-
Notifications
You must be signed in to change notification settings - Fork 0
Shimmy #9
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
Open
m-messer
wants to merge
6
commits into
main
Choose a base branch
from
shimmy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Shimmy #9
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8de7d90
Refactor to replace AWS Lambda entrypoint with shimmy-compatible work…
m-messer d81c039
Update Dockerfile to use `evaluation-function-base` image for BASE_VE…
m-messer c760c9a
Update Dockerfile to use `python:chat-testing-3.12` as BASE_VERSION.
m-messer e3c7ce5
Clarify README: Adjust `X-Api-Version` header requirement to optional.
m-messer 93c0819
Update dependencies and simplify BASE_VERSION in Dockerfile.
m-messer ab9c3b0
Update `lf_toolkit` dependency and add worker send timeout in Dockerf…
m-messer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,14 @@ | ||
| import json | ||
| from pydantic import ValidationError | ||
| from lf_toolkit import create_server, run | ||
|
|
||
| from lf_toolkit.chat import ChatRequest | ||
| from src.module import chat_module | ||
| from src.module import chat_health_module, chat_module | ||
|
|
||
|
|
||
| def handler(event, context): | ||
| """ | ||
| Lambda handler function | ||
| """ | ||
| print("Received event:", json.dumps(event)) | ||
| def main(): | ||
| server = create_server() | ||
| server.chat(chat_module) | ||
| server.chat_health(chat_health_module) | ||
| run(server) | ||
|
|
||
| if "body" in event: | ||
| try: | ||
| event = json.loads(event["body"]) | ||
| except json.JSONDecodeError: | ||
| return { | ||
| "statusCode": 400, | ||
| "body": "Invalid JSON format in the body. Please check the input.", | ||
| } | ||
|
|
||
| try: | ||
| request = ChatRequest.model_validate(event) | ||
| except ValidationError as e: | ||
| return {"statusCode": 400, "body": e.json()} | ||
|
|
||
| try: | ||
| result = chat_module(request) | ||
| except Exception as e: | ||
| return { | ||
| "statusCode": 500, | ||
| "body": f"An error occurred within the chat_module(): {str(e)}", | ||
| } | ||
|
|
||
| response = {"statusCode": 200, "body": result.model_dump_json()} | ||
| return response | ||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| import time | ||
| from langchain_core.messages import HumanMessage, AIMessage, SystemMessage | ||
|
|
||
| from lf_toolkit.chat import ChatRequest, ChatResponse, Message | ||
| from lf_toolkit.shared.mued_api_v0_1_0 import Role | ||
| from lf_toolkit.chat import ChatCapabilities, ChatHealthResponse, ChatRequest, ChatResponse, Message | ||
| from lf_toolkit.shared.mued_api_v0_1_0 import DataPolicySupport, HealthStatus, Role | ||
|
|
||
| from src.agent.context import parse_json_to_prompt | ||
| from src.agent.agent import invoke_base_agent | ||
|
|
@@ -61,6 +61,22 @@ def chat_module(request: ChatRequest) -> ChatResponse: | |
| ) | ||
|
|
||
|
|
||
| def chat_health_module() -> ChatHealthResponse: | ||
| """ | ||
| Health-check entry point — reports whether this chat function is up and | ||
| what it supports, for the shim's GET /chat/health. | ||
| """ | ||
| return ChatHealthResponse( | ||
| status=HealthStatus.OK, | ||
| capabilities=ChatCapabilities( | ||
| supportsChat=True, | ||
| supportsUserPreferences=True, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to update this to False |
||
| supportsStreaming=False, | ||
| supportsDataPolicy=DataPolicySupport.NOT_SUPPORTED, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| def _to_langchain_messages(messages): | ||
| result = [] | ||
| for m in messages: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
same here as maybe we should now rename the deployment path to microservices-base