diff --git a/docs/gen-ai/non-normative/examples-llm-calls.md b/docs/gen-ai/non-normative/examples-llm-calls.md index d95642ab2e..323903d77d 100644 --- a/docs/gen-ai/non-normative/examples-llm-calls.md +++ b/docs/gen-ai/non-normative/examples-llm-calls.md @@ -673,9 +673,19 @@ Span: > The format of `gen_ai.output.messages` is not yet specified for built-in tool calls (check [#2585](https://github.com/open-telemetry/semantic-conventions/issues/2585) > for the details). -This is an example of telemetry generated for a chat completion call with `code_interpreter` tool that results in +This is an example of telemetry generated for a responses call with `code_interpreter` tool that results in a model provider executing a tool and returning response along with tool call details. +```py +response = client.responses.create( + model="gpt-4", + input="Write Python code that generates a random number, executes it, and returns the result.", + tools=[{"type": "code_interpreter"}], + include=['code_interpreter_call.outputs'], + tool_choice="required", +) +``` + ```mermaid %%{init: { @@ -688,11 +698,11 @@ sequenceDiagram participant I as Instrumented Client participant M as Model - A ->>+ I: + A ->>+ I: #U+200D I ->> M: input = [system: You are a helpful bot, user: Write Python code that generates a random number, executes it, and returns the result.] Note left of I: GenAI Client span I --> M: tool:code='import random ....'
assistant: The generated random number is 95. - I -->>- A: + I -->>- A: #U+200D ``` **GenAI client span:** @@ -715,11 +725,64 @@ sequenceDiagram `gen_ai.input.messages` value -TODO +```json +[ + { + "role": "system", + "parts": [ + { + "type": "text", + "content": "You are a helpful bot" + } + ] + }, + { + "role": "user", + "parts": [ + { + "type": "text", + "content": "Write Python code that generates a random number, executes it, and returns the result." + } + ] + } +] +``` `gen_ai.output.messages` value -TODO +```json +[ + { + "role": "assistant", + "parts": [ + { + "type": "tool_call", + "id": "call_VSPygqKTWdrhaFErNvMV18Yl", + "name": "code_interpreter", + "arguments": { + "code": "import random\n\n# Generate a random number\nrandom_number = random.randint(1, 100)\n\n# Execute some operation with the random number (e.g., squaring it)\nresult = random_number ** 2\n\nrandom_number, result", + "container_id": "cntr_690bdbfed8688190884efd4c7ae6435b0db1f006442e8941", + } + }, + { + "type": "tool_call_response", + "id": " call_VSPygqKTWdrhaFErNvMV18Yl", + "response": [ + { + "logs": "(10, 20)", + "type": "logs" + } + ], + }, + { + "type": "text", + "content": "The generated random number is **89**, and the result of squaring it is **7921**" + } + ], + "finish_reason": "stop" + } +] +``` ## Chat completion with multiple choices