Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Include content.1571#2180

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
alexmojaki merged 7 commits intopydantic:mainfromadtyavrdhn:include_content.1571
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Fixing user prompt not being scrubbed when it was a string
  • Loading branch information
@adtyavrdhn
adtyavrdhn committedJul 10, 2025
commit06702f9cbd32a23d12d76e1b7d41f26dffcc0fe6
4 changes: 2 additions & 2 deletionspydantic_ai_slim/pydantic_ai/messages.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -413,7 +413,7 @@ class UserPromptPart:
def otel_event(self, settings: InstrumentationSettings) -> Event:
content: str | list[dict[str, Any] | str]
if isinstance(self.content, str):
content = self.content
content = self.content if settings.include_content else [{'kind': 'text'}]
else:
content = []
for part in self.content:
Expand DownExpand Up@@ -743,7 +743,7 @@ def new_event_body():
'type': 'function', # TODO https://github.com/pydantic/pydantic-ai/issues/888
'function': {
'name': part.tool_name,
'arguments': part.args,
**({'arguments': part.args} if settings.include_content else {}),
},
}
)
Expand Down
17 changes: 12 additions & 5 deletionstests/models/test_instrumented.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -859,6 +859,7 @@ def test_messages_without_content(document_content: BinaryContent):
)
]
),
ModelRequest(parts=[UserPromptPart('simple text prompt')]),
ModelResponse(parts=[TextPart('text2'), ToolCallPart(tool_name='my_tool', args={'a': 13, 'b': 4})]),
ModelRequest(parts=[ToolReturnPart('tool', 'tool_return_content', 'tool_call_1')]),
ModelRequest(parts=[RetryPromptPart('retry_prompt', tool_name='tool', tool_call_id='tool_call_2')]),
Expand DownExpand Up@@ -890,36 +891,42 @@ def test_messages_without_content(document_content: BinaryContent):
'gen_ai.message.index': 2,
'event.name': 'gen_ai.user.message',
},
{
'content': {'kind': 'text'},
'role': 'user',
'gen_ai.message.index': 3,
'event.name': 'gen_ai.user.message',
},
{
'role': 'assistant',
'tool_calls': [
{
'id': IsStr(),
'type': 'function',
'function': {'name': 'my_tool', 'arguments': {'a': 13, 'b': 4}},
'function': {'name': 'my_tool'},
}
],
'gen_ai.message.index':3,
'gen_ai.message.index':4,
'event.name': 'gen_ai.assistant.message',
},
{
'role': 'tool',
'id': 'tool_call_1',
'name': 'tool',
'gen_ai.message.index':4,
'gen_ai.message.index':5,
'event.name': 'gen_ai.tool.message',
},
{
'role': 'tool',
'id': 'tool_call_2',
'name': 'tool',
'gen_ai.message.index':5,
'gen_ai.message.index':6,
'event.name': 'gen_ai.tool.message',
},
{
'content': [{'kind': 'text'}, {'kind': 'binary', 'media_type': 'application/pdf'}],
'role': 'user',
'gen_ai.message.index':6,
'gen_ai.message.index':7,
'event.name': 'gen_ai.user.message',
},
]
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp