Skip to content

Commit

Permalink
Remove non-streaming chat handler
Browse files Browse the repository at this point in the history
Move python dependencies to a layer
  • Loading branch information
mbklein committed Oct 17, 2023
1 parent fd27e02 commit 54decee
Show file tree
Hide file tree
Showing 21 changed files with 25 additions and 556 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ $RECYCLE.BIN/
.vscode
/samconfig.toml
/samconfig.yaml
/samconfig.*.yaml
/env.json
/env.*.json
/*.parameters
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
cd node && npm run lint && npm run prettier && cd -
cd python && ruff check . && cd -
cd chat/src && ruff check . && cd -
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ style-node:
test-node:
cd node && npm run test
deps-python:
cd python && pip install -r requirements.txt
cd chat/src && pip install -r requirements.txt
cover-python:
cd python && coverage run --include='src/**/*' -m unittest -v && coverage report
cd chat/src && coverage run --include='src/**/*' -m unittest -v && coverage report
style-python:
cd python && ruff check .
cd chat/src && ruff check .
test-python:
cd python && python -m unittest -v
cd chat/src && python -m unittest -v
build: .aws-sam/build.toml
link: build
cd python/src && for src in *.py **/*.py; do for target in $$(find ../../.aws-sam/build -maxdepth 1 -type d); do if [[ -f $$target/$$src ]]; then ln -f $$src $$target/$$src; fi; done; done
cd chat/src && for src in *.py **/*.py; do for target in $$(find ../../.aws-sam/build -maxdepth 1 -type d); do if [[ -f $$target/$$src ]]; then ln -f $$src $$target/$$src; fi; done; done
cd node/src && for src in *.js *.json **/*.js **/*.json; do for target in $$(find ../../.aws-sam/build -maxdepth 1 -type d); do if [[ -f $$target/$$src ]]; then ln -f $$src $$target/$$src; fi; done; done
serve: link
sam local start-api --host 0.0.0.0 --log-file dc-api.log
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion chat/src/handlers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, socket: Websocket):
self.socket = socket

def on_llm_new_token(self, token: str, **kwargs):
self.socket.send({'token': token});
self.socket.send({'token': token})

def handler(event, context):
try:
Expand Down
18 changes: 17 additions & 1 deletion chat/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,27 @@ Resources:
Action: lambda:InvokeFunction
FunctionName: !Ref ChatFunction
Principal: apigateway.amazonaws.com
ChatDependencies:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName:
Fn::Sub: "${AWS::StackName}-dependencies"
Description: Dependencies for streaming chat function
ContentUri: ./dependencies
CompatibleRuntimes:
- python3.10
LicenseInfo: "Apache-2.0"
Metadata:
BuildMethod: python3.10
ChatFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./src
Runtime: python3.9
Runtime: python3.10
Architectures:
- x86_64
Layers:
- !Ref ChatDependencies
MemorySize: 128
Handler: handlers/chat.handler
Timeout: 300
Expand All @@ -197,6 +211,8 @@ Resources:
- 'execute-api:ManageConnections'
Resource:
- !Sub 'arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ChatWebSocket}/*'
Metadata:
BuildMethod: nodejs18.x
Deployment:
Type: AWS::ApiGatewayV2::Deployment
DependsOn:
Expand Down
3 changes: 0 additions & 3 deletions python/requirements.txt

This file was deleted.

Empty file removed python/src/__init__.py
Empty file.
105 changes: 0 additions & 105 deletions python/src/handlers/chat.py

This file was deleted.

28 changes: 0 additions & 28 deletions python/src/helpers/apitoken.py

This file was deleted.

48 changes: 0 additions & 48 deletions python/src/helpers/event.py

This file was deleted.

Loading

0 comments on commit 54decee

Please sign in to comment.