エージェント・メモリーの開始
この記事では、エージェント・メモリーのインストールと、ユーザー・コンテキストの格納および取得などの基本的なメモリー操作の実行について説明します。
前提条件
次のものがあることを確認します。
- Oracle AI Databaseへのアクセス(ローカルでのOracle AI Databaseの実行を参照)
- Python 3.10以降
SDKのインストール
エージェント・メモリーをインストールするには、次を実行します。
pip install "oracleagentmemory==26.4.0"
pipを使用してインストールすると、サポートされているプラットフォームで事前構築済のバイナリ・ホイールがプルされます。
メモリー・インスタンスの初期化
埋込み、LLMおよびデータベース接続を構成して、OracleAgentMemoryインスタンスを作成します。
from oracleagentmemory.core.oracleagentmemory import OracleAgentMemory
from oracleagentmemory.apis.searchscope import SearchScope
from oracleagentmemory.core.embedders.embedder import Embedder
from oracleagentmemory.core.llms.llm import Llm
embedder = Embedder(model="YOUR_EMBEDDING_MODEL")
llm = Llm(model="YOUR_LLM")
db_pool = ... #an oracledb connection or connection pool
memory = OracleAgentMemory(connection=db_pool, embedder=embedder, llm=llm)
メモリー・エントリの格納
スレッドを作成し、メッセージを追加し、ユーザーのメモリー・エントリを格納することから始めます。
messages = [
{
"role": "user",
"content": (
"Orange juice has become my favorite breakfast drink lately, "
"what can I pair it with?"
),
},
{
"role": "assistant",
"content": (
"Nice! Orange juice goes great with something savory. "
"Try eggs and toast, avocado toast, or a breakfast sandwich."
),
},
]
thread = memory.create_thread(user_id="user_123")
#add_messages will add messages to the DB and extract memories automatically
thread.add_messages(messages)
#add_memory adds memory to the DB
thread.add_memory("The user likes orange juice with breakfast.")
メモリー・エントリの取得
ユーザー・スコープ問合せを使用してメモリーを検索します。
results = memory.search(query="orange juice", scope=SearchScope(user_id="user_123"))
for result in results:
print(f"- [{result.record.record_type}] {result.content}")
出力:
-[memory] The user likes orange juice with breakfast.
-[message] Orange juice has become my favorite breakfast drink lately, what can I pair it with?
-[message] Nice! Orange juice goes great with something savory.
Try eggs and toast,avocado toast, or a breakfast sandwich.
ノート:示されている出力は図です。将来のバージョンでは、追加の結果タイプ、フィールド、または順序付けが返される場合があります。
モデル互換性
2026年4月時点で、次の大規模言語モデル(LLM)および埋込みモデルはoracleagentmemoryと互換性があります。
LLM
次の大規模言語モデル(LLM)が互換性があることが確認されました。
vllm
openai/google/gemma-4-26B-A4B-itopenai/openai/gpt-oss-120b
oci
oci/google.gemini-2.5-flashoci/google.gemini-2.5-flash-liteoci/google.gemini-2.5-prooci/xai.grok-3oci/xai.grok-3-fastoci/xai.grok-3-minioci/xai.grok-3-mini-fastoci/xai.grok-4oci/xai.grok-4-1-fast-non-reasoningoci/xai.grok-4-1-fast-reasoningoci/xai.grok-4-fast-non-reasoningoci/xai.grok-4-fast-reasoningoci/xai.grok-4.20-non-reasoningoci/xai.grok-4.20-reasoningoci/xai.grok-code-fast-1oci/cohere.command-latestoci/cohere.command-a-03-2025oci/cohere.command-a-reasoning-08-2025oci/cohere.command-a-vision-07-2025oci/cohere.command-a-translate-08-2025oci/cohere.command-plus-latestoci/cohere.cohere.command-r-08-2024oci/cohere.command-r-plus-08-2024
ジェミニ
gemini/gemini-3.1-flash-lite-previewgemini/gemini-3-flash-previewgemini/gemini-3.1-pro-preview
人類
anthropic/claude-opus-4-7anthropic/claude-opus-4-6anthropic/claude-sonnet-4-6anthropic/claude-haiku-4-5
オープンアイ
openai/gpt-4.1openai/gpt-4.1-miniopenai/gpt-4oopenai/gpt-5openai/gpt-5-miniopenai/gpt-5.1openai/gpt-5.2openai/gpt-5.4openai/gpt-5.4-mini
埋込み
次の埋込みモデルが互換性があることが確認されました。
host_vllm
hosted_vllm/Snowflake/snowflake-arctic-embed-l-v2.0
oci
oci/cohere.embed-english-v3.0oci/cohere.embed-english-light-v3.0oci/cohere.embed-multilingual-v3.0oci/cohere.embed-v4.0
ジェミニ
gemini/gemini-embedding-001gemini/gemini-embedding-2-preview
オープンアイ
openai/text-embedding-3-largeopenai/text-embedding-3-small