-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use new OpenTelemetry GenAI chat span attribute conventions #2349
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
854385d
WIP
alexmojaki eb85359
WIP
alexmojaki 680bf63
WIP
alexmojaki 4ac237f
WIP
alexmojaki f1e3254
WIP
alexmojaki d322afc
WIP
alexmojaki 013a836
WIP
alexmojaki 0368faa
WIP
alexmojaki c615ce5
WIP
alexmojaki 4862d75
Merge branch 'main' of github.com:pydantic/pydantic-ai into alex/new-…
alexmojaki 7f0a5ec
IsStr
alexmojaki 1cad66e
Merge branch 'main' of github.com:pydantic/pydantic-ai into alex/new-…
alexmojaki f690187
test_instrumented_model_attributes_mode
alexmojaki 87e7b1e
Separate system part
alexmojaki a5154d7
finish_reason
alexmojaki a0c9ee9
instructions
alexmojaki 753a374
test_logfire
alexmojaki 38beb5f
test_instructions_with_structured_output
alexmojaki ddb819c
Merge branch 'main' into alex/new-otel-semconv
alexmojaki 7fcb3ad
binary_content -> content
alexmojaki 27897f4
system_instructions is a list of parts
alexmojaki 0f376f1
cleanup
alexmojaki 4716e44
Merge branch 'main' of github.com:pydantic/pydantic-ai into alex/new-…
alexmojaki 6f356f9
docstring
alexmojaki 3c1dd4b
docstring
alexmojaki cafba23
Merge branch 'main' of github.com:pydantic/pydantic-ai into alex/new-…
alexmojaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,62 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Literal | ||
|
||
from pydantic import JsonValue | ||
from typing_extensions import NotRequired, TypeAlias, TypedDict | ||
|
||
|
||
class TextPart(TypedDict): | ||
type: Literal['text'] | ||
content: NotRequired[str] | ||
|
||
|
||
class ToolCallPart(TypedDict): | ||
type: Literal['tool_call'] | ||
id: str | ||
name: str | ||
arguments: NotRequired[JsonValue] | ||
|
||
|
||
class ToolCallResponsePart(TypedDict): | ||
type: Literal['tool_call_response'] | ||
id: str | ||
name: str | ||
result: NotRequired[JsonValue] | ||
|
||
|
||
class MediaUrlPart(TypedDict): | ||
type: Literal['image-url', 'audio-url', 'video-url', 'document-url'] | ||
url: NotRequired[str] | ||
|
||
|
||
class BinaryDataPart(TypedDict): | ||
type: Literal['binary'] | ||
media_type: str | ||
content: NotRequired[str] | ||
|
||
|
||
class ThinkingPart(TypedDict): | ||
type: Literal['thinking'] | ||
content: NotRequired[str] | ||
|
||
|
||
MessagePart: TypeAlias = 'TextPart | ToolCallPart | ToolCallResponsePart | MediaUrlPart | BinaryDataPart | ThinkingPart' | ||
|
||
|
||
Role = Literal['system', 'user', 'assistant'] | ||
|
||
|
||
class ChatMessage(TypedDict): | ||
role: Role | ||
parts: list[MessagePart] | ||
|
||
|
||
InputMessages: TypeAlias = list[ChatMessage] | ||
|
||
|
||
class OutputMessage(ChatMessage): | ||
finish_reason: NotRequired[str] | ||
|
||
|
||
OutputMessages: TypeAlias = list[OutputMessage] |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.