repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
Mirrored from https://github.com/yingqi-z20/Agent-libOS
stars
latest
clone command
git clone gitlawb://did:key:z6MkqRzA...RfoM/yingqi-z20-Agen...git clone gitlawb://did:key:z6MkqRzA.../yingqi-z20-Agen...d98dd2c9IPC1d ago| #1 | import asyncio |
| #2 | from agent_libos import Runtime |
| #3 | from agent_libos.config import DEFAULT_CONFIG |
| #4 | from agent_libos.models import AgentImage, ProcessStatus, ResourceBudget |
| #5 | |
| #6 | _RUNTIME_DEFAULTS = DEFAULT_CONFIG.runtime |
| #7 | _SCRIPT_DEFAULTS = DEFAULT_CONFIG.scripts |
| #8 | |
| #9 | CHAT_IMAGE_ID = "chat-image:v0" |
| #10 | CHAT_IMAGE_NAME = "ChatImage" |
| #11 | def chat_image() -> AgentImage: |
| #12 | return AgentImage( |
| #13 | image_id=CHAT_IMAGE_ID, |
| #14 | name=CHAT_IMAGE_NAME, |
| #15 | version="v0", |
| #16 | system_prompt="Traditional human/LLM chat image with only human I/O and process exit tools.", |
| #17 | default_tools=["ask_human", "human_output", "process_exit"], |
| #18 | context_policy="recency_first", |
| #19 | required_capabilities=[{"resource": _RUNTIME_DEFAULTS.default_human_resource, "rights": ["write"]}], |
| #20 | ) |
| #21 | |
| #22 | runtime = Runtime.open(_RUNTIME_DEFAULTS.local_store_target) |
| #23 | runtime.register_image(chat_image()) |
| #24 | pid = runtime.process.spawn(image=CHAT_IMAGE_ID, |
| #25 | goal=("You are an AI assistant interacting via a terminal interface. To ensure a smooth and efficient conversation, please adhere to the following rules:" |
| #26 | "1. Do not repeat the same text, greetings, or explanations in one turn. Keep responses concise and strictly relevant to the new context.", |
| #27 | "2. Every turn MUST conclude with a tool call to either `ask_human` (to receive the next user message) or `process_exit` (when the user wants to exit or the task is done). Never end a turn without calling one of these tools."), |
| #28 | resource_budget=ResourceBudget(max_materialized_tokens=_SCRIPT_DEFAULTS.chat_context_tokens), ) |
| #29 | asyncio.run(runtime.arun_until_idle()) |
| #30 | process = runtime.process.get(pid) |
| #31 | if process.status != ProcessStatus.EXITED: |
| #32 | raise RuntimeError(f"chat process did not exit; status={process.status.value}") |
| #33 |