Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Refactor ParseResult into separate Pydantic models for success and error #588

Closed

Conversation

mentatai[bot]
Copy link
Contributor

@mentatai mentatai bot commented Dec 6, 2024

  • Introduced two Pydantic models: ParsedEdit for successful parses and ParseError for error cases.
  • Updated ParsedLLMResponse to be a union of ParsedEdit and ParseError.
  • Modified agent_handler.py, conversation.py, and json_parser.py to handle the new models.
  • Ensured that only successful parses are added to conversation messages and error handling is improved.

Closes #587

Add error handling for invalid JSON and format in model responses

- Introduce `ParseError` class to represent parsing errors, which can be returned instead of `ParsedLLMResponse` when an error occurs.
- Handle `JSONDecodeError` and `ValidationError` exceptions in the `JsonParser` class, returning a `ParseError` instance with the appropriate error message and partial response.
- Modify the `Conversation` class to handle `ParseError` instances, displaying the error message to the user and not adding the error response to the conversation messages.
- Update the `AgentHandler` class to handle `ParseError` instances returned from the parser, displaying the error message to the user and returning an empty list of commands.

This change improves the robustness of the system by providing better error handling and feedback to the user when issues occur during the parsing of model responses.
@mentatai mentatai bot requested a review from biobootloader December 6, 2024 16:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

better ParseResult
1 participant