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

Implement Pydantic models from neon-data-models #9

Merged
merged 13 commits into from
Jan 6, 2025

Conversation

NeonDaniel
Copy link
Member

@NeonDaniel NeonDaniel commented Nov 19, 2024

Description

Implements shared models for data sent via MQ (NeonGeckoCom/neon-data-models#4)
Refactors persona handling to validate configured personas

Issues

Other Notes

This refactoring allows MQ consumers to more easily decode received messages into Pydantic models so that passed parameters are consistent and new parameters have clearly-defined defaults

@NeonDaniel NeonDaniel requested a review from NeonKirill December 3, 2024 00:03
unit_tests:
strategy:
matrix:
python-version: [ 3.9, "3.10", "3.11", "3.12" ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not intend to support Python 3.8 in our system anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been dropping it from tests as it recently reached EoL

neon_llm_core/chatbot.py Show resolved Hide resolved
neon_llm_core/chatbot.py Show resolved Hide resolved
neon_llm_core/chatbot.py Outdated Show resolved Hide resolved
request_data=request_data.model_dump(),
target_queue=queue,
response_queue=f"{queue}.response")
return LLMProposeResponse(**resp_data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would omit kwargs-like argument passing here, to make it more flexible to any potential updates to the callback body of send_mq_request

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should handle any mis-match of keys as part of the Pydantic validation. My intent with the Pydantic models here is that anything moving across MQ (and HTTP and Messagebus) is defined in neon-data-models; any added parameters will have defaults defined there, so the defaults are consistent across different handlers.

neon_llm_core/chatbot.py Show resolved Hide resolved
neon_llm_core/chatbot.py Show resolved Hide resolved
pydantic~=2.6
neon-data-models@git+https://github.com/neongeckocom/neon-data-models@FEAT_LLMRequestModels
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets first merge this PR and then publish it to PyPi to further get the actual version there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyPI upload will fail with git dependencies, so the neon-data-models PR must be merged before this one.

Outline unit tests with automation
Add test extra dependencies
Add tests of MQ request/response handling in `chatbot` module
Update `chatbot` module to use Pydantic models in place of `dict` objects for MQ message validation
…ser`

Refactor `chatbot` methods to safely handle missing context
Include `routing_key` in LLM responses to associate inputs/responses
Update tests to reference constant strings for more specific testing
@NeonDaniel NeonDaniel force-pushed the FEAT_ImplementDataModels branch from 40e7dcd to 16fa24a Compare December 18, 2024 17:21
@NeonDaniel NeonDaniel marked this pull request as ready for review December 18, 2024 17:22
@NeonDaniel NeonDaniel merged commit fd6ef5d into dev Jan 6, 2025
7 checks passed
@NeonDaniel NeonDaniel deleted the FEAT_ImplementDataModels branch January 6, 2025 20:46
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.

2 participants