Questions tagged [langchain]

LangChain is an open-source framework for developing applications powered by language models. Use [py-langchain] for the python-specific package.

LangChain is an open-source framework for developing applications powered by language models. Use [py-langchain] for the python-specific package.

672 questions
3
votes
3 answers

Langchain pandas agent - Azure OpenAI account

I am trying to use Langchain for structured data using these steps from the official document. I changed it a bit as I am using Azure OpenAI account referring this. Below is the snippet of my code - from langchain.agents import…
Archit
  • 33
  • 6
3
votes
4 answers

how to create a langchain doc from an str

I've searched all over langchain documentation on their official website but I didn't find how to create a langchain doc from a str variable in python so I searched in their GitHub code and I found this : doc=Document( …
Mohamed Amine
  • 340
  • 1
  • 4
  • 16
3
votes
1 answer

How does `enforce_stop_tokens` work in LangChain with Huggingface models?

When we look at HuggingFaceHub model usage in langchain there's this part that the author doesn't know how to stop the generation, https://github.com/hwchase17/langchain/blob/master/langchain/llms/huggingface_pipeline.py#L182: class…
alvas
  • 115,346
  • 109
  • 446
  • 738
3
votes
0 answers

Langchain Ouput Parser on QA Chain

How does one correctly parse data from load_qa_chain? It is easy to retrieve an answer using the QA chain, but we want the LLM to return two answers, which then parsed by a output parser, PydanticOutputParser. The chain returns: {'output_text':…
rich
  • 520
  • 6
  • 21
3
votes
1 answer

Langchain pyPDFLoader

I am currently trying to get started working with Langchain. I am working in Anaconda/Spyder IDE: # Imports import os from langchain.llms import OpenAI from langchain.document_loaders import TextLoader from langchain.document_loaders import…
NeilS
  • 65
  • 1
  • 7
3
votes
1 answer

Using GPT 4 or GPT 3.5 with SQL Database Agent throws OutputParserException: Could not parse LLM output:

I am using the SQL Database Agent to query a postgres database. I want to use gpt 4 or gpt 3.5 models in the OpenAI llm passed to the agent, but it says I must use ChatOpenAI. Using ChatOpenAI throws parsing errors. The reason for wanting to switch…
RamlahAziz
  • 47
  • 10
3
votes
1 answer

LangChain, terminating a chain on specific tool output

Im using a conversational agent, with some tools, one of them is a calculator tool (for the sake of example). Agent initializated as follows: conversational_agent = initialize_agent( agent='chat-conversational-react-description', …
Aviran
  • 5,160
  • 7
  • 44
  • 76
3
votes
1 answer

Unable to send OpenAI stream response via Flask API

For streaming OpenAI response in langchain I use this https://python.langchain.com/en/latest/modules/models/chat/examples/streaming.html It streams the response in my terminal. I want to send stream response back to the user using Flask API Anyone,…
3
votes
1 answer

Query existing Pinecone index without re-loading the context data

I'm learning Langchain and vector databases. Following the original documentation I can read some docs, update the database and then make a…
Francisco Ghelfi
  • 872
  • 1
  • 11
  • 34
3
votes
1 answer

Indefinite wait while using Langchain and HuggingFaceHub in python

from langchain import PromptTemplate, HuggingFaceHub, LLMChain import os os.environ['HUGGINGFACEHUB_API_TOKEN'] = 'token' # initialize HF LLM flan_t5 = HuggingFaceHub( repo_id="google/flan-t5-xl", model_kwargs={"temperature":…
3
votes
1 answer

Google's flan-t5 models are not loading on HuggingFaceHub through Langchain

I am trying to replicate the example code provided on Langchain website (link here) but I am getting the following error whether I run it on Google colab or locally: HfHubHTTPError: 504 Server Error: Gateway Time-out for url:…
r1sh4bh
  • 61
  • 5
3
votes
1 answer

How can I index the tables along with texts present in the pdf using Llamaindex and LangChain? (i am using Openai key)

def ask(file): print(" Loading...") PDFReader = download_loader("PDFReader") loader = PDFReader() documents = loader.load_data(file=Path(file)) print("Path: ", Path(file)) # Check if the index file exists if…
Harshit
  • 41
  • 2
3
votes
1 answer

Using Custom JSON data for context in Langchain and ConversationChain() in ChatGPT OpenAI

I have a custom JSON file which is created from an excel sheet which contains certain data on which I want my questions to be based on and off which I require answers from OpenAI. Now for this I have a piece of code as follows - s3 =…
3
votes
1 answer

Is there any way to load an index created through VectorstoreIndexCreator in langchain? How does it work?

I am experimenting with langchains and its applications, but as a newbie, I could not understand how the embeddings and indexing really work together here. I know what these two are, but I can't figure out a way to use the index that I created and…
AqashaT
  • 45
  • 1
  • 7
3
votes
1 answer

Langchain, Huggingface: Can't evaluate model with two different inputs

I'm evaluating a LLM on Huggingface using Langchain and Python using this code: # https://github.com/hwchase17/langchain/blob/0e763677e4c334af80f2b542cb269f3786d8403f/docs/modules/models/llms/integrations/huggingface_hub.ipynb from langchain import…
Jennie94
  • 33
  • 4