A unified interface for multiple AI language models
Project description
MosaicAI
MosaicAIは、複数の最先端AI言語モデル(ChatGPT、Claude、Gemini、Perplexity)を統一的なインターフェースで利用できるPythonライブラリです。
特徴
- 複数のAI言語モデルを簡単に利用できる統一されたインターフェース
- API Keyの安全な管理と再利用
- 拡張性を持つ設計で、新しいAIモデルの追加が容易
インストール
pipを使用してMosaicAIをインストールできます:
$ pip install mosaicai
要件
- Python 3.7以上
- 各AI言語モデルのAPIキー
使用方法
- まず、プロジェクトのルートディレクトリに
.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
- 基本的な使用例を以下に示します:
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ディレクトリを参照してください。
ドキュメンテーション
詳細なドキュメントはこちらで見ることができます。
ライセンス
MosaicAIはMITライセンスの下で公開されています。詳細はLICENSEファイルを参照してください。
貢献
MosaicAIはオープンソースプロジェクトです。バグの報告、機能の提案、コードの貢献など、ご協力いただけます。詳細はCONTRIBUTING.mdを参照してください。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mosaicai-0.1.4.tar.gz.
File metadata
- Download URL: mosaicai-0.1.4.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b36f61847fa485df4ddc81213004c81d468667a1285b835a6bcbfc9079d570d2
|
|
| MD5 |
6b0bc8e4c4aa22486087698955042c5f
|
|
| BLAKE2b-256 |
d13a5ef84df4f8eed94fb5fa2aba7bc3ef0ff5d0f2cd1a5a5ab8a9518f5d8e6e
|
File details
Details for the file mosaicai-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mosaicai-0.1.4-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca18e54ee64d92680038c5e398dbda3c6f83b16e473c2b8eb0046eab3827a9d8
|
|
| MD5 |
86aa3b495809c7324c59f2cb00f564cf
|
|
| BLAKE2b-256 |
f0ba6b16542f16354fb5d5c40be8ce40ea1062db6050acdb5ad87b04774e65b9
|