Giter VIP home page Giter VIP logo

langchain-aws-template's Introduction

langchain-aws-template

This package contains code templates to deploy LLM applications built with LangChain to AWS. The templates contain both the infrastructure (CDK code) and the application code to run these services. At present, the following templates are included.

  1. Lambda Service: An API Gateway + Lambda based REST service, that can connect to any front end application to create a chat like request-reply application. There is a demo web app included to interact with the deployed service.

  1. Slack Bot: An API Gateway + Lambda based REST service, that can process slack messages by calling an LLM chain and send reply to the slack channel where the bot is installed.

Prerequisites

langchain-aws-template's People

Contributors

3coins avatar andreaolgiati avatar dianachung00 avatar utopianf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

langchain-aws-template's Issues

keyError 'session_id' while running service app

I am getting this error

0
Chat with AI
0

hello
KeyError: 'session_id'
Traceback:

File "/Users/rupeshti/anaconda3/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 541, in _run_script
    exec(code, module.__dict__)
File "/Users/rupeshti/workdir/gitbox/langchain-aws-template-main/service/webapp/app.py", line 123, in <module>
    write_chat_message(a, q)
File "/Users/rupeshti/workdir/gitbox/langchain-aws-template-main/service/webapp/app.py", line 114, in write_chat_message
    st.session_state['session_id'] = md['answer']['session_id']
                                     ~~~~~~~~~~~~^^^^^^^^^^^^^^

Made with [Streamlit](http://streamlit.io/)

Basic deploy has Access Denied for AWS-Parameters-and-Secrets-Lambda-Extension

cdk deploy in the service blows up with some permissions errors

Full stack trace:

12:51:25 PM | CREATE_FAILED | AWS::Lambda::Function | LangChainHandlerDD6FD44B
Resource handler returned message: "User: arn:aws:sts::942747732415:assumed-role/cdk-hnb659fds-cfn-exec-role-9
42747732415-us-west-2/AWSCloudFormation is not authorized to perform: lambda:GetLayerVersion on resource: arn:
aws:lambda:us-east-1:177933569100:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4 because no resource-base
d policy allows the lambda:GetLayerVersion action (Service: Lambda, Status Code: 403, Request ID: 64ab8809-cc5
4-49d2-996f-1b96c387404e)" (RequestToken: d53c00f6-d230-3dde-73bb-942b56d31849, HandlerErrorCode: AccessDenied
)

❌ LangChainApp failed: Error: The stack named LangChainApp failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "User: arn:aws:sts::942747732415:assumed-role/cdk-hnb659fds-cfn-exec-role-942747732415-us-west-2/AWSCloudFormation is not authorized to perform: lambda:GetLayerVersion on resource: arn:aws:lambda:us-east-1:177933569100:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4 because no resource-based policy allows the lambda:GetLayerVersion action (Service: Lambda, Status Code: 403, Request ID: 64ab8809-cc54-49d2-996f-1b96c387404e)" (RequestToken: d53c00f6-d230-3dde-73bb-942b56d31849, HandlerErrorCode: AccessDenied)
at FullCloudFormationDeployment.monitorDeployment (/Users/jmannix/.volta/tools/image/packages/aws-cdk/lib/node_modules/aws-cdk/lib/index.js:397:10236)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async deployStack2 (/Users/jmannix/.volta/tools/image/packages/aws-cdk/lib/node_modules/aws-cdk/lib/index.js:400:145739)
at async /Users/jmannix/.volta/tools/image/packages/aws-cdk/lib/node_modules/aws-cdk/lib/index.js:400:128776
at async run (/Users/jmannix/.volta/tools/image/packages/aws-cdk/lib/node_modules/aws-cdk/lib/index.js:400:126782)

❌ Deployment failed: Error: Stack Deployments Failed: Error: The stack named LangChainApp failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "User: arn:aws:sts::942747732415:assumed-role/cdk-hnb659fds-cfn-exec-role-942747732415-us-west-2/AWSCloudFormation is not authorized to perform: lambda:GetLayerVersion on resource: arn:aws:lambda:us-east-1:177933569100:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4 because no resource-based policy allows the lambda:GetLayerVersion action (Service: Lambda, Status Code: 403, Request ID: 64ab8809-cc54-49d2-996f-1b96c387404e)" (RequestToken: d53c00f6-d230-3dde-73bb-942b56d31849, HandlerErrorCode: AccessDenied)
at deployStacks (/Users/jmannix/.volta/tools/image/packages/aws-cdk/lib/node_modules/aws-cdk/lib/index.js:400:129083)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async CdkToolkit.deploy (/Users/jmannix/.volta/tools/image/packages/aws-cdk/lib/node_modules/aws-cdk/lib/index.js:400:147788)
at async exec4 (/Users/jmannix/.volta/tools/image/packages/aws-cdk/lib/node_modules/aws-cdk/lib/index.js:455:51984)

Stack Deployments Failed: Error: The stack named LangChainApp failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "User: arn:aws:sts::942747732415:assumed-role/cdk-hnb659fds-cfn-exec-role-942747732415-us-west-2/AWSCloudFormation is not authorized to perform: lambda:GetLayerVersion on resource: arn:aws:lambda:us-east-1:177933569100:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4 because no resource-based policy allows the lambda:GetLayerVersion action (Service: Lambda, Status Code: 403, Request ID: 64ab8809-cc54-49d2-996f-1b96c387404e)" (RequestToken: d53c00f6-d230-3dde-73bb-942b56d31849, HandlerErrorCode: AccessDenied)

Status:502;Internal server error - aws secrets manager related

I think this issue is related to aws secrets manager not setup correctly, according to this issue.

I followed this instruction to set up my aws secrets (and I made sure that it was set up in the same region as my lambda & api):
Expected secret name is api-keys
openai key is expected to be stored with openai-api-key key

but I still got Status:502;Internal server error...

here is a log file:

logs.txt

Any help is appreciated!

Langflow cannot be installed in SageMaker Studio Notebook and Jupyter Notebook

Langflow is a web interface to experiment and prototype langchain pipelines.
https://pypi.org/project/langflow/

In Jupyter Notebook (jupyter notebook has docker).
Instructions : 5, 6, 7
langflow-ai/langflow#310
Got struck after installing. Both local and network links giving "This site can’t be reached"
Tried both with local and network ip adding /proxy/3000. Didn't work.

Screenshot 2023-06-26 at 6 42 42 PM

pip install langflow in sagemaker studio is exiting with the error below. Langflow not getting installed.

Screenshot 2023-06-26 at 7 00 38 PM

Add a RAG template

Add a Retrieval Augmented Generation (RAG) template that can connect to external knowledge sources.

Front-End / Back-end Authentication

Many developers will need a front-end login/authentication that integrates with the back-end. One option is Amplify authentication, but the downside is it requires a Javascript front-end. To do so we could look to making a Typescript front-end folder that branches off of the mckaywrigely/chatbot-ui project.

Amplify Auth has the added benefit of allowing developers to identify which user is currently accessing the front-end allowing them to customize the chatbot with multiple features such as: allowing a user to access previous conversations in the left-hand menu and ensuring a user only has access to their own data.

Another benefit of the mckaywrigely/chatbot-ui project front-end is we can add further features later on such as allowing a user to select certain tools (similar to GPT Plugins).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.