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
5
votes
0 answers

Langchain - Can't solve the dynamic filtering problem from vectorstore

I am using Langchain version 0.218, and was wondering if anyone was able to filter a seeded vectorstore dynamically during runtime? Such as when running by a Agent. My motive is to put this dynamic filter in a Conversational Retrieval QA chain,…
5
votes
1 answer

define an output schema for a nested json in langchain

Whats the recommended way to define an output schema for a nested json, the method I use doesn't feel ideal. # adding to planner -> from langchain.experimental.plan_and_execute import load_chat_planner refinement_response_schemas = [ …
Zizi96
  • 459
  • 1
  • 6
  • 23
5
votes
1 answer

In LangChain, how to save the verbose output to a variable?

I tried executing a langchain agent. I want to save the output from verbose into a variable, but all I can access from the agent.run is only the final answer. How can I save the verbose output to a variable so that I can use later? My code: import…
Troyanovsky
  • 53
  • 1
  • 3
5
votes
2 answers

I can't get the langchain agent module to actually execute my prompt

I am learning how to use langchain and I have written a small exercise to try and figure out how agents work. I have a small Python program that looks like this: import os from…
redmage123
  • 413
  • 8
  • 15
5
votes
2 answers

How to incorporate context/chat history in OpenAI ChatBot using ChatGPT and langchain in Python?

Please bear with me as this is literally the first major code I have ever written and its for OpenAI's ChatGPT API. What I intend to do with this code is load a pdf document or a group of pdf documents. Then split them up so as to not use up my…
Ali Q
  • 51
  • 4
5
votes
1 answer

Stream a response from LangChain's OpenAI with Pyton Flask API

I am using Python Flask app for chat over data. So in the console I am getting streamable response directly from the OpenAI since I can enable streming with a flag streaming=True. The problem is, that I can't “forward” the stream or “show” the strem…
devZ
  • 606
  • 1
  • 7
  • 23
5
votes
0 answers

How to use StuffDocumentsChain with ConversationChain in LangChain?

I want to use StuffDocumentsChain but with behaviour of ConversationChain the suggested example in the documentation doesn't work as I want: import fs from 'fs'; import path from 'path'; import { OpenAI } from "langchain/llms/openai"; import {…
Arsenius
  • 4,972
  • 4
  • 26
  • 39
4
votes
1 answer

module 'chainlit' has no attribute 'langchain_factory'

I downloaded the repo: https://github.com/menloparklab/falcon-langchain I created a virtualenv for this one to install the requirments.txt and run the application. After I run the application using the following command. chainlit run app.py -w But…
cetusian
  • 45
  • 4
4
votes
5 answers

Langchain: ModuleNotFoundError: No module named 'langchain'

When I write code in VS Code, beginning with: import os from langchain.chains import RetrievalQA from langchain.llms import OpenAI from langchain.document_loaders import TextLoader I am met with the error: ModuleNotFoundError: No module named…
4
votes
3 answers

Langchain: text splitter behavior

I don't understand the following behavior of Langchain recursive text splitter. Here is my code and output. from langchain.text_splitter import RecursiveCharacterTextSplitter r_splitter = RecursiveCharacterTextSplitter( chunk_size=10, …
GreenEye
  • 153
  • 2
  • 14
4
votes
2 answers

How do I change the default 4 documents that LangChain returns?

I have the following code that implements LangChain + ChatGPT to answer questions from given data: import { PineconeStore } from 'langchain/vectorstores/pinecone'; import { ConversationalRetrievalQAChain } from 'langchain/chains'; const…
imjesr
  • 89
  • 4
4
votes
1 answer

For GPT4All, cannot seem to load downloaded model file. Getting error llama_init_from_file: failed to load model (bad f16 value 5)

I am trying to use the following code for using GPT4All with langchain but am getting the above error: Code: import streamlit as st from langchain import PromptTemplate, LLMChain from langchain.llms import GPT4All from…
Daremitsu
  • 545
  • 2
  • 8
  • 24
4
votes
2 answers

How to use the new gpt-3.5-16k model with langchain?

I have written an application in langchain that passes a number of chains to a Sequential Chain to run. The problem I'm having is that the prompts are so large that they are exceeding the 4K token limit size. I saw that OpenAI has released a new…
redmage123
  • 413
  • 8
  • 15
4
votes
2 answers

How to load a folder of Json files in Langchain?

I am trying to load a folder of JSON files in Langchain as: loader = DirectoryLoader(r'C:...') documents = loader.load() But I got such an error message: ValueError: Json schema does not match the Unstructured schema Can anyone tell me how to…
peiwb
  • 41
  • 1
  • 2
4
votes
2 answers

ChromaDb add single document, only if it doesn't exist

I'm working with langchain and ChromaDb using python. Now, I know how to use document loaders. For instance, the below loads a bunch of documents into ChromaDb: from langchain.embeddings.openai import OpenAIEmbeddings embeddings =…
user791793
  • 413
  • 1
  • 6
  • 19
1
2
3
44 45