代理内存

本页介绍具体的 Oracle AI Agent Memory 实施。

Oracle 代理内存

注:OracleAgentMemory.delete_thread() 是线程范围级联清除支持的路径。它将删除线程以及关联的消息、持久存储和托管检索数据。这比 OracleThread.delete_message() 更宽,后者仅删除原始消息行。客户端级删除将等待相关的早期后台提取:线程删除将等待该线程,内存删除将等待存储目标的线程(如果存在),用户或代理删除将等待已知拥有的线程(无论是否启用了级联清除)。这些等待仅涵盖同一客户机在等待开始之前接受的工作。

class oracleagentmemory.core.OracleAgentMemory

基础:IAgentMemory

由 Oracle DB 或呼叫方提供的存储支持的代理内存客户机。

创建内存客户机。

警告:SchemaPolicy.CREATE_IF_NECESSARY 可能比普通客户端启动贵,因为它可能会在初始化成功之前应用托管方案 DDL 和尽力重写数据。在旧托管方案包含多个行时,将首次打开的托管方案计划为迁移或维护操作。

如果方案设置必须创建托管的过期记录清除作业,但数据库用户缺少调度程序 - 作业权限,则初始化将警告并继续。过期的消息和记忆不会被读取和搜索隐藏,但是在具有 CREATE JOB 或等效调度程序权限的用户创建作业之前,这些消息和记忆不会被物理清除。

当 SchemaPolicy.CREATE_IF_NECESSARY 首次在现有方案上创建托管混合索引时,Oracle 会扫描存储的搜索文本,并从配置的数据库内模型构建托管混合索引状态。客户机启动将等待该 DDL 完成,因此,请计划第一次将混合升级作为大型方案的迁移或维护操作。SearchIndexSyncMode 控制索引存在后正在进行的维护;它不会使第一个索引构建异步。

示例

要访问由其他数据库用户创建的方案,请为应用程序数据库用户配置 memory_rw_pool,并将 memory_schema_owner 设置为所有者用户的无引号数据库名称。

from oracleagentmemory.core import (
    MemoryExtractionConfig,
    SearchIndexSyncMode,
    OracleAgentMemory,
    SchemaPolicy,
    SearchStrategy,
)
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
read_only_client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    memory_extraction_config=MemoryExtractionConfig(extract_memories=False),
)
pruned_search_client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    memory_extraction_config=MemoryExtractionConfig(extract_memories=False),
    pruner_llm=llm,
)
shared_client = OracleAgentMemory(
    connection=memory_rw_pool,
    embedder=embedder,
    llm=llm,
    schema_owner=memory_schema_owner,
)

使用数据库内嵌入模型利用 Oracle 混合索引搜索:

from oracleagentmemory.core.embedders import OracleDBEmbedder
db_embedder = OracleDBEmbedder(
    connection=db_pool,
    model="DOC_MODEL",
    embedding_dimension=768,
)
hybrid_client = OracleAgentMemory(
    connection=db_pool,
    embedder=db_embedder,
    schema_policy=SchemaPolicy.CREATE_IF_NECESSARY,
    search_strategy=SearchStrategy.HYBRID,
    search_index_sync=SearchIndexSyncMode.ON_COMMIT,
    memory_store_id=memory_store_id,
)

method add_agent

将座席概要信息记录添加到门店。

注释

代理概要信息记录存储在客户端级存储中,并有意取消范围。返回的记录标识符与应用程序用作 agent_id 的公共标识符相同。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
client.add_agent(
    "a1",
    "Support assistant",
    metadata={"source": "catalog"},
)
'a1'

method add_agent_async(异步)

将代理概要信息记录异步添加到门店。

注释

代理概要信息记录存储在客户端级存储中,并有意取消范围。返回的记录标识符与应用程序用作 agent_id 的公共标识符相同。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
import asyncio
asyncio.run(client.add_agent_async(
    "a1",
    "Support assistant",
    metadata={"source": "catalog"},
))
'a1'

method add_image

向客户端添加图像记录。

示例

image_id = client.add_image(
    b"image-bytes",
    description="Image description",
    mime_type=ImageMimeType.PNG,
    image_id="img-1",
    user_id="user-1",
)
image_id
'img-1'

method add_image_async(异步)

通过配置的存储持久保存一个独立映像。

如果省略 description 或 None,则配置的 LLM 将生成标题。

method add_memory

在内存系统中添加内存,该内存归属于指示的用户、代理和线程。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
memory_id = client.add_memory("User likes pizza", memory_id="mem-1")
memory_id
'mem-1'

method add_memory_async(异步)

在内存系统中异步添加内存。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
import asyncio
memory_id = asyncio.run(client.add_memory_async(
    "User likes pizza", memory_id="mem-1"
))
memory_id
'mem-1'

method add_user

将用户概要信息记录添加到门店。

注释

用户概要信息记录存储在客户端级存储中,并且有意取消范围。返回的记录标识符与应用程序用作 user_id 的公共标识符相同。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
client.add_user(
    "u1",
    "Prefers concise answers.",
    metadata={"source": "crm"},
)
'u1'

method add_user_async(异步)

将用户概要信息记录异步添加到门店。

注释

用户概要信息记录存储在客户端级存储中,并且有意取消范围。返回的记录标识符与应用程序用作 user_id 的公共标识符相同。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
import asyncio
asyncio.run(client.add_user_async(
    "u1",
    "Prefers concise answers.",
    metadata={"source": "crm"},
))
'u1'

method close

关闭代理内存组件。

关闭将停止接受新的后台工作,包括内存提取和图像描述生成,并等待待定工作完成到配置的超时。如果该超时到期,即使某些工作仍未完成,close() 也会返回。方法是幂等的。

示例

client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    schema_policy=SchemaPolicy.CREATE_IF_NECESSARY,
    memory_extraction_config=MemoryExtractionConfig(extract_memories=False),
)
client.close()

method close_async(异步)

异步关闭代理内存组件。

此方法遵循与 close() 相同的关闭行为。如果超时到期,则可以在后台工作仍在运行时返回。

示例

import asyncio
asyncio.run(client.close_async())

method create_thread

创建并注册主题。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
thread = client.create_thread(thread_id="c1", user_id="u1")
thread.thread_id
'c1'

method create_thread_async(异步)

异步创建并注册线程。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
import asyncio
thread = asyncio.run(client.create_thread_async(
    thread_id="c1", user_id="u1"
))
thread.thread_id
'c1'

method delete_agent

按标识符删除代理概要记录。

注释

在删除配置文件之前,此方法最多等待 300 秒,以便通过此代理内存组件已知的所有线程可以接受更早的后台提取。无论是否启用级联清除,此等待均适用。级联清理作为一项操作在后备存储内计划和执行。该方法不会等待等待等待开始后接受的工作,也不会等待其他代理内存组件或进程启动的工作。不支持在删除过程中同时使用操作者范围。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
client.add_agent("a-delete", "Support assistant")
'a-delete'
client.delete_agent("a-delete")
1

method delete_agent_async(异步)

异步删除按标识符列出的代理概要信息记录。

注释

此方法遵循 delete_agent() 所记录的后台提取等待和并发行为。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
import asyncio
asyncio.run(client.add_agent_async("a-delete", "Support assistant"))
'a-delete'
asyncio.run(client.delete_agent_async("a-delete"))
1

method delete_image

按标识符删除图像记录。

method delete_image_async(异步)

通过配置的存储删除一个独立映像。

method delete_memory

按标识符删除类似内存的记录(例如,内存、事实、首选项或准则)。

注释

在删除线程范围的记录之前,此方法会解析其存储的线程,并等待通过此代理内存组件接受的早期后台提取。它不会等待不相关的线程、等待开始后接受的工作,或者由其他代理内存组件或进程启动的工作。没有线程范围和未知标识符的记录不会导致提取等待。

示例

client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
memory_id = client.add_memory("Temporary memory", memory_id="mem-delete")
client.delete_memory(memory_id)
1

method delete_memory_async(异步)

异步删除类似内存的记录。

注释

此方法遵循 delete_memory() 记录的目标后台提取等待和并发行为。

示例

import asyncio
memory_id = asyncio.run(client.add_memory_async(
    "Temporary memory", memory_id="mem-delete"
))
asyncio.run(client.delete_memory_async(memory_id))
1

按标识符删除关系或完成端点元组。

未提供 relation_id 时,在存储的源到目标方向中提供每个源、目标、类型和关系标签参数。

示例

client.delete_record_link(relation_id="relation-id")
1

按 ID 异步删除关系或完成端点元组。

method delete_thread

删除与线程标识符关联的所有记录。

注释

Use this operation when you need retention-complete removal of a thread. The backing store deletes the thread together with associated thread-scoped messages, durable memories, and managed retrieval data. This differs from OracleThread.delete_message(), which removes only the raw message record and does not cascade to derived memories created from that message. Before deleting the thread, this method waits for earlier background extraction already accepted for that thread through this agent memory component. It does not wait for background work accepted after that wait begins or for work started by another agent memory component or process. Concurrent use of the same thread while deletion is in progress is unsupported.

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
thread = client.create_thread(thread_id="c-delete")
client.delete_thread(thread.thread_id)
1

method delete_thread_async(异步)

异步删除与线程标识符关联的所有记录。

注释

Use this operation when you need retention-complete removal of a thread. The backing store deletes the thread together with associated thread-scoped messages, durable memories, and managed retrieval data. This differs from OracleThread.delete_message(), which removes only the raw message record and does not cascade to derived memories created from that message. Before deleting the thread, this method waits for earlier background extraction already accepted for that thread through this agent memory component. It does not wait for background work accepted after that wait begins or for work started by another agent memory component or process. Concurrent use of the same thread while deletion is in progress is unsupported.

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
import asyncio
thread = asyncio.run(client.create_thread_async(thread_id="c-delete"))
asyncio.run(client.delete_thread_async(thread.thread_id))
1

method delete_user

按标识符删除用户概要记录。

注释

在删除配置文件之前,此方法最多等待 300 秒,以便通过此代理内存组件已知的所有线程可以接受更早的后台提取。无论是否启用级联清除,此等待均适用。级联清理作为一项操作在后备存储内计划和执行。该方法不会等待等待等待开始后接受的工作,也不会等待其他代理内存组件或进程启动的工作。不支持在删除过程中同时使用操作者范围。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
client.add_user("u-delete", "Prefers concise answers.")
'u-delete'
client.delete_user("u-delete")
1

method delete_user_async(异步)

异步删除按标识符列出的用户概要记录。

注释

此方法遵循 delete_user() 所记录的后台提取等待和并发行为。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
import asyncio
asyncio.run(client.add_user_async("u-delete", "Prefers concise answers."))
'u-delete'
asyncio.run(client.delete_user_async("u-delete"))
1

method get_thread

检索以前创建的线程。

注释

显式每次调用覆盖优先。省略运行时覆盖时,重新打开的线程将在可用时使用持久运行时配置,然后再回退到 SDK 默认值。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
created = client.create_thread(thread_id="c2", user_id="u1")
loaded = client.get_thread("c2")
loaded.user_id
'u1'

method get_thread_async(异步)

异步检索以前创建的线程。

注释

显式每次调用覆盖优先。省略运行时覆盖时,重新打开的线程将在可用时使用持久运行时配置,然后再回退到 SDK 默认值。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
import asyncio
created = asyncio.run(client.create_thread_async(
    thread_id="c2", user_id="u1"
))
loaded = asyncio.run(client.get_thread_async("c2"))
loaded.user_id
'u1'

在两个存储的记录之间创建定向关系。

目前,两个端点必须是类似内存的记录:"memory"、"fact"、"guideline" 或 "preference"。内置关系类型为 "supersedes" ("is_superseded_by")、"contradicts"、"refines" ("is_refined_by")、"supports" ("is_supported_by") 和 "duplicates"。"contradicts" 和 "duplicates" 反向使用相同的标签。

一个端点对只能存储一个方向。当从目标遍历到源时,opposite_relation_type 将命名关系。例如,如果 new "supersedes" old,则反向遍历为 old "is_superseded_by" new。

示例

client.link_records(
    "fact-1", "fact", "memory-1", "memory", "supports"
)
'relation-id'

在存储的记录之间异步创建类型化关系。

目前,两个端点必须是类似内存的记录:"memory"、"fact"、"guideline" 或 "preference"。内置关系类型为 "supersedes" ("is_superseded_by")、"contradicts"、"refines" ("is_refined_by")、"supports" ("is_supported_by") 和 "duplicates"。"contradicts" 和 "duplicates" 反向使用相同的标签。

method list_agents

列出持久的代理概要信息记录。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
client.add_agent("a1", "Support assistant", metadata={"source": "catalog"})
'a1'
[record.id for record in client.list_agents(metadata_filter={"source": "catalog"})]
['a1']

method list_agents_async(异步)

异步列出持久化的代理概要信息记录。

示例

import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
async def main():
    await client.add_agent_async(
        "a1",
        "Support assistant",
        metadata={"source": "catalog"},
    )
    records = await client.list_agents_async(metadata_filter={"source": "catalog"})
    return [record.id for record in records]
anyio.run(main)
['a1']

method list_images

列表保留了独立映像记录。

示例

images = client.list_images(user_id="u1", limit=10)
[image.id for image in images]
['img-1']

method list_images_async(异步)

列表以异步方式持久保存独立映像记录。

示例

images = await client.list_images_async(
    user_id="u1",
    limit=10,
)
[image.id for image in images]
['img-1']

method list_memories

列出持久性类似内存的记录。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
client.add_memory("User likes pizza.", user_id="u1", memory_id="mem-1")
'mem-1'
[record.id for record in client.list_memories(user_id="u1", limit=10)]
['mem-1']

method list_memories_async(异步)

列表以异步方式持久保存类似内存的记录。

示例

import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
async def main():
    await client.add_memory_async("User likes pizza.", user_id="u1", memory_id="mem-1")
    records = await client.list_memories_async(user_id="u1", limit=10)
    return [record.id for record in records]
anyio.run(main)
['mem-1']

method list_messages

列出保留的聊天消息记录。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
thread = client.create_thread(thread_id="c1", user_id="u1")
message_id = thread.add_messages([{"role": "user", "content": "Hello"}])[0]
[record.id for record in client.list_messages(thread_id="c1", limit=10)] == [message_id]
True

method list_messages_async(异步)

列表以异步方式保留了聊天消息记录。

示例

import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
async def main():
    thread = await client.create_thread_async(thread_id="c1", user_id="u1")
    message_ids = await thread.add_messages_async(
        [{"role": "user", "content": "Hello"}]
    )
    records = await client.list_messages_async(thread_id="c1", limit=10)
    return [record.id for record in records] == message_ids
anyio.run(main)
True

method list_threads

列出持久的对话话题。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
client.create_thread(thread_id="c1", user_id="u1").thread_id
'c1'
[record.thread_id for record in client.list_threads(user_id="u1", limit=10)]
['c1']

method list_threads_async(异步)

异步列出持久的对话线程。

示例

import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
async def main():
    await client.create_thread_async(thread_id="c1", user_id="u1")
    records = await client.list_threads_async(user_id="u1", limit=10)
    return [record.thread_id for record in records]
anyio.run(main)
['c1']

method list_users

列出持久的用户概要信息记录。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
client.add_user("u1", "Prefers concise answers.", metadata={"source": "crm"})
'u1'
[record.id for record in client.list_users(metadata_filter={"source": "crm"})]
['u1']

method list_users_async(异步)

列表以异步方式保留了用户概要信息记录。

示例

import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
async def main():
    await client.add_user_async(
        "u1",
        "Prefers concise answers.",
        metadata={"source": "crm"},
    )
    records = await client.list_users_async(metadata_filter={"source": "crm"})
    return [record.id for record in records]
anyio.run(main)
['u1']

同步搜索与查询相关的记录。

注释

显式 None 范围值仍遵循已解析的确切匹配规则:exact_*_match=False 保持该维不受约束,而 exact_*_match=True 仅匹配该维上未定义的记录。

method search_async(异步)

异步搜索与查询相关的记录。

注释

显式 None 范围值仍遵循已解析的确切匹配规则:exact_*_match=False 保持该维不受约束,而 exact_*_match=True 仅匹配该维上未定义的记录。

method update_image

按标识符更新存储的图像记录。

注释

省略的字段保持不变。此 API 不支持范围更新。元数据替换是整个对象替换,而不是递归 JSON 合并。

method update_image_async(异步)

通过配置的存储更新一个独立映像。

省略 image 以保留现有字节。如果提供了 image,则必须随其提供 mime_type。省略 description 以保留现有说明。传递 None 以使用配置的 LLM 生成新说明;非空说明会直接替换该说明。元数据、时间戳和到期设置在提供时会更新。

method update_memory

按标识符更新存储的类似内存的记录。

注释

省略的字段将从存储的记录中保留。存储的范围保持不变。元数据替换是整个对象替换,而不是递归 JSON 合并。

method update_memory_async(异步)

按标识符异步更新存储的类似内存的记录。

注释

省略的字段将从存储的记录中保留。存储的范围保持不变。元数据替换是整个对象替换,而不是递归 JSON 合并。

示例

import asyncio
memory_id = asyncio.run(client.add_memory_async("Original memory"))
(
    asyncio.run(client.update_memory_async(
        memory_id, content="Updated memory"
    ))
    == memory_id
)
True

更新一个存储关系的可变字段。

省略的值会保留。当 relation_type 更改为内置内存关系类型时,其固定反向标签将替换 opposite_relation_type。为 timestamp 或 metadata 传递 None 以清除该值。

示例

client.update_record_link("relation-id", relation_type="supports")
1

异步更新一个存储关系。

method update_thread

持久保存线程元数据和持久的运行时配置更新。

注释

运行时配置通过存储的对话线程解析,加上传递给此调用的显式覆盖,匹配 get_thread 语义,然后再保留结果。省略的元数据和运行时配置更新是从存储的数据(而不是从任何以前加载的 OracleThread 实例)解析的,并且仅写入显式提供的元数据更新或持久的运行时配置覆盖。元数据替换是整个对象替换,而不是递归 JSON 合并。线程所有权通过此 API 不可变,因此 user_id 和 agent_id 保持不变。可变运行时状态(例如提取计数器)保持不变。

示例

from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    llm=llm,
)
updated = client.update_thread(
    "c1",
    metadata={"flags": {"vip": True}},
    message_shortening_input_token_limit=12_000,
)
updated.message_shortening_input_token_limit
12000

method update_thread_async(异步)

异步持久保存更新的线程元数据和持久运行时配置。

method wait_for_memory_extraction

等待此客户机启动更早的后台内存提取。

此方法等待已通过此 OracleAgentMemory 实例在此代理内存组件拥有的所有线程中启动的后台提取。它不等待此等待开始后启动提取,不等待其他代理内存组件启动提取,也不等待在另一个进程中运行的提取。此等待的提取失败计数为已完成。

示例

client = OracleAgentMemory(
    connection=db_pool,
    embedder=embedder,
    memory_extraction_config=MemoryExtractionConfig(extract_memories=False),
)
client.wait_for_memory_extraction(timeout=10)

method wait_for_memory_extraction_async(异步)

异步等待更早的后台内存提取。

此方法遵循与 wait_for_memory_extraction() 相同的行为。

示例

import asyncio
asyncio.run(client.wait_for_memory_extraction_async(timeout=10))

图像输入限制

class oracleagentmemory.core.ImageInputLimitConfig

基准:object

配置原始映像和 LLM 映像请求限制。

省略的字段从下一个更广泛的配置范围继承。客户端字段继承 SDK 默认值,而每线程字段继承客户端配置。无法禁用验证,解析的值不能超过 SDK 的绝对最大值。

示例

from oracleagentmemory.core import ImageInputLimitConfig
config = ImageInputLimitConfig(
    max_raw_image_bytes=16 * 1024 * 1024,
    max_images_per_llm_request=200,
)

内存提取

class oracleagentmemory.core.MemoryExtractionImageContext

基础:str、Enum

选择图像如何参与自动内存提取。

DISABLED 省略提取提示中的图像和图像说明。IMAGE 发送原始图像部分。CAPTION 将图像描述作为文本发送,并要求每个选定的图像都具有非空白描述。

CAPTION = ‘ CAPTION ’

将说明作为文本包含,并且每个选定图像都需要一个说明。

已禁用 = ‘ DISABLED ’

请勿在提取提示中包括图像或图像说明。

图像 = ‘ IMAGE ’

在提取提示中包含原始图像部分。

MEMORY = ‘ MEMORY ’

当前不支持图像特定的内存提取。

class oracleagentmemory.core.MemoryExtractionConfig

基准:object

用于自动内存提取的分组设置。

将此对象传递到 OracleAgentMemory、create_thread、get_thread 或 update_thread 以配置自动提取。extraction_mode 和后台队列设置还控制自动图像描述生成。每个字段都独立解析。为操作提供的值优先,后跟保存的线程值、客户机值和 SDK 默认值。新线程和独立线程没有已保存的线程值。

示例

from oracleagentmemory.core import (
    MemoryExtractionImageContext,
    MemoryExtractionConfig,
    MemoryExtractionMode,
    MemoryLinkExtractionMode,
)
config = MemoryExtractionConfig(
    extract_memories=True,
    memory_extraction_image_context=MemoryExtractionImageContext.CAPTION,
    extraction_mode=MemoryExtractionMode.BACKGROUND,
    memory_link_extraction_mode=MemoryLinkExtractionMode.POST_EXTRACTION,
    memory_link_extraction_token_limit=8_000,
)

提取或图像描述无法立即排队时应执行的操作。

省略的值解析为 DROP。

在等待模式下后台工作等待队列容量的最大秒数。

省略的值解析为 300.0 秒。

自动刷新之前在最新的有效汇总之后的消息。

每次检查时值小于或等于 0 刷新。

OAM 是否维护线程读取和提取提示的上下文摘要。

提取和图像描述是内嵌运行还是后台运行。

省略的值解析为 BACKGROUND。

运行提取之间的消息;每次附加后,值低于 0 提取。

图像表示;省略解析为线程、客户机,然后解析为 DISABLED。

源消息元数据已复制到提取的内存中。

提示的输入令牌预算;低于 1 的值将禁用限制。

用于提取提示的近期消息窗口;-1 仅使用新消息。

附加到自动链路解析提示的可选调用方指令。

如何为提取的记忆解析自动链接。

省略的值解析为 POST_EXTRACTION。

POST_EXTRACTION 链接解析的输入标记预算合计。

低于 1 的值将禁用限制。

class oracleagentmemory.core.MemoryExtractionMode

基础:str、Enum

控制何时运行自动提取和映像说明。

INLINE 在写入方法返回之前完成派生的工作。原始写入成功并尝试将该工作排队后,BACKGROUND 将返回。背景工作是最好的努力:生成的描述和派生的记忆可能稍后出现,或者如果无法完成,可能永远不会写。

后台 = ‘ BACKGROUND ’

在原始写入后返回并在后台运行派生工作。

内嵌 = ‘ INLINE ’

在返回写入之前完成提取和图像说明。

class oracleagentmemory.core.BackgroundExtractionQueueFullBehavior

基础:str、Enum

控制在配置的后台工作无法及时排队时发生的情况。

尽管具有特定于提取的名称,但此设置也适用于在后台模式下自动生成图像描述。

删除 = ‘ DROP ’

记录警告,并在队列容量不可用时立即继续。

WAIT_THEN_DROP = ‘ WAIT_THEN_DROP ’

等待队列容量达到配置的超时,然后记录警告并继续。

WAIT_THEN_RAISE = ‘ WAIT_THEN_RAISE ’

等待队列容量达到配置的超时,然后引发 TimeoutError。