mosaicai


Namemosaicai JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryA unified interface for multiple AI language models
upload_time2024-08-18 12:09:43
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2024 syukan3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords ai language model chatgpt claude gemini perplexity
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MosaicAI

[![PyPI version](https://badge.fury.io/py/mosaicai.svg)](https://badge.fury.io/py/mosaicai)
[![Python Versions](https://img.shields.io/pypi/pyversions/mosaicai.svg)](https://pypi.org/project/mosaicai/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

MosaicAIは、複数の最先端AI言語モデル(ChatGPT、Claude、Gemini、Perplexity)を統一的なインターフェースで利用できるPythonライブラリです。

## 特徴

- 複数のAI言語モデルを簡単に利用できる統一されたインターフェース
- API Keyの安全な管理と再利用
- 拡張性を持つ設計で、新しいAIモデルの追加が容易

## インストール

pipを使用してMosaicAIをインストールできます:

```bash
$ pip install mosaicai
```

## 要件

- Python 3.7以上
- 各AI言語モデルのAPIキー

## 使用方法

1. まず、プロジェクトのルートディレクトリに`.env`ファイルを作成し、以下のように設定してください:

```
# OpenAI (ChatGPT) API Key
OPENAI_API_KEY=YOUR-OPENAI_API_KEY

# Anthropic (Claude) API Key
ANTHROPIC_API_KEY=YOUR-ANTHROPIC_API_KEY

# Google (Gemini) API Key
GOOGLE_API_KEY=YOUR-GOOGLE_API_KEY

# Perplexity API Key
PERPLEXITY_API_KEY=YOUR-PERPLEXITY_API_KEY

# Default model (optional)
DEFAULT_MODEL=gemini

# Logging configuration (optional)
LOG_LEVEL=INFO
LOG_FILE=mosaicai.log

# Request configuration (optional)
REQUEST_TIMEOUT=30
MAX_RETRIES=3
```

2. 基本的な使用例を以下に示します:

```python
from mosaicai import MosaicAI

# クライアントの初期化
client = MosaicAI(model="gpt-4o")

# テキスト生成
response = client.generate_text("AIの未来について教えてください")
print(response)

# 画像を使用した生成
image_path = "path/to/your/image.jpg"
response = client.generate_with_image("この画像について説明してください", image_path)
print(response)

# JSON生成
from pydantic import BaseModel
from typing import List
class AIEthicsResponse(BaseModel):
    title: str
    points: List[str]
    summary: str
    integer_value: int
    float_value: float
    boolean_flag: bool
    nested_object: Dict[str, Any]
    array_of_numbers: List[float]

response = client.generate_json("AIの倫理的課題について3つのポイントを挙げてください", AIEthicsResponse)
print(response)

# 画像付きJSON生成
class AIProductFeatures(BaseModel):
    product_name: str
    features: List[str]
    overall_impression: str
    price: float
    is_available: bool
    release_date: str
    specifications: Dict[str, Union[str, int, float, bool]]
    ratings: List[int]

image_json_response = client.generate_with_image_json("path/to/image.jpg", "この画像に基づいて、製品の特徴を3つ挙げてください", AIProductFeatures)
```

より詳細な使用例については、[examples](examples)ディレクトリを参照してください。

## ドキュメンテーション

詳細なドキュメントは[こちら](https://mosaicai.readthedocs.io/)で見ることができます。

## ライセンス

MosaicAIはMITライセンスの下で公開されています。詳細は[LICENSE](LICENSE)ファイルを参照してください。

## 貢献

MosaicAIはオープンソースプロジェクトです。バグの報告、機能の提案、コードの貢献など、ご協力いただけます。詳細は[CONTRIBUTING.md](CONTRIBUTING.md)を参照してください。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mosaicai",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "ai, language model, chatgpt, claude, gemini, perplexity",
    "author": null,
    "author_email": "syukan3 <syun3ac@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d1/3a/5ef84df4f8eed94fb5fa2aba7bc3ef0ff5d0f2cd1a5a5ab8a9518f5d8e6e/mosaicai-0.1.4.tar.gz",
    "platform": null,
    "description": "# MosaicAI\n\n[![PyPI version](https://badge.fury.io/py/mosaicai.svg)](https://badge.fury.io/py/mosaicai)\n[![Python Versions](https://img.shields.io/pypi/pyversions/mosaicai.svg)](https://pypi.org/project/mosaicai/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nMosaicAI\u306f\u3001\u8907\u6570\u306e\u6700\u5148\u7aefAI\u8a00\u8a9e\u30e2\u30c7\u30eb\uff08ChatGPT\u3001Claude\u3001Gemini\u3001Perplexity\uff09\u3092\u7d71\u4e00\u7684\u306a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u5229\u7528\u3067\u304d\u308bPython\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\n\n## \u7279\u5fb4\n\n- \u8907\u6570\u306eAI\u8a00\u8a9e\u30e2\u30c7\u30eb\u3092\u7c21\u5358\u306b\u5229\u7528\u3067\u304d\u308b\u7d71\u4e00\u3055\u308c\u305f\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\n- API Key\u306e\u5b89\u5168\u306a\u7ba1\u7406\u3068\u518d\u5229\u7528\n- \u62e1\u5f35\u6027\u3092\u6301\u3064\u8a2d\u8a08\u3067\u3001\u65b0\u3057\u3044AI\u30e2\u30c7\u30eb\u306e\u8ffd\u52a0\u304c\u5bb9\u6613\n\n## \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n\npip\u3092\u4f7f\u7528\u3057\u3066MosaicAI\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\uff1a\n\n```bash\n$ pip install mosaicai\n```\n\n## \u8981\u4ef6\n\n- Python 3.7\u4ee5\u4e0a\n- \u5404AI\u8a00\u8a9e\u30e2\u30c7\u30eb\u306eAPI\u30ad\u30fc\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n1. \u307e\u305a\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b`.env`\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\uff1a\n\n```\n# OpenAI (ChatGPT) API Key\nOPENAI_API_KEY=YOUR-OPENAI_API_KEY\n\n# Anthropic (Claude) API Key\nANTHROPIC_API_KEY=YOUR-ANTHROPIC_API_KEY\n\n# Google (Gemini) API Key\nGOOGLE_API_KEY=YOUR-GOOGLE_API_KEY\n\n# Perplexity API Key\nPERPLEXITY_API_KEY=YOUR-PERPLEXITY_API_KEY\n\n# Default model (optional)\nDEFAULT_MODEL=gemini\n\n# Logging configuration (optional)\nLOG_LEVEL=INFO\nLOG_FILE=mosaicai.log\n\n# Request configuration (optional)\nREQUEST_TIMEOUT=30\nMAX_RETRIES=3\n```\n\n2. \u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\uff1a\n\n```python\nfrom mosaicai import MosaicAI\n\n# \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u521d\u671f\u5316\nclient = MosaicAI(model=\"gpt-4o\")\n\n# \u30c6\u30ad\u30b9\u30c8\u751f\u6210\nresponse = client.generate_text(\"AI\u306e\u672a\u6765\u306b\u3064\u3044\u3066\u6559\u3048\u3066\u304f\u3060\u3055\u3044\")\nprint(response)\n\n# \u753b\u50cf\u3092\u4f7f\u7528\u3057\u305f\u751f\u6210\nimage_path = \"path/to/your/image.jpg\"\nresponse = client.generate_with_image(\"\u3053\u306e\u753b\u50cf\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044\", image_path)\nprint(response)\n\n# JSON\u751f\u6210\nfrom pydantic import BaseModel\nfrom typing import List\nclass AIEthicsResponse(BaseModel):\n    title: str\n    points: List[str]\n    summary: str\n    integer_value: int\n    float_value: float\n    boolean_flag: bool\n    nested_object: Dict[str, Any]\n    array_of_numbers: List[float]\n\nresponse = client.generate_json(\"AI\u306e\u502b\u7406\u7684\u8ab2\u984c\u306b\u3064\u3044\u30663\u3064\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u6319\u3052\u3066\u304f\u3060\u3055\u3044\", AIEthicsResponse)\nprint(response)\n\n# \u753b\u50cf\u4ed8\u304dJSON\u751f\u6210\nclass AIProductFeatures(BaseModel):\n    product_name: str\n    features: List[str]\n    overall_impression: str\n    price: float\n    is_available: bool\n    release_date: str\n    specifications: Dict[str, Union[str, int, float, bool]]\n    ratings: List[int]\n\nimage_json_response = client.generate_with_image_json(\"path/to/image.jpg\", \"\u3053\u306e\u753b\u50cf\u306b\u57fa\u3065\u3044\u3066\u3001\u88fd\u54c1\u306e\u7279\u5fb4\u30923\u3064\u6319\u3052\u3066\u304f\u3060\u3055\u3044\", AIProductFeatures)\n```\n\n\u3088\u308a\u8a73\u7d30\u306a\u4f7f\u7528\u4f8b\u306b\u3064\u3044\u3066\u306f\u3001[examples](examples)\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n## \u30c9\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\n\n\u8a73\u7d30\u306a\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306f[\u3053\u3061\u3089](https://mosaicai.readthedocs.io/)\u3067\u898b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\n\n## \u30e9\u30a4\u30bb\u30f3\u30b9\n\nMosaicAI\u306fMIT\u30e9\u30a4\u30bb\u30f3\u30b9\u306e\u4e0b\u3067\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u8a73\u7d30\u306f[LICENSE](LICENSE)\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n## \u8ca2\u732e\n\nMosaicAI\u306f\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u3059\u3002\u30d0\u30b0\u306e\u5831\u544a\u3001\u6a5f\u80fd\u306e\u63d0\u6848\u3001\u30b3\u30fc\u30c9\u306e\u8ca2\u732e\u306a\u3069\u3001\u3054\u5354\u529b\u3044\u305f\u3060\u3051\u307e\u3059\u3002\u8a73\u7d30\u306f[CONTRIBUTING.md](CONTRIBUTING.md)\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 syukan3  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A unified interface for multiple AI language models",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/syukan3/MosaicAI"
    },
    "split_keywords": [
        "ai",
        " language model",
        " chatgpt",
        " claude",
        " gemini",
        " perplexity"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0ba6b16542f16354fb5d5c40be8ce40ea1062db6050acdb5ad87b04774e65b9",
                "md5": "86aa3b495809c7324c59f2cb00f564cf",
                "sha256": "ca18e54ee64d92680038c5e398dbda3c6f83b16e473c2b8eb0046eab3827a9d8"
            },
            "downloads": -1,
            "filename": "mosaicai-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "86aa3b495809c7324c59f2cb00f564cf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17297,
            "upload_time": "2024-08-18T12:09:42",
            "upload_time_iso_8601": "2024-08-18T12:09:42.492884Z",
            "url": "https://files.pythonhosted.org/packages/f0/ba/6b16542f16354fb5d5c40be8ce40ea1062db6050acdb5ad87b04774e65b9/mosaicai-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d13a5ef84df4f8eed94fb5fa2aba7bc3ef0ff5d0f2cd1a5a5ab8a9518f5d8e6e",
                "md5": "6b0bc8e4c4aa22486087698955042c5f",
                "sha256": "b36f61847fa485df4ddc81213004c81d468667a1285b835a6bcbfc9079d570d2"
            },
            "downloads": -1,
            "filename": "mosaicai-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "6b0bc8e4c4aa22486087698955042c5f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 13871,
            "upload_time": "2024-08-18T12:09:43",
            "upload_time_iso_8601": "2024-08-18T12:09:43.835318Z",
            "url": "https://files.pythonhosted.org/packages/d1/3a/5ef84df4f8eed94fb5fa2aba7bc3ef0ff5d0f2cd1a5a5ab8a9518f5d8e6e/mosaicai-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-18 12:09:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "syukan3",
    "github_project": "MosaicAI",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mosaicai"
}
        
Elapsed time: 1.71352s