Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 8d622ab

Browse files
committed
add lambda deploy approach and expose functions
1 parent 0bd911c commit 8d622ab

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/data_neuron/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .chat_cmd.main import process_chat_message
2+
from .lambda_handler import lambda_handler
3+
4+
__all__ = [
5+
'process_chat_message',
6+
'lambda_handler'
7+
]

src/data_neuron/lambda_handler.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import json
2+
from .server import app as application
3+
4+
5+
def lambda_handler(event, context):
6+
with application.test_client() as client:
7+
http_method = event['httpMethod']
8+
path = event['path']
9+
headers = event.get('headers', {})
10+
query_string = event.get('queryStringParameters', {})
11+
body = event.get('body', '')
12+
13+
if body:
14+
body = json.loads(body)
15+
16+
response = client.open(
17+
path,
18+
method=http_method,
19+
headers=headers,
20+
query_string=query_string,
21+
json=body
22+
)
23+
24+
return {
25+
'statusCode': response.status_code,
26+
'body': response.data.decode('utf-8'),
27+
'headers': dict(response.headers)
28+
}

0 commit comments

Comments
 (0)