You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importasynciofromagent_protocol.modelsimportStepRequestBodyfromagent_protocol_clientimport (
Configuration,
ApiClient,
StepRequestBody,
TaskRequestBody,
AgentApi,
)
# Defining the host is optional and defaults to http://localhost# See configuration.py for a list of all supported configuration parameters.configuration=Configuration(host="http://localhost:8000")
asyncdefmain():
# Enter a context with an instance of the API clientasyncwithApiClient(configuration) asapi_client:
# Create an instance of the API classapi_instance=AgentApi(api_client)
task_request_body=TaskRequestBody(input="Write 'Hello world!' to hi.txt.")
response=awaitapi_instance.create_agent_task(
task_request_body=task_request_body
)
print("The response of AgentApi->create_agent_task:\n")
print(response)
print("\n\n")
task_id=response.task_idi=1while (
step:=awaitapi_instance.execute_agent_task_step(
task_id=task_id, step_request_body=StepRequestBody(input=i)
)
) andstep.is_lastisFalse:
print("The response of AgentApi->execute_agent_task_step:\n")
print(step)
print("\n\n")
i+=1print("Agent finished its work!")
artifacts=awaitapi_instance.list_agent_task_artifacts(task_id=task_id)
forartifactinartifacts:
ifartifact.file_name=="hi.txt":
content=awaitapi_instance.download_agent_task_artifact(
task_id=task_id, artifact_id=artifact.artifact_id
)
print(f'The content of the hi.txt is {content})')
breakelse:
print("The agent did not create the hi.txt file.")
asyncio.run(main())
* API endpoints are concise and clear. * Have official test suites and benchmarks.
* Low-level: it has no concept of tools, memory, etc. Some extra work needed to implement a high-level protocol above it. * limited current adoptions
OpenAI Assistant API
* Rich abstraction of agent execution flow and related tools. * GPT-4 models are really good at general instructions for agent. * Relatively richer features in client sdk. * built-in tools: code interpreter, retriever, and function calling.
* Closed sourced. we don’t know how the the underlying agent architecture is built. And little information about API server is revealed on documentation websites. * a little bit complicated API design, esp. for Run, RunStep stuff. Pretty sure that these APIs will be improved in future.
Bottom lines:
OpenAI’s solution is easy to adapt and more powerful in terms of foundation models and built-in tools.
Influence of OpenAI results more downstream projects based on Assistant API, which may be the next software ecosystem (GUI, benchmarks, etc. ) like its ChatCompletionAPI.
Agent protocol is more friendly for agent developers, not for agent users, at least for now. It’s definitely a potential opponent to OpenAI’s solution.
Regarding instinct.cpp:
My bet is on Assistant API.
More analysis of implementation cost is needed before further development.
No thought text is generated. function call options are genearted directly. Could they ommit thought text and use action text directly? Or they have different prompt techniques for tool uses.
in event stream, thread.run.step.completed is duplicated.
run is queued again after tool outputs are submitted.
These tool agent relies on API with function call.
When last message does not contain function call request, then the conversion is regarded as finallized. This is simple but probematic for many reasons.
Other stop strategy:
if max step number are reached, stop abrutly with no final answer.
if a user provided special function tool is called, agent will accpet call result as final answer and then stop.
Activity
RobinQu commentedon Apr 11, 2024
Agent Protocol
The protocol
https://agentprotocol.ai/protocol
Restful Endpoints:
Demo Code
server code:
client code:
Adoptions
https://github.com/ai-engineer-foundation/agent-protocol?tab=readme-ov-file#open-source-agents-and-projects-that-have-adopted-agent-protocol
RobinQu commentedon Apr 11, 2024
OpenAI Assistant API
The protocol
https://platform.openai.com/docs/api-reference/assistants
Endpoints
Resource objects
Lifecycle of run objects
https://platform.openai.com/docs/assistants/how-it-works/run-lifecycle
run_step.step_detailsTools
Assistant API defines three primary tools.
They are general purpose tools. I suppose more specific tools will come, e.g. data interpreter.
Adoptions
Open sourced implementations
https://github.com/transitive-bullshit/OpenOpenAI
https://github.com/stellar-amenities/hal-9100/tree/main
Related readings
RobinQu commentedon Apr 11, 2024
Conclusion
* Have official test suites and benchmarks.
* limited current adoptions
* GPT-4 models are really good at general instructions for agent.
* Relatively richer features in client sdk.
* built-in tools: code interpreter, retriever, and function calling.
* a little bit complicated API design, esp. for
Run,RunStepstuff. Pretty sure that these APIs will be improved in future.Bottom lines:
ChatCompletionAPI.Regarding
instinct.cpp:RobinQu commentedon Apr 19, 2024
OpenAI's Assistant V2 is released: https://platform.openai.com/docs/assistants/migration
retrieverbecomesfilesearch, which support more sophiscated control over vector stores.RobinQu commentedon Apr 28, 2024
tool call test with assitant api
test_function_call_sync_1714287406.json
Observations:
thread.run.step.completedis duplicated.API with function calls:
Tool agent using OpenAI style tool call API:
Conclusion
RobinQu commentedon May 20, 2024
it should be closed long ago with v01.2.0 release.