-
Notifications
You must be signed in to change notification settings - Fork 0
DX-94 Unified API Spec for Agents #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tyler5673
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left quite a lot of comments, more conversations may come out of them so leaving status as request changes for now
| "stream": False, | ||
| }) | ||
|
|
||
| ### Example with Advanced agent and tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There doesn't seem to be any examples of advanced agent or tool functionality now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some changes and this has gone away. Also was autogenerated
| ]) | ||
| res = you.agents_runs(request={ | ||
| "agent": "express", | ||
| "input": "What is the capital of France?", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like every example is express agent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generated by Speakeasy. working with them to figure out how we can get their tools to pick a different example from the openapi_unified_agents.yaml of which there are many. See examples: on line 35
| # Helper Functions for Type-Safe Event Handling | ||
| # ============================================================================ | ||
|
|
||
| def parse_sse_event(event: Any) -> SSEEvent: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may want to keep some of the helper functions! most likely not all, but parse_sse_event may be useful to some for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at api-example-calls.py in the examples folder, def express_streaming_request() is setup to look for SSE events all in a typesafe way, (same with the other calls) so i don't think we need this function or the other helpers
Specifically using isinstance() casts the chunk data
for chunk in stream:
event_data = chunk.data
# Use isinstance() to narrow the type and handle each event
if isinstance(event_data, ResponseCreated):
print(f"✨ Response created (seq: {event_data.seq_id})")
elif isinstance(event_data, ResponseStarting):
print(f"🚀 Response starting (seq: {event_data.seq_id})")
elif isinstance(event_data, ResponseOutputItemAdded):
print(f"➕ Output item added: {event_data.seq_id}")
elif isinstance(event_data, ResponseOutputContentFull):
print("\n🔍 Web Search Results:")
if event_data.response.full:
for idx, result in enumerate(event_data.response.full, 1):
print(f" {idx}. {result.title} - {result.url}")
...I also added some example code in the readme to show how to process streaming tokens under Server-sent event streaming. Let me know. I think we're good here!
Added User-Agent hook to override user agent to what we want
…e-calls.py for more info
.speakeasy/gen.yaml
Outdated
| requestBodyFieldName: body | ||
| persistentEdits: {} | ||
| tests: | ||
| generateTests: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want this false since we have a custom test suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, thanks. Also note that when I set it to false, and rerun speakeasy run to regenerate the data, the script removes the entire tests: portion of the yaml on its own.
examples/api-example-calls.py
Outdated
|
|
||
| results = you.agents.runs.create(request=request) | ||
|
|
||
| res = you.agents.runs.create(request={ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call is unneeded here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appreciate it!
DX-94: Unified API Spec for Agents
High level notes:
openapi_schemas.speakeasy/workflow.yamlis where we tell speakeasy to compile the openAPI yaml files together.speakeasy/gen.yamlpython.versionis where we can set the version number (currently set to 1.5.0)examples/api-example-calls.pylists the type safe ways of running our endpointsReadme.mdand related files are all auto generatedx-speakeasy-enumsin the openAPI yaml files after settingpython.enumFormattoenumin the.speakeasy/gen.yamlsrc/youdotcom/_hooks/registration.pycontains the code to set the user agent header to our custom valueAll other files are Speakeasy generated