Brief description of what this chat function does, from the developer perspective
Specific input parameters which can be supplied when the calling this chat function.
Output schema/values for this function
List of example inputs and outputs for this function, each under a different sub-heading
To test your function, you can run the unit tests, call the code directly through a python script, or build the respective chat function docker container locally and call it through an API request. Below you can find details on those processes.
You can run the unit tests using pytest.
pytestYou can run the Python function itself. Make sure to have a main function in either src/module.py or index.py.
python src/module.pyYou can also use the manual_agent_run.py script to test the agents with example inputs from Lambda Feedback questions and synthetic conversations.
python tests/manual_agent_run.pyTo build the Docker image, run the following command:
docker build -t llm_chat .To run the Docker image, use the following command:
docker run -e OPENAI_API_KEY={your key} -e OPENAI_MODEL={your LLM chosen model name} -p 8080:8080 llm_chatdocker run --env-file .env -it --name my-lambda-container -p 8080:8080 llm_chatThis will start the chat function and expose it on port 8080 and it will be open to be curl:
curl --location 'http://localhost:8080/2015-03-31/functions/function/invocations' \
--header 'Content-Type: application/json' \
--data '{"body":"{\"message\": \"hi\", \"params\": {\"conversation_id\": \"12345Test\", \"conversation_history\": [{\"type\": \"user\", In the tests/ folder you can find the manual_agent_requests.py script that calls the POST URL of the running docker container. It reads any kind of input files with the expected schema. You can use this to test your curl calls of the chatbot.
POST URL:
http://localhost:8080/2015-03-31/functions/function/invocationsBody (stringified within body for API request):
{"body":"{\"message\": \"hi\", \"params\": {\"conversation_id\": \"12345Test\", \"conversation_history\": [{\"type\": \"user\", \"content\": \"hi\"}]}}"}Body with optional Params:
{
"message":"hi",
"params":{
"conversation_id":"12345Test",
"conversation_history":[{"type":"user","content":"hi"}],
"summary":" ",
"conversational_style":" ",
"question_response_details": "",
"include_test_data": true,
}
}