Giter VIP home page Giter VIP logo

langchain-aws-template's Issues

Add a RAG template

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

KeyError: 'message' occasionally on completions

I occasionally get a the following error on completions:

KeyError: 'message'

Here's the stack:

  File ".../langchain_aws/chat_models/bedrock.py", line 361, in _generate
    for chunk in self._stream(messages, stop, run_manager, **kwargs):
  File ".../langchain_aws/chat_models/bedrock.py", line 339, in _stream
    for chunk in self._prepare_input_and_invoke_stream(
  File ".../langchain_aws/llms/bedrock.py", line 653, in _prepare_input_and_invoke_stream
    for chunk in LLMInputOutputAdapter.prepare_output_stream(
  File ".../langchain_aws/llms/bedrock.py", line 239, in prepare_output_stream
    chunk_obj[output_key]

Here are my langchain versions:

langchain                  0.1.20
langchain-anthropic        0.1.11
langchain-aws              0.1.3
langchain-community        0.0.38
langchain-core             0.1.52
langchain-experimental     0.0.58
langchain-text-splitters   0.0.1
langgraph                  0.0.48

Python version: Python 3.11.6
Model Id: anthropic.claude-3-sonnet-20240229-v1:0

The error is intermittent. It appears to be an issue with the response that Bedrock is generating.

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/)

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).

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)

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

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!

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.