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
24
votes
6 answers

import langchain => Error : TypeError: issubclass() arg 1 must be a class

I want to use langchain for my project. so I installed it using following command : pip install langchain but While importing "langchain" I am facing following Error: File /usr/lib/python3.8/typing.py:774, in _GenericAlias.__subclasscheck__(self,…
M. D. P
  • 604
  • 2
  • 6
  • 18
10
votes
3 answers

Question and answer over multiple csv files in langchain

I've a folder with multiple csv files, I'm trying to figure out a way to load them all into langchain and ask questions over all of them. Here's what I have so far. from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores…
Dave Kalu
  • 1,520
  • 3
  • 19
  • 38
10
votes
2 answers

How to persist LangChain conversation memory (save and load)?

I'm creating a conversation like so: llm = ChatOpenAI(temperature=0, openai_api_key=OPENAI_API_KEY, model_name=OPENAI_DEFAULT_MODEL) conversation = ConversationChain(llm=llm, memory=ConversationBufferMemory()) But what I really want is to be able…
Neil C. Obremski
  • 18,696
  • 24
  • 83
  • 112
9
votes
1 answer

Streaming ChatGPT's results with Flask and LangChain

Basically I want to achieve this with Flask and LangChain: https://www.youtube.com/watch?v=x8uwwLNxqis. I'm building a Q&A Flask app that uses LangChain in the backend, but I'm having trouble to stream the response from ChatGPT. My chain looks like…
Dante Noguez
  • 91
  • 1
  • 3
8
votes
4 answers

How do i add memory to RetrievalQA.from_chain_type? or, how do I add a custom prompt to ConversationalRetrievalChain?

How do i add memory to RetrievalQA.from_chain_type? or, how do I add a custom prompt to ConversationalRetrievalChain? For the past 2 weeks ive been trying to make a chatbot that can chat over documents (so not in just a semantic search/qa so with…
8
votes
4 answers

LangChain Chroma - load data from Vector Database

I have written LangChain code using Chroma DB to vector store the data from a website url. It currently works to get the data from the URL, store it into the project folder and then use that data to respond to a user prompt. I figured out how to…
max choate
  • 81
  • 1
  • 3
7
votes
0 answers

How to combine ConversationalRetrievalQAChain, Agents, and Tools in LangChain

I'd like to combine a ConversationalRetrievalQAChain with - for example - the SerpAPI tool in LangChain. I'm using ConversationalRetrievalQAChain to search through product PDFs that have been ingested using OpenAI's embedding API and a local Chroma…
Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165
7
votes
1 answer

How can I use LangChain Callbacks to log the model calls and answers into a variable

I'm using LangChain to build a NL application. I want the interactions with the LLM to be recorded in a variable I can use for logging and debugging purposes. I have created a very simple chain: from typing import Any, Dict from langchain import…
Pythonist
  • 1,937
  • 1
  • 14
  • 25
7
votes
3 answers

How to stream Agent's response in Langchain?

I am using Langchain with Gradio interface in Python. I have made a conversational agent and am trying to stream its responses to the Gradio chatbot interface. I have had a look at the Langchain docs and could not find an example that implements…
MRF
  • 455
  • 1
  • 6
  • 13
7
votes
2 answers

Using Chain and Parser together in langchain

The langchain docs include this example for configuring and invoking a PydanticOutputParser # Define your desired data structure. class Joke(BaseModel): setup: str = Field(description="question to set up a joke") punchline: str =…
Abe
  • 22,738
  • 26
  • 82
  • 111
6
votes
2 answers

How to store chat history using langchain conversationalRetrievalQA chain in a Next JS app?

Im creating a text document QA chatbot, Im using Langchainjs along with OpenAI LLM for creating embeddings and Chat and Pinecone as my vector Store. See Diagram: After successfully uploading embeddings and creating an index on pinecone. I am using…
jasan
  • 11,475
  • 22
  • 57
  • 97
6
votes
1 answer

langchain custom prompts & input parameters not clear

I do not understand how customprompt works in the example documentation: https://python.langchain.com/en/latest/modules/chains/index_examples/qa_with_sources.html prompt object is defined as: PROMPT = PromptTemplate(template=template,…
Ani
  • 265
  • 1
  • 3
  • 10
6
votes
0 answers

Refer to specific files using LangChain & Question-Answering about differences/comparisons

I have not found documentation regarding Question-Answering based on multiple text files, while referencing the text files individually. Example: I have file1.txt through file20.txt. file1.txt is from April 2023 and file5.txt is from March…
Jay Jung
  • 1,805
  • 3
  • 23
  • 46
6
votes
2 answers

Using Vicuna + langchain + llama_index for creating a self hosted LLM model

I want to create a self hosted LLM model that will be able to have a context of my own custom data (Slack conversations for that matter). I've heard Vicuna is a great alternative to ChatGPT and so I made the below code: from llama_index import…
Ben
  • 421
  • 6
  • 19
6
votes
2 answers

langchain: logprobs, best_of and echo parameters are not available on gpt-35-turbo model

I am trying to use langchain with gpt-35-turbo. It seems that the new gpt3.5 turbo is not using certain parameters anymore as per the link Learn how to work with the ChatGPT and GPT-4 models (preview) The following parameters aren't available with…
Sarah
  • 1,361
  • 2
  • 14
  • 20
1
2 3
44 45