Closed valentin-dirken closed 1 month ago
Hi,
You can use the framework anywhere, in a Lambda Function included.
There is a demo app included in the repository where the framework is used in a Lambda function.
Have a look at the code here https://github.com/awslabs/multi-agent-orchestrator/blob/main/examples/chat-demo-app/lambda/multi-agent/index.ts
.
The framework does not need anything special to be done in order to work inside a lambda. The library is available in python also , you can use it in your Lambda Function like any other library. Have you tried to create your function using the library and had any issues?
I just made some changes to the documentation and now there is a section on how to use it inside a Lambda Function in python https://awslabs.github.io/multi-agent-orchestrator/deployment/aws-lambda-py/
Check it out and let me know if it helps.
Hi, Thank you ! I'm checking the code.
Runtime: Python 3.12
Handler : lambda_function.lambda_handler
Architecture: x86_64
Event JSON :
{ "query": "What is Artificial Intelligence ?", "userId": "user123", "sessionId": "23987987" }
I have an error :
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'pydantic_core._pydantic_core'",
"errorType": "Runtime.ImportModuleError",
"requestId": "",
"stackTrace": []
}
Lambda requires packages built for a specific architecture. Many packages have distributions for multiple architectures (see available distributions for pydantic-core). By default, pip installs the distribution suitable for the machine where you are running it on, which is not necessary the same architecture as your Lambda. But you can force pip to install packages for the architecture you want. If your Lambda uses x86_64, then you should select platform manylinux2014_x86_64:
https://github.com/pydantic/pydantic/issues/6557 https://docs.pydantic.dev/latest/integrations/aws_lambda/#troubleshooting
In the meantime :
I propose that you add this command for Windows
Compress-Archive -Path .\* -DestinationPath ..\deployment-package.zip
And
Add-Type -AssemblyName "System.IO.Compression.FileSystem"; $zip = [System.IO.Compression.ZipFile]::Open("deployment-package.zip", [System.IO.Compression.ZipArchiveMode]::Update); if ($entry = $zip.Entries | Where-Object { $_.FullName -eq "lambda_function.py" }) { $entry.Delete() }; $entry = $zip.CreateEntry("lambda_function.py"); $stream = $entry.Open(); [System.IO.File]::OpenRead("lambda_function.py").CopyTo($stream); $stream.Close(); $zip.Dispose()
Regarding "Set the runtime to Python 3.8 or later.", it's minimum 3.12. https://github.com/awslabs/multi-agent-orchestrator/blob/e25419487942f6c9e05b699b6fadd1d02a9b0109/python/setup.cfg#L21
Thank you for letting me know. The documentation about using the framework inside a lambda function is mainly to show how the framework can be imported and used. Regarding the errors on the Lambda function itself you should check the official documentation. I've updated the documentation to highlight this point.
Use case
I am working on integrating the Multi-Agent Orchestrator into a serverless architecture using AWS Lambda. My goal is to leverage AWS Lambda's scalability and cost-efficiency while utilizing the orchestrator's powerful multi-agent capabilities. However, deploying and managing the orchestrator within the AWS Lambda environment presents challenges, particularly with handling asynchronous operations and adapting to Lambda’s execution model.
Solution/User Experience
I would like to request a version of the orchestrator which can be deployed as a Lambda function.
Alternative solutions
No response