-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #63 * refactor:backend directory structure * fix: readme * wip * enable hot reload * wip * change: detection of end of streaming' * update: max token * fix * fix * change temperature --------- Co-authored-by: Yusuke Wada <[email protected]>
- Loading branch information
Showing
28 changed files
with
180 additions
and
184 deletions.
There are no files selected for viewing
This file contains 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 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,16 +1,15 @@ | ||
FROM public.ecr.aws/docker/library/python:3.11.4-slim-bullseye | ||
FROM public.ecr.aws/docker/library/python:3.11.6-slim-bullseye | ||
|
||
# Install lambda web adapter | ||
COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.0 /lambda-adapter /opt/extensions/lambda-adapter | ||
|
||
WORKDIR /app | ||
WORKDIR /backend | ||
|
||
COPY ./api/requirements.txt ./ | ||
COPY ./requirements.txt ./ | ||
RUN pip3 install -r requirements.txt --no-cache-dir | ||
|
||
COPY ./common . | ||
COPY ./api . | ||
COPY ./app ./app | ||
|
||
ENV PORT=8000 | ||
EXPOSE ${PORT} | ||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] | ||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] |
This file contains 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
File renamed without changes.
This file contains 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 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 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 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
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import json | ||
import os | ||
|
||
import boto3 | ||
from botocore.exceptions import ClientError | ||
|
||
TOPIC_ARN = os.environ["WEBSOCKET_TOPIC_ARN"] | ||
sns_client = boto3.client("sns") | ||
|
||
|
||
def handler(event, context): | ||
print(f"Received event: {event}") | ||
route_key = event["requestContext"]["routeKey"] | ||
|
||
if route_key == "$connect": | ||
# NOTE: Authentication is run at each message | ||
return {"statusCode": 200, "body": "Connected."} | ||
|
||
message = { | ||
"requestContext": event["requestContext"], | ||
"body": event["body"], | ||
} | ||
|
||
try: | ||
sns_response = sns_client.publish( | ||
TopicArn=TOPIC_ARN, | ||
Message=json.dumps(message), | ||
) | ||
|
||
response = { | ||
"statusCode": 200, | ||
} | ||
except ClientError as e: | ||
print(f"ClientError: {e}") | ||
response = { | ||
"statusCode": 500, | ||
"body": json.dumps({"error": str(e)}), | ||
} | ||
|
||
return response |
File renamed without changes.
Oops, something went wrong.