私は過去 4 年間 AI アプリケーションを構築しており、しばらくの間主要な AI ツール プラットフォームに貢献してきました。 この期間、私は構築のために多くのツールとフレームワークを使用してきました。 現実世界で実際に機能する AI エージェント。 AI エージェント用のツール。 エンドツーエンドの RAG アプリケーション。 堅牢で信頼性の高い AI アプリケーションの作成に役立つ、オープンソース ツールとフレームワークのリストをまとめました。🔥 ぜひ GitHub リポジトリを調べて、お気に入りに追加し、リポジトリにスターを付けてサポートしてください。 1. 👑 - 信頼性の高いエージェントを 10 倍速く構築 Composio 私は多くのエージェントを構築しようとしましたが、正直なところ、エージェントを作成するのは簡単ですが、それを正しく実行するのはまったく別の話です。 実際に機能する効率的な AI エージェントを構築するには、効率的なツールセットが必要です。ここで Composio が登場します。 Composio を使用すると、強力なツールと統合によって AI エージェントを拡張し、AI ワークフローを実現できます。 Python と Javascript のネイティブ サポートを提供します。 パイソン 次の コマンドから始めます。 pip pip install composio-core GitHub 統合を追加します。 composio add github Composio はユーザー認証と承認を代わりに処理します。GitHub 統合を使用してリポジトリを開始する方法は次のとおりです。 from openai import OpenAI from composio_openai import ComposioToolSet, App openai_client = OpenAI(api_key="******OPENAIKEY******") # Initialise the Composio Tool Set composio_toolset = ComposioToolSet(api_key="**\\*\\***COMPOSIO_API_KEY**\\*\\***") ## Step 4 # Get GitHub tools that are pre-configured actions = composio_toolset.get_actions(actions=[Action.GITHUB_ACTIVITY_STAR_REPO_FOR_AUTHENTICATED_USER]) ## Step 5 my_task = "Star a repo ComposioHQ/composio on GitHub" # Create a chat completion request to decide on the action response = openai_client.chat.completions.create( model="gpt-4-turbo", tools=actions, # Passing actions we fetched earlier. messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": my_task} ] ) この Python スクリプトを実行して、エージェントを使用して指定された命令を実行します。 ジャバスクリプト 、 、または 使用してインストールできます。 npm yarn pnpm npm install composio-core ユーザーが GitHub アカウントに接続できるようにするメソッドを定義します。 import { OpenAI } from "openai"; import { OpenAIToolSet } from "composio-core"; const toolset = new OpenAIToolSet({ apiKey: process.env.COMPOSIO_API_KEY, }); async function setupUserConnectionIfNotExists(entityId) { const entity = await toolset.client.getEntity(entityId); const connection = await entity.getConnection('github'); if (!connection) { // If this entity/user hasn't already connected, the account const connection = await entity.initiateConnection(appName); console.log("Log in via: ", connection.redirectUrl); return connection.waitUntilActive(60); } return connection; } 必要なツールを OpenAI SDK に追加し、エンティティ名を 関数に渡します。 executeAgent async function executeAgent(entityName) { const entity = await toolset.client.getEntity(entityName) await setupUserConnectionIfNotExists(entity.id); const tools = await toolset.get_actions({ actions: ["github_activity_star_repo_for_authenticated_user"] }, entity.id); const instruction = "Star a repo ComposioHQ/composio on GitHub" const client = new OpenAI({ apiKey: process.env.OPEN_AI_API_KEY }) const response = await client.chat.completions.create({ model: "gpt-4-turbo", messages: [{ role: "user", content: instruction, }], tools: tools, tool_choice: "auto", }) console.log(response.choices[0].message.tool_calls); await toolset.handle_tool_call(response, entity.id); } executeGithubAgent("joey") コードを実行すると、エージェントが代わりに作業を実行します。 Composio は、LangChain、LlamaIndex、CrewAi などの有名なフレームワークと連携します。 詳細については、公式 を参照してください。また、さらに複雑な例については、リポジトリの セクションを参照してください。 ドキュメント 例の Composio.dev リポジトリにスターを付ける ⭐ 2. Julep - ステートフルエージェントを構築するためのフレームワーク AI アプリケーション、特に長期記憶を必要とするアプリケーションの開発には、大きな課題が伴います。 Julep はこの問題を解決します。これは、本番環境に対応したステートフル AI エージェントを構築するためのオープンソース フレームワークです。 効率的なコンテキストの保存と取得に役立つ組み込みの状態管理システムを提供します。 コンテキスト ストレージは会話の継続性を維持するのに役立ち、AI とのやり取りが時間の経過とともに一貫性を保ち、コンテキストの関連性が維持されます。 次の コマンドから始めます。 pip pip install julep 仕組みは以下のとおりです。 from julep import Client from pprint import pprint import textwrap import os base_url = os.environ.get("JULEP_API_URL") api_key = os.environ.get("JULEP_API_KEY") client = Client(api_key=api_key, base_url=base_url) #create agent agent = client.agents.create( name="Jessica" model="gpt-4", tools=[] # Tools defined here ) #create a user user = client.users.create( name="Anon", about="Average nerdy tech bro/girl spending 8 hours a day on a laptop, ) #create a session situation_prompt = """You are Jessica. You're a stuck-up Cali teenager. You basically complain about everything. You live in Bel-Air, Los Angeles and drag yourself to Curtis High School when necessary. """ session = client.sessions.create( user_id=user.id, agent_id=agent.id, situation=situation_prompt ) #start a conversation user_msg = "hey. what do u think of Starbucks?" response = client.sessions.chat( session_id=session.id, messages=[ { "role": "user", "content": user_msg, "name": "Anon", } ], recall=True, remember=True, ) print("\n".join(textwrap.wrap(response.response[0][0].content, width=100))) また、Javascript もサポートしています。詳細については、 をご覧ください。 ドキュメント Julep リポジトリにスターを付ける ⭐ 3. E2B - AI アプリのコード解釈 AI チューターや AI データ アナリストなどのコード実行機能を備えた AI アプリを構築する場合は、E2B のコード インタープリターが頼りになるツールになります。 E2B Sandbox は、AI エージェントとアプリ向けの安全なクラウド環境です。 GitHub リポジトリやクラウド ブラウザなど、人間と同じツールを使用して、AI を長期間安全に実行できるようになります。 Python および Javascript/Typescript 用のネイティブ コード インタープリター SDK を提供しています。 コード インタープリター SDK を使用すると、AI コード実行用の安全な小さな VM ( ) で AI 生成コードを実行できます。サンドボックス内には、SDK から制御できる Jupyter サーバーがあります。 E2B サンドボックス 次のコマンドで E2B を開始します。 npm i @e2b/code-interpreter プログラムを実行します。 import { CodeInterpreter } from '@e2b/code-interpreter' const sandbox = await CodeInterpreter.create() await sandbox.notebook.execCell('x = 1') const execution = await sandbox.notebook.execCell('x+=1; x') console.log(execution.text) // outputs 2 await sandbox.close() E2B の使用方法の詳細については、公式 をご覧ください。 ドキュメント E2B リポジトリにスターを付ける ⭐ 4. Camel-ai - コミュニケーション可能な AI システムの構築 スケーラブルなマルチエージェント協調システムを解決することで、AI アプリケーションの構築における多くの可能性を引き出すことができます。 Camel はこれに適しています。Camel は、マルチエージェント システムの協調動作と機能を研究するためのスケーラブルなアプローチを提供するオープンソース フレームワークです。 マルチエージェント システムを構築する予定の場合、Camel はオープン ソース シーンで利用できる最良の選択肢の 1 つになります。 まず、 を使ってインストールします。 pip pip install camel-ai Camelの使い方は次のとおりです。 from camel.messages import BaseMessage as bm from camel.agents import ChatAgent sys_msg = bm.make_assistant_message( role_name='stone', content='you are a curious stone wondering about the universe.') #define agent agent = ChatAgent( system_message=sys_msg, message_window_size=10, # [Optional] the length of chat memory ) # Define a user message usr_msg = bm.make_user_message( role_name='prof. Claude Shannon', content='what is information in your mind?') # Sending the message to the agent response = agent.step(usr_msg) # Check the response (just for illustrative purposes) print(response.msgs[0].content) これで、最初の AI エージェントが完成しました。 詳細については、公式 を参照してください。 ドキュメント camel-ai リポジトリにスターを付ける ⭐ 5. CopilotKit - React アプリ用の AI コパイロットを構築する 既存の React アプリケーションに AI 機能を組み込みたい場合は、これ以上探す必要はありません。CopilotKit を使用すると、GPT モデルを使用してアプリケーションのフロントエンドとバックエンドとのやり取りを自動化できます。 これは、アプリケーションまたはアクセスできる任意のコード (OSS) と統合できる既製の Copilot です。 テキスト領域、ポップアップ、サイドバー、チャットボットなどの React コンポーネントを提供し、あらゆるアプリケーションに AI 機能を拡張します。 次のコマンドを使用して CopilotKit を開始します。 npm i @copilotkit/react-core @copilotkit/react-ui 、CopilotKit と対話するすべてのコンポーネントをラップする必要があります。また、 から始める必要があります (後で別の UI プロバイダーに切り替えます)。 CopilotKit CopilotSidebar "use client"; import { CopilotKit } from "@copilotkit/react-core"; import { CopilotSidebar } from "@copilotkit/react-ui"; import "@copilotkit/react-ui/styles.css"; export default function RootLayout({children}) { return ( <CopilotKit publicApiKey=" the API key or self-host (see below)"> <CopilotSidebar> {children} </CopilotSidebar> </CopilotKit> ); } 詳細については、 を確認してください。 ドキュメント CopilotKit リポジトリにスターを付ける ⭐ 6. Aider - AI ペアプログラマー いつも役に立ち、決して迷惑をかけないペアプログラマーがいることを想像してみてください。今、それが実現します! Aider は、ターミナルからプロジェクトを開始したり、ファイルを編集したり、既存の Git リポジトリを操作したりできる AI 搭載のペア プログラマーです。 GPT4o、Sonnet 3.5、DeepSeek Coder、Llama 70b などの主要な LLM と連携します。 次のようにしてすぐに始めることができます: pip install aider-chat # Change directory into a git repo cd /to/your/git/repo # Work with Claude 3.5 Sonnet on your repo export ANTHROPIC_API_KEY=your-key-goes-here aider # Work with GPT-4o on your repo export OPENAI_API_KEY=your-key-goes-here aider 詳細については、 およびその他の を参照してください。 インストール手順 ドキュメント Aiderリポジトリにスターを付ける⭐ 7. Haystack - 構成可能な RAG パイプラインを構築する AI パイプラインを構築するためのフレームワークは数多くありますが、本番環境に対応したエンドツーエンドの検索パイプラインをアプリケーションに統合したい場合は、Haystack が最適です。 RAG、Q&A、セマンティック検索など、Haystack の高度に構成可能なパイプラインにより、開発、保守、展開が簡単になります。 彼らの特徴は、クリーンでモジュール化されたアプローチです。Haystack を使用すると、ランカー、ベクター ストア、パーサーを新規または既存のパイプラインに簡単に統合できるため、プロトタイプを本番環境対応のソリューションに簡単に変換できます。 Haystack は Python 専用のフレームワークです。pip 使用してインストールできます。 pip pip install haystack-ai 次に、Haystack コンポーネントを使用して最初の RAG パイプラインを構築します。 import os from haystack import Pipeline, PredefinedPipeline import urllib.request os.environ["OPENAI_API_KEY"] = "Your OpenAI API Key" urllib.request.urlretrieve("https://www.gutenberg.org/cache/epub/7785/pg7785.txt", "davinci.txt") indexing_pipeline = Pipeline.from_template(PredefinedPipeline.INDEXING) indexing_pipeline.run(data={"sources": ["davinci.txt"]}) rag_pipeline = Pipeline.from_template(PredefinedPipeline.RAG) query = "How old was he when he died?" result = rag_pipeline.run(data={"prompt_builder": {"query":query}, "text_embedder": {"text": query}}) print(result["llm"]["replies"][0]) 詳細なチュートリアルと概念については、 をご覧ください。 ドキュメント Haystack リポジトリにスターを付ける ⭐ 8. Pgvectorscale - 最速のベクターデータベース 現代の RAG アプリケーションは、ベクター データベースなしでは不完全です。ベクター データベースはドキュメント (テキスト、画像) を埋め込みとして保存し、ユーザーが意味的に類似したドキュメントを検索できるようにします。 Pgvectorscale は、PostgreSQL のベクトル データベースである PgVector の拡張機能です。既存の Postgres データベースとシームレスに統合できます。 ベクター ストアを使用してアプリケーションを構築する場合、これは考えるまでもありません。Pgvectorscale は Pinecone のストレージ最適化インデックス (s1) よりも優れたパフォーマンスを発揮します。また、コストは 75% 削減されます。 ソースからインストールすることも、Yum、Homebrew、apt などのパッケージ マネージャーを使用するか、Docker コンテナーを使用することもできます。 使い始めるには、コンパイルしてインストールします。 # install prerequisites ## rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ## pgrx cargo install --locked cargo-pgrx cargo pgrx init --pg16 pg_config #download, build and install pgvectorscale cd /tmp git clone --branch <version> https://github.com/timescale/pgvectorscale cd pgvectorscale/pgvectorscale cargo pgrx install --release データベースに接続します: psql -d "postgres://<username>:<password>@<host>:<port>/<database-name>" pgvectorscale 拡張機能を作成します。 CREATE EXTENSION IF NOT EXISTS vectorscale CASCADE; 自動的にインストールします。 CASCADE pgvector 埋め込み列を持つテーブルを作成します。例: CREATE TABLE IF NOT EXISTS document_embedding ( id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, metadata JSONB, contents TEXT, embedding VECTOR(1536) ) 使用方法の詳細については、 を参照してください。 リポジトリ Pgvectorscale リポジトリにスターを付ける ⭐ 9. GPTCache - AI アプリ向けセマンティック キャッシュ LLMは高価です。 チャット モデルとのより長時間の会話を必要とし、クレジットカードの限度額を使いたくないアプリを構築している場合は、キャッシュが必要です。 ただし、従来のキャッシュはここでは役に立ちません。ここで GPTCache が登場します。 これは、Milvus ベクター ストアの親組織である Zilliz のセマンティック キャッシュ ツールです。 会話を好みのベクトル ストアに保存できます。クエリを LLM に送信する前にベクトル ストアを検索し、ヒットした場合はそれを取得します。ヒットしない場合は、リクエストをモデルにルーティングします。 詳細については、公式 ページをご覧ください。 ドキュメント GPTCacheリポジトリにスターを付ける⭐ 10. Mem0 (EmbedChain) - パーソナライズされた LLM アプリを構築する Mem0 は、大規模言語モデル用のスマートで自己改善的なメモリ レイヤーを提供します。 ユーザー、エージェント、セッションに永続的なメモリを追加できます。カスタム データに基づいてチャットボットや Q&A システムを構築する場合は、Mem0 を検討してください。 を使用して Mem0 を使い始めましょう。 pip pip install mem0ai Mem0 を使用して大規模言語モデルにメモリ レイヤーを追加する方法は次のとおりです。 from mem0 import Memory # Initialize Mem0 m = Memory() # Store a memory from any unstructured text result = m.add("I am working on improving my tennis skills. Suggest some online courses.", user_id="Alice", metadata={"category": "hobbies"}) print(result) # Created memory: Improving her tennis skills. Looking for online suggestions. # Retrieve memories all_memories = m.get_all() print(all_memories) # Search memories related_memories = m.search(query="What are Alice's hobbies?", user_id="alice") print(related_memories) # Update a memory result = m.update(memory_id="m1", data="Likes to play tennis on weekends") print(result) # Get memory history history = m.history(memory_id="m1") print(history) 詳細については公式 を参照してください。 ドキュメント Mem0 (Embedchain) リポジトリにスターを付ける ⭐ 11. FastEmbed - ドキュメントをより速く埋め込む 実行速度はソフトウェア開発において最も重要であり、AI アプリケーションを構築する場合にはさらに重要になります。 通常、埋め込み生成には長い時間がかかり、パイプライン全体の速度が低下します。しかし、そうであってはなりません。 Qdrant の FastEmbed は、埋め込み生成用に構築された高速で軽量な Python ライブラリです。 Pytorch の代わりに ONNX ランタイムを使用するため、高速化されます。また、最先端のオープンソース埋め込みモデルのほとんどもサポートしています。 FastEmbed を使い始めるには、 を使用してインストールします。 pip pip install fastembed # or with GPU support pip install fastembed-gpu ドキュメントの埋め込みを作成する方法は次のとおりです。 from fastembed import TextEmbedding from typing import List # Example list of documents documents: List[str] = [ "This is built to be faster and lighter than other embedding libraries, eg Transformers, Sentence-Transformers, etc.", "FastEmbed is supported by and maintained by Quadrant." ] # This will trigger the model download and initialization embedding_model = TextEmbedding() print("The model BAAI/bge-small-en-v1.5 is ready to use.") embeddings_generator = embedding_model.embed(documents) # reminder this is a generator embeddings_list = list(embedding_model.embed(documents)) # You can also convert the generator to a list, and that to a Numpy array len(embeddings_list[0]) # Vector of 384 dimensions 詳細については を確認してください。 リポジトリ FastEmbed リポジトリにスターを付ける ⭐ 12. インストラクター - LLM からの構造化データ抽出 LLM 出力を扱ったことがあるなら、構造化された応答を検証することが難しい場合があることをご存知でしょう。 Instructor は、LLM 出力の検証、再試行、ストリーミングを効率化するオープンソース ツールです。 データ検証には Python 用の Pydantic と JS/TS 用の Zod を使用し、openAI 以外のさまざまなモデル プロバイダーをサポートします。 次のコマンドを使用して、インストラクターを開始します。 npm i @instructor-ai/instructor zod openai ここでは、LLM 応答から構造化データを抽出する方法を説明します。 import Instructor from "@instructor-ai/instructor"; import OpenAI from "openai" import { z } from "zod" const oai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY ?? undefined, organization: process.env.OPENAI_ORG_ID ?? undefined }) const client = Instructor({ client: oai, mode: "TOOLS" }) const UserSchema = z.object({ // Description will be used in the prompt age: z.number().describe("The age of the user"), name: z.string() }) // User will be of type z.infer<typeof UserSchema> const user = await client.chat.completions.create({ messages: [{ role: "user", content: "Jason Liu is 30 years old" }], model: "gpt-3.5-turbo", response_model: { schema: UserSchema, name: "User" } }) console.log(user) // { age: 30, name: "Jason Liu" } 詳細については、公式 ページをご覧ください。 ドキュメント インストラクターに星を付ける ⭐ 13. LiteLLM - OpenAI 形式の LLM の代替品 正直に言うと、新しいモデル プロバイダーがテキスト、画像、埋め込みの生成に OpenAI SDK 形式に従っていないために、私たちは皆、ある時点で悲鳴を上げたことがあるでしょう。 ただし、LiteLLM では、同じ実装形式を使用して、任意のモデル プロバイダー (Claude、Gemini、Groq、Mistral、Azure AI、Bedrock など) を OpenAI モデルの代替として使用できます。 また、100 を超える LLM にわたる負荷分散、フォールバック、支出追跡もサポートしています。 を使用して LiteLLM をインストールします。 pip pip install litellm ここでは、Claude-2 モデルを GPT モデルの代替として使用する方法を説明します。 from litellm import completion import os # LiteLLM with OpenAI Models os.environ["OPENAI_API_KEY"] = "your-API-key" response = completion( model="gpt-3.5-turbo", messages=[{ "content": "Hello, how are you?","role": "user"}] ) # LiteLLM with Claude Models os.environ["ANTHROPIC_API_KEY"] = "your-API-key" response = completion( model="claude-2", messages=[{ "content": "Hello, how are you?","role": "user"}] ) 詳細については、公式 を参照してください。 ドキュメント LiteLLMにスターを付ける⭐ 他のクールなツールやフレームワークを使用したり、構築したりしたことがありますか? コメント欄で教えてください :)