-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tool call id to openai instrumentor (#1090)
- Loading branch information
1 parent
f473157
commit 9bbadd2
Showing
6 changed files
with
186 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...entation-openai/tests/openinference/instrumentation/openai/cassettes/test_tool_calls.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
interactions: | ||
- request: | ||
body: '{"messages": [{"role": "assistant", "tool_calls": [{"id": "call_62136355", | ||
"type": "function", "function": {"name": "get_weather", "arguments": "{\"city\": | ||
\"New York\"}"}}, {"id": "call_62136356", "type": "function", "function": {"name": | ||
"get_population", "arguments": "{\"city\": \"New York\"}"}}]}, {"role": "tool", | ||
"tool_call_id": "call_62136355", "content": "{\"city\": \"New York\", \"weather\": | ||
\"fine\"}"}, {"role": "tool", "tool_call_id": "call_62136356", "content": "{\"city\": | ||
\"New York\", \"weather\": \"large\"}"}, {"role": "assistant", "content": "In | ||
New York the weather is fine and the population is large."}, {"role": "user", | ||
"content": "What''s the weather and population in San Francisco?"}], "model": | ||
"gpt-4o-mini", "tools": [{"type": "function", "function": {"name": "get_weather", | ||
"description": "finds the weather for a given city", "parameters": {"type": | ||
"object", "properties": {"city": {"type": "string", "description": "The city | ||
to find the weather for, e.g. ''London''"}}, "required": ["city"]}}}, {"type": | ||
"function", "function": {"name": "get_population", "description": "finds the | ||
population for a given city", "parameters": {"type": "object", "properties": | ||
{"city": {"type": "string", "description": "The city to find the population | ||
for, e.g. ''London''"}}, "required": ["city"]}}}]}' | ||
headers: {} | ||
method: POST | ||
uri: https://api.openai.com/v1/chat/completions | ||
response: | ||
body: | ||
string: "{\n \"id\": \"chatcmpl-AOA1TtLtlb9GcK4LnNYnNcK2ETJpW\",\n \"object\": | ||
\"chat.completion\",\n \"created\": 1730321763,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n | ||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": | ||
\"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n | ||
\ \"id\": \"call_Yheo99FhD2nPbVfhJ2qwM1XK\",\n \"type\": | ||
\"function\",\n \"function\": {\n \"name\": \"get_weather\",\n | ||
\ \"arguments\": \"{\\\"city\\\": \\\"San Francisco\\\"}\"\n }\n | ||
\ },\n {\n \"id\": \"call_qvrUTewqYFp3XTGIYS97SCwX\",\n | ||
\ \"type\": \"function\",\n \"function\": {\n \"name\": | ||
\"get_population\",\n \"arguments\": \"{\\\"city\\\": \\\"San | ||
Francisco\\\"}\"\n }\n }\n ],\n \"refusal\": | ||
null\n },\n \"logprobs\": null,\n \"finish_reason\": \"tool_calls\"\n | ||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 207,\n \"completion_tokens\": | ||
46,\n \"total_tokens\": 253,\n \"prompt_tokens_details\": {\n \"cached_tokens\": | ||
0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\": | ||
0\n }\n },\n \"system_fingerprint\": \"fp_0ba0d124f1\"\n}\n" | ||
headers: {} | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters