Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces comprehensive support for tool calls and enhanced template expression handling in the POML language, adding rich API capabilities for Python SDK integration and improved flexibility in schema and runtime parameter management.
Key Changes
- Enhanced template expression support in
<tool-definition>and<output-schema>element attributes with dynamic name, description, and schema generation - Automatic runtime parameter key conversion from kebab-case to camelCase with intelligent type conversion (boolean, number, JSON parsing)
- Python API enrichment with tool call/response models, OpenAI/LangChain format conversion, and new
PomlFramecontainer for complete conversation metadata
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
python/tests/test_poml_formats.py |
Comprehensive test coverage for new tool call conversions, format handling, and runtime parameter processing |
python/poml/api.py |
Core API enhancements with tool call models, format conversion functions, and expanded output format support |
packages/poml/util/schema.ts |
Added getTools() utility method for accessing all defined tools |
packages/poml/tests/file.test.tsx |
Extensive test coverage for runtime parameter conversion and template expression handling |
packages/poml/file.tsx |
Implementation of template expression support in attributes and runtime parameter conversion logic |
docs/language/standalone.md |
Updated documentation covering template expressions in attributes and runtime parameter conversion rules |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| return langchain_messages | ||
|
|
||
|
|
||
| def _camel_case_to_snake_case(name: str) -> str: |
There was a problem hiding this comment.
Missing import for the re module. The function uses re.sub() but re is not imported at the top of the file.
| else: | ||
| # TODO: Make it a RichContent object | ||
| pydantic_result = [PomlMessage(speaker="human", content=result)] | ||
| pydantic_messages = [PomlMessage(speaker="human", content=messages_data)] # type: ignore |
There was a problem hiding this comment.
The type ignore comment suggests a type mismatch that should be properly handled. Consider either fixing the type conversion or adding a more specific comment explaining why the type ignore is necessary.
| pydantic_messages = [PomlMessage(speaker="human", content=messages_data)] # type: ignore | |
| # Ensure content is a string for legacy format | |
| if isinstance(messages_data, list): | |
| content_str = "\n".join(str(item) for item in messages_data) | |
| else: | |
| content_str = str(messages_data) | |
| pydantic_messages = [PomlMessage(speaker="human", content=content_str)] |
| message["tool_calls"] = tool_calls | ||
| elif not text_image_contents: | ||
| # If no content and no tool calls, skip this message | ||
| pass |
There was a problem hiding this comment.
The condition elif not text_image_contents: followed by pass and then an if condition checking the same thing creates unclear control flow. Consider simplifying this logic for better readability.
| pass |
This pull request introduces enhanced support for template expressions and automatic type conversion in schema and runtime parameter handling for the POML language, along with improved Python API support for tool calls and richer content types. The changes improve flexibility, correctness, and interoperability across both the TypeScript and Python implementations, and are accompanied by thorough documentation and test coverage.
Template Expression and Schema Handling Improvements:
<tool-definition>and<output-schema>elements, allowing dynamic generation of tool names, descriptions, and schemas. This is reflected in both the documentation (standalone.md) and the implementation inPomlFile, including the newhandleTextAsStringhelper. [1] [2] [3]langattribute of schemas now supports template expressions, enabling dynamic schema language selection.Runtime Parameter Handling and Type Conversion:
Python API: Tool Call and Rich Content Support:
ContentMultiMediaToolRequestandContentMultiMediaToolResponsemodels to represent tool calls and responses in the Python API, and updated theSpeakertype to include"tool".PomlFramemodel to encapsulate messages, schemas, tools, and runtime parameters in a single object."message_dict"as a valid output format for the API.Utility Improvements:
getTools()method toToolsSchemafor easier access to all defined tools.These changes collectively make the POML language and its tooling more expressive, robust, and compatible with modern LLM integration patterns.