ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# coding: utf-8
|
||||
# Copyright (c) 2025 inclusionAI.
|
||||
|
||||
import os
|
||||
from aworld.config.conf import AgentConfig
|
||||
from aworld.agents.llm_agent import Agent
|
||||
from aworld.runner import Runners
|
||||
import json
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
agent_config = AgentConfig(
|
||||
llm_provider=os.getenv("LLM_PROVIDER", "openai"),
|
||||
llm_model_name=os.getenv("LLM_MODEL_NAME"),
|
||||
llm_base_url=os.getenv("LLM_BASE_URL"),
|
||||
llm_api_key=os.getenv("LLM_API_KEY"),
|
||||
llm_temperature=os.getenv("LLM_TEMPERATURE", 0.0)
|
||||
)
|
||||
|
||||
# Register the MCP tool here, or create a separate configuration file.
|
||||
mcp_config = {
|
||||
"mcpServers": {
|
||||
"GorillaFileSystem": {
|
||||
"type": "stdio",
|
||||
"command": "python",
|
||||
"args": ["mcp_tools/gorilla_file_system.py"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file_sys_prompt = "You are a helpful agent to use the standard file system to perform file operations."
|
||||
file_sys = Agent(
|
||||
conf=agent_config,
|
||||
name="file_sys_agent",
|
||||
system_prompt=file_sys_prompt,
|
||||
mcp_servers=mcp_config.get("mcpServers", []).keys(),
|
||||
mcp_config=mcp_config,
|
||||
)
|
||||
|
||||
# run
|
||||
result = Runners.sync_run(
|
||||
input=(
|
||||
"use mcp tools in the GorillaFileSystem server to perform file operations: "
|
||||
"write the content 'AWorld' into the hello_world.py file with a new line "
|
||||
"and keep the original content of the file. Make sure the new and old "
|
||||
"content are all in the file; and display the content of the file"
|
||||
),
|
||||
agent=file_sys,
|
||||
)
|
||||
|
||||
print("=" * 100)
|
||||
print(f"result.answer: {result.answer}")
|
||||
print("=" * 100)
|
||||
print(f"result.trajectory: {json.dumps(result.trajectory[0], indent=4)}")
|
||||
Reference in New Issue
Block a user