wenjin272 commented on PR #1481:
URL: https://github.com/apache/flink-agents/pull/1481#issuecomment-7279397200

   Thanks for the fix. I'd prefer separating template variables into an 
explicit dictionary:
   
   ```python
   prompt.format_messages(
       role=MessageRole.USER,
       variables={"role": "a pirate"},
   )
   ```
   
   Here, `role` only determines the message type when converting a text 
template into a `ChatMessage`. For a message-list template, each message keeps 
its existing role.
   
   This keeps message configuration separate from template variables and aligns 
with Java's existing `formatMessages(MessageRole, Map)` API. There are similar 
patterns in other frameworks: 
[Haystack](https://docs.haystack.deepset.ai/reference/builders-api#chat_prompt_builder)
 provides `template_variables`, while 
[LangChain](https://reference.langchain.com/python/langchain-core/prompts/chat/ChatPromptTemplate)
 accepts a variable dictionary through `invoke`, with message roles defined in 
the template.
   
   We don't need to preserve backward compatibility at this stage, so I think 
this is clearer than positional-only arguments plus the `MessageRole` check.
   
   Please also update both bridge directions. In particular, 
`PythonMCPPrompt.formatMessages()` currently overwrites a template variable 
named `role` when preparing the Python call. A regression test covering that 
path would help.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to