mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-11 03:37:56 +00:00
59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
import asyncio
|
|
import os
|
|
|
|
from agent_framework.openai import OpenAIChatClient
|
|
|
|
from supermemory_agent_framework import (
|
|
AgentSupermemory,
|
|
SupermemoryChatMiddleware,
|
|
SupermemoryMiddlewareOptions,
|
|
SupermemoryTools,
|
|
)
|
|
|
|
|
|
async def main():
|
|
conn = AgentSupermemory(
|
|
api_key=os.environ["SUPERMEMORY_API_KEY"],
|
|
container_tag="test-user-123",
|
|
)
|
|
|
|
middleware = SupermemoryChatMiddleware(
|
|
conn,
|
|
options=SupermemoryMiddlewareOptions(
|
|
mode="full",
|
|
verbose=True,
|
|
add_memory="always",
|
|
),
|
|
)
|
|
|
|
tools = SupermemoryTools(conn)
|
|
|
|
agent = OpenAIChatClient(
|
|
api_key=os.environ["OPENAI_API_KEY"], model="gpt-5"
|
|
).as_agent(
|
|
name="MemoryAgent",
|
|
instructions="You are a helpful assistant with memory.",
|
|
middleware=[middleware],
|
|
tools=tools.get_tools(),
|
|
)
|
|
|
|
print("Chat with the agent (type 'quit' to exit)")
|
|
print("-" * 40)
|
|
|
|
while True:
|
|
try:
|
|
user_input = input("\nYou: ")
|
|
except (EOFError, KeyboardInterrupt):
|
|
print("\nBye!")
|
|
break
|
|
|
|
if user_input.strip().lower() in ("quit", "exit"):
|
|
print("Bye!")
|
|
break
|
|
|
|
response = await agent.run(user_input)
|
|
await middleware.wait_for_background_tasks()
|
|
print(f"\nAgent: {response.text}")
|
|
|
|
|
|
asyncio.run(main())
|