Conversation
|
👋 Hi — I'm PR Bot, your SAP code review assistant. I'll automatically review your pull requests for code quality, security, and SAP compliance. Get an overview of what I do → What I do
Key commands
Configure me for your teamCreate {
"$schema": "https://devops-insights-pr-bot.cfapps.eu10-004.hana.ondemand.com/schema/pull_request_bot.json",
"features": {
"control_panel": false,
"summarize": {
"auto_generate_summary": true,
"auto_insert_summary": true,
"auto_run_on_draft_pr": true,
"use_custom_summarize_prompt": false,
"use_custom_summarize_output_template": false,
"excluded_paths": [],
"auto_exclude_authors": []
},
"review": {
"auto_generate_review": true,
"auto_run_on_draft_pr": false,
"use_custom_review_focus": false,
"excluded_paths": [],
"auto_exclude_authors": []
},
"sonar_fix": {
"enable": true,
"excluded_rules": []
},
"pipeline_fix": {
"enable": true
}
},
"excluded_paths": []
}*This introduction message will be shown to you only once, you will not see it in future PRs. |
|
[pp] Would it be more convenient for review to set the base branch to #92 or what do you think? |
yes that's correct, I rather meant the GitHub PR base branch so that it reads out as "merge into |
yeah, that's better I think. I'll do it. |
yamaceay
left a comment
There was a problem hiding this comment.
nice work! just adding some comments :)
|
|
||
|
|
||
| class AssistantMessage(BaseModel): | ||
| class AssistantMessage(ResponseBaseModel): |
There was a problem hiding this comment.
| class AssistantMessage(ResponseBaseModel): | |
| class AssistantMessage(BaseModel): |
There was a problem hiding this comment.
Here are some investigation from my side. They do have the same fields, but they serve different roles in the flow. ResponseChatMessage is what you get back from the model (LLMChoice.message), while AssistantMessage some other messages, like what you put into the conversation history to send back in the next turn. (Also for the type declarations mentioned)
The existing integration test makes this explicit — it reads from a ResponseChatMessage and manually constructs an AssistantMessage to append to history:
# response.final_result.choices[0].message is ResponseChatMessage — the model's output
assistant_message = AssistantMessage(
content=response.final_result.choices[0].message.content,
refusal=response.final_result.choices[0].message.refusal,
tool_calls=response.final_result.choices[0].message.tool_calls,
)
history.append(assistant_message) # AssistantMessage — going back in as input
Context
Closes SAP/ai-sdk-python-backlog#22.
What this PR does and why it is needed
The orchestration service v2 spec
defines a
reasoning_contentfield onAssistantChatMessage,ResponseChatMessage, andChatDelta.The Python SDK did not declare this field, and the response-related classes (
ResponseChatMessage,StreamDelta, etc.) inherited fromABCBaseModel(extra="forbid"), causing a PydanticValidationErrorwhenever the orchestration service returnedreasoning_content— which happens bydefault for models such as
gemini-3.5-flash(see #92).This PR explicitly adds
reasoning_content: Optional[List[ReasoningBlock]]toAssistantMessageandStreamDelta, and fixes the root cause by making all response-related classes inherit fromResponseBaseModel(extra="allow") so that any currently-unknown field returned by the server isaccepted rather than rejected. This covers
FunctionCall,MessageToolCall,ReasoningBlock,ResponseChatMessageinmessage.py; all classes inresponse.py; andEmbeddingsUsage,EmbeddingResult,EmbeddingsResponse,EmbeddingsPostResponseinembeddings.py.ResponseBaseModelis moved fromresponse.pyintobase.pyto avoid a circular import.Scope
All changes are confined to
packages/gen/gen_ai_hub/orchestration_v2/. Other packages(
document_grounding,proxy,prompt_registry,batch_service) may have the same patternand should be discussed later. Some models are shared through requests and responses. They are now updated to use
ResponseBaseModel.Definition of Done