Questions tagged [py-langchain]

LangChain is an open-source framework for developing applications powered by language models. Use this tag for the python-specific package.

LangChain is an open-source framework for developing applications powered by language models. Use this tag for the python-specific package.

Official Python LangChain documentation: https://python.langchain.com/en/latest/

153 questions
1
vote
2 answers

How to use SQLDatabaseChain from LangChain with memory?

I want to create a chain to make query against my database. Also I want to add memory to this chain. Example of dialogue I want to see: Query: Who is an owner of website with domain domain.com? Answer: Boba Bobovich Query: Tell me his email Answer:…
1
vote
0 answers

OPENAI-Langchain issues: while trying to read data from csv and convert into embeddings using the text-ada-002, I got the following error

We are getting the following error while trying to read data from csv and convert into embeddings using the text-ada-002  in langchain 500 {'error': {'message': 'The server had an error while processing your request. Sorry about that! You can retry…
Fred Wu
  • 11
  • 1
1
vote
0 answers

ImportError: cannot import name 'FunctionMessage' from 'langchain.schema'

I'm deputing the code below and I get an error message. ImportError cannot import name 'FunctionMessage' from 'langchain.schema' (/Users/janiobonfim/Projetos-VSCode/env/lib/python3.11/site-packages/langchain/schema.py) File…
Jan Ferrer
  • 21
  • 7
1
vote
1 answer

npydantic.error_wrappers.ValidationError: 1 validation error for XXX field required (type=value_error.missing)

I've edited the question as going round in circles trying to fix the original error. Here's the latest: Current error pydantic.main.BaseModel.__init__\npydantic.error_wrappers.ValidationError: 1 validation error for ConversationBufferMemory2\nchat\n…
Reddspark
  • 6,934
  • 9
  • 47
  • 64
1
vote
0 answers

Asynchronous tools break the chain in langchain implementation

I implemented langchain as a Python API, created via FASTAPI and uvicorn. The Python API is composed of one main service and various microservices the main service call when required. These microservices are tools. I use 3 tools: web search, image…
Hassan Baig
  • 15,055
  • 27
  • 102
  • 205
1
vote
1 answer

Langchain pandas agent unable to run pandas commands

I'm trying to use langchain's pandas agent on python for some development work but it goes into a recursive loop due to it being unable to take action on a thought, the thought being, having to run some pandas code to continue the thought process…
1
vote
1 answer

LangChain: Reduce size of tokens being passed to OpenAI

I am using LangChain to create embeddings and then ask a question to those embeddings like so: embeddings: OpenAIEmbeddings = OpenAIEmbeddings(disallowed_special=()) db = DeepLake( dataset_path=deeplake_url, read_only=True, …
Patrick Collins
  • 5,621
  • 3
  • 26
  • 64
1
vote
2 answers

ValidationError for trying to use langchain with ChatOpenAI()

I am newbie to LLM and I have been trying to implement recent deep learning tutorial in my notebook. I have set an openai.api_key="sk-xxxxxxxx". This key works perfectly when prompting and getting output from GPT, but the problem arises when I…
Warren K
  • 11
  • 3
1
vote
0 answers

How to add a k value to the SelfQueryRetriever of langchain

enter image description here enter image description here It is mentioned in the langchain document.We can also use the self query retriever to specify k: the number of documents to fetch. We can do this by passing enable_limit=True to the…
1
vote
1 answer

Question mutiple pdf's using openai, pinecone, langchain

I am trying to ask questions against a multiple pdf using pinecone and openAI but I dont know how to. The code below works for asking questions against one document. but I would like to have multiple documents to ask questions against: #…
Juan Casas
  • 268
  • 2
  • 13
1
vote
2 answers

Is there a way to edit Langchain Agent's conversation as it is going on?

I'm using langchain to query a MySQL database, but langchain agents always go over OpenAI's 4k token limit. When I looked into the agent's conversation history, it seems like the agent called schema_sql_db multiple times and the table schemas took…
1
vote
0 answers

I can't get langchain/openai to actually run the prompt that I am providing

I have been running into a major roadblock with langchain and I haven't yet figured out what's wrong. The issue is that when I ask openai to perform a task for me, it simply responds by saying what it will do, and then not actually doing it. I've…
redmage123
  • 413
  • 8
  • 15
1
vote
1 answer

Does the SQLDatabase agent for langchain store the database in memory?

Say I have a huge database stored in BigQuery, and I'd like to use the SQL Database Agent to query this database using natural language prompts. I can't store the data in memory because it's too huge. Does the SQLDatabase function store this in…
theodre7
  • 125
  • 4
1
vote
2 answers

How can I speed up a QA Langchain using load_qa_with_sources_chain?

I am currently running a QA model using load_qa_with_sources_chain(). However, when I run it with three chunks of each up to 10,000 tokens, it takes about 35s to return an answer. I would like to speed this up. Can somebody explain what influences…
1
vote
2 answers

Can't run simple intro langchain application and getting error

I'm having issues running simple example from the langchain from dotenv import load_dotenv,find_dotenv load_dotenv(find_dotenv()) from langchain.llms import openai llm = OpenAI(temperature=0.9) text = "What would be a good company name for a…
Andrey Tagaew
  • 1,573
  • 1
  • 15
  • 20