Skip to content
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

Fix metadata processing in chat adapter #2040

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gilad12-coder
Copy link

This PR enhances the ChatAdapter implementation with two improvements:

1. Added Field Metadata Processing:

  • Introduced new metadata handling capabilities for numeric field constraints with PERMITTED_CONSTRAINTS
  • Added new utility functions to process field metadata:
    • _format_constraint(): Formats numeric constraints (gt, lt, ge, le, multiple_of, allow_inf_nan) based on the constraints that can be passed in Pydantic's fields class (https://docs.pydantic.dev/latest/concepts/fields/#field-aliases)
    • format_metadata_summary(): Creates human-readable metadata summaries for each field
    • format_metadata_constraints(): Formats field constraints for prompt generation
  • Enhanced field descriptions in prompts to include metadata information (using the summary and the paragraphical format).
  • Added support for numeric field constraints in field metadata processing

example:
relevance_and_significance (float): The score of the argument based on its relevance and significance.
When evaluating relevance and significance, consider the following questions:

  • How significant is the central claim the argument is trying to establish?
  • How relevant is the claim to the topic?
    The score should be a floating-point number between the specified lower and upper bounds. [Metadata: Ge(ge=0.0); Le(le=1.0)] (this is formatted using format_metadata_summary())
    [[ ## relevance_and_significance ## ]]
    {relevance_and_significance} # note: the value you produce must be a single float value that is greater than or equal to 0.0 and less than or equal to 1.0. (this is formatted using format_metadata_constraints())

2. Improved Code Documentation and Type Hints:

  • Added comprehensive docstring to all functions and classes
  • Added proper type hints throughout the file
  • Improved function signatures with explicit type annotations
  • Enhanced error messages for better debugging
  • Added descriptive comments for complex logic sections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant