Skip to content

Commit da8943d

Browse files
committed
feat: add v2 Settings class
1 parent 8adc7c4 commit da8943d

File tree

5 files changed

+38
-49
lines changed

5 files changed

+38
-49
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#------------------------------------------------------------------------------
3+
# written by: Lawrence McDaniel
4+
# https://lawrencemcdaniel.com/
5+
#
6+
# date: sep-2023
7+
#
8+
# usage: Lambda Python packaging tool.
9+
# Called by Terraform "null_resource". Copies python
10+
# module(s) plus any requirements to a dedicated folder so that
11+
# it can be archived to a zip file for upload to
12+
# AWS Lambda by Terraform.
13+
#------------------------------------------------------------------------------
14+
15+
# delete and recreate the package folder to remove any existing build artifacts
16+
PACKAGE_NAME=openai_api
17+
18+
rm -rf $BUILD_PATH/$PACKAGE_NAME
19+
mkdir -p $BUILD_PATH
20+
21+
# copy the python module(s) to the package folder
22+
echo "BUILD_PATH: " $BUILD_PATH
23+
echo "SOURCE_CODE_PATH: " $SOURCE_CODE_PATH
24+
25+
cp -R $SOURCE_CODE_PATH $BUILD_PATH/
26+
cp terraform.tfvars $BUILD_PATH/$PACKAGE_NAME/
27+
touch $BUILD_PATH/$PACKAGE_NAME/__init__.py
28+
29+
# remove any non-production artifacts
30+
find $BUILD_PATH/$PACKAGE_NAME/ -name __pycache__ -type d -exec rm -rf {} +
31+
find $BUILD_PATH/$PACKAGE_NAME/ -name tests -type d -exec rm -rf {} +
32+
find $BUILD_PATH/$PACKAGE_NAME/ -name .gitignore -type f -exec rm -rf {} +
33+
find $BUILD_PATH/$PACKAGE_NAME/ -name create_pkg.sh -type f -exec rm -rf {} +
34+
find $BUILD_PATH/$PACKAGE_NAME/ -name .DS_Store -type f -exec rm -rf {} +
35+
find $BUILD_PATH/$PACKAGE_NAME/ -name env.sh -type f -exec rm -rf {} +

api/terraform/python/openai_api/lambda_langchain/create_pkg.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

api/terraform/python/openai_api/lambda_langchain/lambda_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def handler(event, context):
6868
OpenAI API endpoint based on the contents of the request.
6969
"""
7070

71-
cloudwatch_handler(event)
71+
cloudwatch_handler(event, settings.dump, debug_mode=settings.debug_mode)
7272
try:
7373
openai_results = {}
7474
# ----------------------------------------------------------------------
@@ -79,7 +79,7 @@ def handler(event, context):
7979
object_type, model, messages, input_text, temperature, max_tokens = parse_request(request_body)
8080
request_meta_data = {
8181
"request_meta_data": {
82-
"lambda": "lambda_openai_v2",
82+
"lambda": "lambda_langchain",
8383
"model": model,
8484
"object_type": object_type,
8585
"temperature": temperature,

api/terraform/python/openai_api/lambda_openai_v2/create_pkg.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

api/terraform/python/openai_api/lambda_openai_v2/lambda_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def handler(event, context):
6161
Responsible for processing incoming requests and invoking the appropriate
6262
OpenAI API endpoint based on the contents of the request.
6363
"""
64-
cloudwatch_handler(event)
64+
cloudwatch_handler(event, settings.dump, debug_mode=settings.debug_mode)
6565
try:
6666
openai_results = {}
6767
request_body = get_request_body(event=event)

0 commit comments

Comments
 (0)