-
Notifications
You must be signed in to change notification settings - Fork 18
Add HTTPMessangerInterface #410
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
base: dev
Are you sure you want to change the base?
Conversation
chatsky/messengers/http_interface.py
Outdated
| class Output(BaseModel): | ||
| user_id: str | ||
| response: Message | ||
|
|
||
| @app.post("/chat", response_model=Output) | ||
| async def respond( | ||
| user_id: str, | ||
| user_message: Message, | ||
| ): | ||
| message = Message(text=user_message) | ||
| context = await pipeline_runner(message, user_id) | ||
| return {"user_id": user_id, "response": context.last_response} | ||
|
|
||
| @app.get("/health", response_model=HealthStatus) | ||
| async def health_check(): | ||
| return { | ||
| "status": "ok", | ||
| "uptime": str(time.time() - self.start_time), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to define these (Output, respond, health_check) outside of the connect method and add to the app via
app.post("/chat", response_model=Output)(respond)
app.post("/health", response_model=HealthStatus)(respond)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this's possible, particularly for the respond method as it needs the pipeline_runner unserializable variable. I.e. it's not possible to pass pipeline_runner as a dependency to the endpoint
Description
Add a new interface
HTTPMessangerInterfacewith an endpoint/chatand health-check one/healthChecklist
List here tasks to complete in order to mark this PR as ready for review.
To Consider
.ignorefiles, scripts (such aslint), distribution manifest (if files are added/deleted)