AWS Lambda + ChatGPT API = 🔥
HTML-код
- Опубликовано: 12 сен 2024
- You have an AWS Lambda function and now you want to integrate with ChatGPT's API.
Can you do this in a few steps using the Cloud9 IDE?
--
AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers.
--
Tutorial Summary:
- The video demonstrates how to integrate AWS Lambda with the ChatGPT API.
- The process is explained in a series of steps using the Cloud9 IDE.
Steps:
1. Navigate to the Lambda service.
2. Create a new Lambda function with a Python runtime.
3. Configure environment variables, including an API key.
4. Increase the timeout value for the Lambda function to 20 seconds.
5. In the Code Source tab, copy and paste Python code.
6. The code imports modules, sets API key, defines message roles, and makes a chat completion call.
7. It extracts the response and constructs an HTML output.
8. Deploy the Lambda function, but encounter an issue with the OpenAI module.
To fix the OpenAI module issue:
9. Create a Cloud9 environment.
10. Open the Cloud9 IDE.
11. Download the Lambda function code.
12. Install the OpenAI module using pip3.
13. Upload the Lambda function code back to Lambda.
14. Adjust the timeout setting to 40 seconds.
15. Test the Lambda function, and it works.
16. Check the Lambda output in a web browser, and it displays an interesting fact about New York, which changes with each refresh.
Nice video, I got stuck with "No module named `pydantic_core._pydantic_core` error", run pip3 -V in your cloud9 ide to get the python version, and use that as the runtime version in your lambda function. Worked for me.
@@saipranavvuppala7829 what is your python version?
Man! your style is very nice! Both, the way you dress, and the way you explain!
Thank you but I am getting No module named `pydantic_core._pydantic_core` error
Bro, it's not a tiktok video, try not to bounce as much. Good content by the way! Thanks
Bro love your videos
Thank you! :)
Sorry, Stop moving around, it's so annoying!!
haha, fair enough!
yep, super distracting. don't act so much
Very nice video, I am having similar issues to many other with pylance it appears there is a hurdle there that could be addressed
I am getting internal server error at the end after creating function URL. any ideas?
awesome!!! 🤯
:)
It says that I'm missing pylance eventhouhg pylance is installed with openai
That’s strange! Perhaps try installing it anyway.
Hey need help
My lambda give error "message": "Endpoint request timed out" even after changing it to 5 minutes.
How to solve this?
Make sure it works in Playground first: platform.openai.com/playground
@@GokceDB Yes. It does.
@@shamsudheenmarakkar7346 is your Lambda running in a VPC? Does it have access to the internet?
i'm getting: ""errorMessage": "Unable to import module 'lambda_function': No module named 'pydantic_core._pydantic_core'"" but I see it in the folder when i ls
I found a GitHub repository that offers an OpenAI layer and solves the issue: "Unable to import module 'lambda_function': No module named 'pydantic_core._pydantic_core'". @Gokce DB, could you create a tutorial on this topic, as we are encountering the same error with the anthropic library.
Same error here.
The more easiest, it's to use lambda with bedrock @@enricotrivellato2898
where can I get the lambda script you pasted?
I love your style, but I need help! I tried twice and get this error when I run the test in Lambda: "Unable to import module 'lambda_function': No module named 'pydantic_core._pydantic_core'",
Try installing this module :)
same problem here...
@@L12393 did you try installing the module?
@@GokceDB I tried to pip install pydantic-core and add it to a new layer but the error occurs.
Hey, did you find a solution? @@GokceDB
This is the error message when I follow your steps.:
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'pydantic_core._pydantic_core'",
"errorType": "Runtime.ImportModuleError",
"requestId": "93f7da54-3f7e-41a5-95d2-9038bc158337",
"stackTrace": []
}
The only thing I noticed was that you have a .C9 folder in your environment. Is that related?
When I open the choose my region and select the lambda function I can't download it , It's not available ..why?
Try python 3.10 for your Lambda function, then try again
"errorMessage": "Unable to import module 'lambda_function': No module named 'pydantic_core._pydantic_core'",
this error happened in your method and it is also happened when I used layers ...this error would kill me @@GokceDB
@@Mostafa_Sharaf_4_9 that's weird. Try installing this module.
I downgraded the python version and it worked.
can we use langchain along with vector db ?
you"re the best
too much showmanship...
Sorry
the cloud9 isnt connecting for me
Exelente
:)
No way this guy isn't AI generated