issue_owner_repo
listlengths
2
2
issue_body
stringlengths
0
261k
issue_title
stringlengths
1
925
issue_comments_url
stringlengths
56
81
issue_comments_count
int64
0
2.5k
issue_created_at
stringlengths
20
20
issue_updated_at
stringlengths
20
20
issue_html_url
stringlengths
37
62
issue_github_id
int64
387k
2.46B
issue_number
int64
1
127k
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I want to read otp using gmail tool kit but I am getting an errror when the email is in form of HTML or in image form . How do I fix this ? ### Suggestion: _No response_
Unable to read OTP from an email whose content is in form of HTML/Image
https://api.github.com/repos/langchain-ai/langchain/issues/12820/comments
3
2023-11-03T06:34:28Z
2024-02-09T16:09:03Z
https://github.com/langchain-ai/langchain/issues/12820
1,975,535,523
12,820
[ "langchain-ai", "langchain" ]
### Feature request Move Chat [LangChain](https://github.com/langchain-ai/chat-langchain) into a template. ### Motivation ChatLangchain has useful features (prompts, etc) that should be captured in a templates. ### Your contribution Add template
[Chat template] Chat LangChain
https://api.github.com/repos/langchain-ai/langchain/issues/12818/comments
2
2023-11-03T04:14:37Z
2024-02-09T16:09:08Z
https://github.com/langchain-ai/langchain/issues/12818
1,975,429,808
12,818
[ "langchain-ai", "langchain" ]
### Issue with current documentation: Converting https://python.langchain.com/ to a pdf using https://github.com/jean-humann/docs-to-pdf runs forever because https://python.langchain.com/docs/expression_language/cookbook/tools --next leads to a previous page. `npx docs-to-pdf --initialDocURLs="https://python.langchain.com/" --contentSelector="article" --paginationSelector="a.pagination-nav__link.pagination-nav__link--next" --coverImage="https://upload.wikimedia.org/wikipedia/commons/3/3f/LangChain_logo.png" --coverTitle="LangChain"` ### Idea or request for content: _No response_
DOC: docs/expression_language/cookbook/tools --next leads to a previous page
https://api.github.com/repos/langchain-ai/langchain/issues/12815/comments
5
2023-11-03T02:53:58Z
2024-02-12T16:08:39Z
https://github.com/langchain-ai/langchain/issues/12815
1,975,379,949
12,815
[ "langchain-ai", "langchain" ]
### System Info langchain: 0.0.311 ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [X] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction We're trying to load confluence pages using `ConfluenceLoader.load()`. If we load pages by list of page_ids: ``` loader = ConfluenceLoader( url=baseUrl, username=username, api_key= api_key ) documents = loader.load( page_ids = ["2081227164", "2096890841", "2081227310"], include_attachments=False, limit=50, max_pages=1000 ) ``` We are able to get `when` field in metadata. However, if we reuqest pages by space ``` documents = loader.load( space_key = spaceName, include_attachments=False, limit=50, max_pages=1000 ) ``` The when field will not be in metadata. ### Expected behavior Is there any methods we can request pages by space and also get `when` field? This is really important for us. Thanks :)
Langchain ConfluenceLoader.load(): Get "when" field in metadata
https://api.github.com/repos/langchain-ai/langchain/issues/12812/comments
4
2023-11-03T00:26:16Z
2024-05-14T16:06:46Z
https://github.com/langchain-ai/langchain/issues/12812
1,975,246,193
12,812
[ "langchain-ai", "langchain" ]
### Feature request Example of what NOT to do: https://github.com/langchain-ai/langchain/issues/12507 Langchain, PLEASE stop doing this. PLEASE make all your updates backwards compatible. As it is, if you keep making changes like moving modules around, existing scripts break with every new update of Langchain. ### Motivation It is so frustrating to have to try and guess which version of Langchain will actually work with my code. ### Your contribution Just stop moving modules around. You cause way more harm than good when you do that, because tutorials for Langchain have to be rewritten and new versions of Langchain are not compatible with Langchain code written just a few months ago.
PLEASE make all subsequent versions of Langchain backwards compatible!!!
https://api.github.com/repos/langchain-ai/langchain/issues/12803/comments
3
2023-11-02T21:07:39Z
2024-02-09T16:09:18Z
https://github.com/langchain-ai/langchain/issues/12803
1,975,037,118
12,803
[ "langchain-ai", "langchain" ]
### Feature request The new cohere V3 embed endpoints have a new required parameter - input_type. Langchain currently doesn't support this parameter https://txt.cohere.com/introducing-embed-v3/ ### Motivation Being able to use the newest multilingual embedding capabilities is something users who are developing an international product would find very important ### Your contribution Documentation!
Add support for Cohere embed V3
https://api.github.com/repos/langchain-ai/langchain/issues/12793/comments
10
2023-11-02T17:15:12Z
2023-11-07T14:22:53Z
https://github.com/langchain-ai/langchain/issues/12793
1,974,708,436
12,793
[ "langchain-ai", "langchain" ]
### System Info Sample Snippet: ``` from langchain.chains.question_answering import load_qa_chain chain = load_qa_chain(llm, chain_type = "stuff") query = "decentralized identity" docs = docsearch.similarity_search(query) text = chain({"input_documents": docs, "question": query, "verbose": True}) ``` Error: ``` ValueError: Error raised by bedrock service: An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: 2 schema violations found, please reformat your input and try again. ``` ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [X] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ``` from langchain.llms.bedrock import Bedrock from langchain.embeddings import BedrockEmbeddings modelId = 'cohere.command-text-v14' bedrock_runtime = boto3.client(service_name='bedrock-runtime', region_name='us-east-1') llm = Bedrock(model_id=modelId, client=bedrock_runtime ) docs = read_and_split_docs(data_directory) bedrock_embeddings = BedrockEmbeddings(model_id="amazon.titan-embed-text-v1", client=bedrock_runtime) docsearch = Pinecone.from_texts( [t.page_content for t in docs], bedrock_embeddings, index_name=index_name ) from langchain.chains.question_answering import load_qa_chain chain = load_qa_chain(llm, chain_type = "stuff") query = "Human: decentralized identity. Assistant:" docs = docsearch.similarity_search(query) text = chain({"input_documents": docs, "question": query, "verbose": True}) ``` ### Expected behavior return some response
Issue: Amazon Bedrock Cohere Command LLM - Malformed input request: 2 schema violations found
https://api.github.com/repos/langchain-ai/langchain/issues/12790/comments
4
2023-11-02T16:06:47Z
2024-02-12T16:08:43Z
https://github.com/langchain-ai/langchain/issues/12790
1,974,583,805
12,790
[ "langchain-ai", "langchain" ]
when i used vocab_only=True for tokenize and add documents to opensearch vectors store, facing the following issue. could you please help me to fix, GGML_ASSERT: C:\Users\pip-install-vabntc\project\llama-cpp-python\vendor\llama.cpp\llama.cpp:4032: !!kv_self.ctx
GGML_ASSERT when using LlamaCppEmbeddings using langchain with quantized Llama 7B chat model
https://api.github.com/repos/langchain-ai/langchain/issues/12788/comments
4
2023-11-02T15:23:06Z
2023-11-03T04:00:11Z
https://github.com/langchain-ai/langchain/issues/12788
1,974,495,685
12,788
[ "langchain-ai", "langchain" ]
### System Info Version 0.0.328, macOS, Python 3.11.5 In [_convert_website_search_response() ](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/retrievers/google_vertex_ai_search.py#L120-L154) of [langchain.retrievers.google_vertex_ai_search](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/retrievers/google_vertex_ai_search.py), if no documents are found it will try and print: ``` print( f"No {chunk_type} could be found.\n" "Make sure that your data store is using Advanced Website Indexing.\n" "https://cloud.google.com/generative-ai-app-builder/docs/about-advanced-features#advanced-website-indexing" # noqa: E501 ) ``` However, the `chunk_type` variable is defined only if documents have been found, and is therefore unbound, leading to exception and crash. ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Any query that will fail to produce documents at all. ### Expected behavior The variable should be bound so that the exception is avoided.
UnboundLocalError in langchain.retrievers.google_vertex_ai_search
https://api.github.com/repos/langchain-ai/langchain/issues/12780/comments
5
2023-11-02T13:07:25Z
2024-02-05T22:55:14Z
https://github.com/langchain-ai/langchain/issues/12780
1,974,212,272
12,780
[ "langchain-ai", "langchain" ]
### Feature request WebResearchRetriever is a really great way to build a RAG based solution on public data. The challenge with using it in production is two things: 1. WebResearchRetriever contains a field called url_database and its an in memory python list, it would be good to provide some sort of alternative (maybe a memory based backend). 2. Documents on the web get updated, so some sort of staleness after the google search to reload and reingest the document again would be very great. (i.e expire the url from the database after some time delta, check if the url is already in the vectorstore, purge the docs, then regingest the site). Suggestion: add the following fields to WebResearchRetriever: 1. url_seen_ttl: TimeDelta 2. url_database_backend: MemoryBackend (some memory object in langchain that supports ttl or the ability to save a last lived field 3. purge_already_existing_documents: bool I think the above should be optional to avoid adding more latency for purging documents to avoid performance regressions. Vectorstore abstraction doesnt also provide a simple way to filter by metadata unsure what to do there. ### Motivation I am trying to make a WebResearchRetriever on public technical documentation and it gets updated every sprint release cycle, thus having something that is long living in a vectordb does not meet the requirements. Those two specific asks will help me use the out of the box functionality in langchain rather than overriding the baseretriever an making my own custom websearchretriever with memory. ### Your contribution I can help with a PR if it makes sense to have in langchain, otherwise I will take this as not something the community wants which is fair, I have a good sense of how to implement it for my own use case.
WebResearchRetriever enhancement with Memory and Reingestion of Documents
https://api.github.com/repos/langchain-ai/langchain/issues/12776/comments
2
2023-11-02T12:35:11Z
2024-02-08T16:10:20Z
https://github.com/langchain-ai/langchain/issues/12776
1,974,157,607
12,776
[ "langchain-ai", "langchain" ]
### System Info linux: 6.5.0-asahi-15-1-edge-ARCH python=3.11.5 langchain=0.0.327 sentence-transformers=2.2.2 ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [X] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction The followig code simply causes the script to crash with a core dump: `zsh: segmentation fault (core dumped) python3 bge.py`. Note that I have no trouble downloading the model when this script runs for the first time. Also, this works as expected on my x86 machines. ``` from langchain.embeddings import HuggingFaceBgeEmbeddings def embed(query): model_name = "BAAI/bge-base-en-v1.5" encode_kwargs = {'normalize_embeddings': True} # set True to compute cosine similarity bge_model = HuggingFaceBgeEmbeddings( model_name=model_name, model_kwargs={'device': 'cpu'}, encode_kwargs=encode_kwargs ) vector = bge_model.embed_query(query) print(vector) def main(): embed("Hello there.") if __name__ == "__main__": main() ``` ### Expected behavior This script should simply print a list of floating point numbers, i.e., the result of the embedding.
Core dump with Hugginface Embedding on aarch64 (M1 macbook)
https://api.github.com/repos/langchain-ai/langchain/issues/12775/comments
14
2023-11-02T11:51:02Z
2024-02-18T16:06:42Z
https://github.com/langchain-ai/langchain/issues/12775
1,974,087,849
12,775
[ "langchain-ai", "langchain" ]
### Feature request **Status Quo** Currently, the [MathpixPDFLoader](https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html#MathpixPDFLoader) sets its data property as follows: ``` @property def data(self) -> dict: options = {"conversion_formats": {self.processed_file_format: True}} return {"options_json": json.dumps(options)} ``` However, there are a variety of additional useful parameters that can be defined in the MathPix API calls: https://docs.mathpix.com/#request-parameters-6 For instance, this includes `enable_tables_fallback`, `numbers_default_to_math`, `enable_spell_check` etc. It would be great if these parameters could be specified as keyword arguments directly in the MathpixPDFLoader. ### Motivation For instance, tables do not always get parsed properly in PDFs and therefore in some cases it can make sense to set enable_tables_fallback=True. ### Your contribution TBD
Add option to set request parameters for MathpixPDFLoader
https://api.github.com/repos/langchain-ai/langchain/issues/12773/comments
3
2023-11-02T10:29:26Z
2024-02-01T19:02:45Z
https://github.com/langchain-ai/langchain/issues/12773
1,973,949,972
12,773
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. The error {'error': [{'message': "'id' is a reserved property name, no such prop with name 'id' found in class 'LangChain_14ee2519c3154dcb9ea3f47a8967d0e8' in the schema. Check your schema files for which properties in this class are available"}]} loader = ConfluenceLoader( url="URL", username="USERNAME", api_key="API_KEY") documents = loader.load(space_key="SPACE_KEY", include_attachments=True, limit=150) text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=0) documents = text_splitter.split_documents(documents) db = Weaviate.from_documents(documents, embeddings, client=client, by_text=False) chatbot = RetrievalQA.from_chain_type( llm=llm, chain_type="stuff", retriever=db.as_retriever(search_type="similarity",search_kwargs={"k": 1}), ) prompt = PromptTemplate(template=template, input_variables=["query"]) import sys while True: message=input("prompt: ") if message=='exit': print('Exiting') sys.exit() if message=='': continue response = chatbot.run(prompt.format(query=message)) ### Suggestion: _No response_
Issue: Schema error when ingesting documents
https://api.github.com/repos/langchain-ai/langchain/issues/12772/comments
2
2023-11-02T10:19:42Z
2024-02-09T16:09:28Z
https://github.com/langchain-ai/langchain/issues/12772
1,973,933,503
12,772
[ "langchain-ai", "langchain" ]
### System Info Running langchain in Nextjs app ``` "langchain": "^0.0.175", "next": "^13.5.2", "react": "18.2.0", ``` ### Who can help? @eyurtsev ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [X] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction I'm using the YoutubeLoader as described in the docs. The YoutubeLoader is part of a route handler in my NextJs application. ``` // in youtube service export async function getYoutubeTranscript(youtubeUrl: string) { const loader = YoutubeLoader.createFromUrl(youtubeUrl, { language: 'en', addVideoInfo: true, }) const docs = await loader.load() return docs .map((doc) => doc.pageContent) .join(' ') .replaceAll('\n', ' ') } ``` ``` // in route handler const transcript = await getYoutubeTranscript(link) ``` When using the route, I get an error because of a missing dependency - on my machine the route still works though. ![image](https://github.com/langchain-ai/langchain/assets/113305699/0890279e-f741-408a-9cb1-7e6cbc49c878) Manually installing canvas via `npm i canvas` fixes the issue, but when I deploy to vercel, the function exceeds the maximum size limit of 50 MB compressed, because the canvas package is 45 MB compressed... Not manually installing the dependency causes the route on Vercel to always return a 405 because of the missing dependency: ![image](https://github.com/langchain-ai/langchain/assets/113305699/bf1b95bf-4f99-4ceb-8e6f-740f14346cd3) I realize that this is not caused by the YoutubeLoader itself, but still hoping for any pointers or ideas how to fix this. ### Expected behavior YoutubeLoader works without throwing a 'module not found' error
YoutubeLoader throws 'module not found' error
https://api.github.com/repos/langchain-ai/langchain/issues/12771/comments
4
2023-11-02T10:15:03Z
2024-02-12T16:08:54Z
https://github.com/langchain-ai/langchain/issues/12771
1,973,925,566
12,771
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. When using FAISS vector store, how can I get the size of vector store? For example, I used FAISS.load_local(path, embeddings) to load a vector store, how to get the size of the loaded vector store? Which should be the total number of documents in it. ### Suggestion: _No response_
Issue: When using FAISS vector store, how can I get the size of vector store
https://api.github.com/repos/langchain-ai/langchain/issues/12767/comments
5
2023-11-02T07:38:15Z
2024-03-21T04:37:09Z
https://github.com/langchain-ai/langchain/issues/12767
1,973,677,488
12,767
[ "langchain-ai", "langchain" ]
### System Info Langchain == 0.0.327 sqlite3 Here's how the setup is done Entity memory ``` memory = ConversationEntityMemory( llm=llm, input_key='question', entity_store=store, chat_history_key='chat_history', return_messages=True ) ``` Entity store ``` store = SQLiteEntityStore( session_id=f'session_{name}', db_file=os.path.abspath('storage/db/chat_history.sqlite3'), table_name='chat_history' ) ``` It doesn't store any chat history to the sqlite database. Ofcourse a table for each conversation id is getting created and it does store only one row i.e. the summary of the conversation. But nothing else getting stored. I am using ```RetrievalQA``` as well as ```ConversationalRetrievalChain``` and it doesn't work with either of them ``` chain = RetrievalQA.from_chain_type( llm=llm, retriever=vectordb, // chroma db is used and works properly chain_type_kwargs={ "prompt": QUERY_PROMPT, "memory": memory, "verbose": False }, # memory=memory, // doesnt work here verbose=False ) ``` or ``` chain = ConversationalRetrievalChain.from_llm( retriever=vectordb, llm=llm, memory=memory ) ``` LLM is as provided ``` llm = ChatOpenAI(...) ``` ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [X] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction As I have checked the chat_history.py script, found out that the particular method is not implemented till now File path ``` .venv/lib/python3.11/site-packages/langchain/schema/chat_history.py ``` Method details (line 56-63) ``` @abstractmethod def add_message(self, message: BaseMessage) -> None: """Add a Message object to the store. Args: message: A BaseMessage object to store. """ raise NotImplementedError() ``` I think this method is responsible for storing the chat history to the persistent database ### Expected behavior The code should save the chat_history (prompt + response) to the sqlite database after each prompt.
ConversationEntityMemory + SQLiteEntityStore doesn't store chat_history to the database at all
https://api.github.com/repos/langchain-ai/langchain/issues/12766/comments
2
2023-11-02T07:34:53Z
2024-02-08T16:10:36Z
https://github.com/langchain-ai/langchain/issues/12766
1,973,673,398
12,766
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. In create_Sql_agent, when the agent is querying a table schema with partition field, it nevers adds parition and the program goes wrong, how to let the agent add partition field everytime it queries a table schema? Many thanks. ### Suggestion: _No response_
create_sql_agent checks schema of a table with partiton field always goes wrong
https://api.github.com/repos/langchain-ai/langchain/issues/12765/comments
2
2023-11-02T06:38:16Z
2024-02-08T16:10:40Z
https://github.com/langchain-ai/langchain/issues/12765
1,973,604,467
12,765
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I tried to use webscraping by using langchain and used the async chromium loader as per the lanchain documentation but I was getting error asyncio.run() error so I made some chnages that i found on web but its still not working . below is the code: import asyncio import playwright from langchain.document_loaders import AsyncChromiumLoader from langchain.document_transformers import BeautifulSoupTransformer import nest_asyncio nest_asyncio.apply() async def main(): # Create an instance of AsyncChromiumLoader with a list of URLs urls = ["https://www.hdfcbank.com/personal/borrow/popular-loans/personal-loan/eligibility"] # Replace with your desired URLs loader = AsyncChromiumLoader(urls) # Load the URLs html = await loader.load() # Print the HTML content for url, content in html.items(): print(f"URL: {url}\nHTML Content: {content}\n") if __name__ == "__main__": asyncio.run(main()) ### Suggestion: _No response_
Issue: getting not implemented error when using async chromium loader
https://api.github.com/repos/langchain-ai/langchain/issues/12763/comments
7
2023-11-02T04:34:54Z
2024-07-06T16:05:28Z
https://github.com/langchain-ai/langchain/issues/12763
1,973,488,881
12,763
[ "langchain-ai", "langchain" ]
### Feature request DPP (Determinantal Point Process) retriever for retrieve examples. ### Motivation DPPRetriever can obtain diverse examples. Therefore, I think DDP is needed in langchain. ### Your contribution NO
DPP retriever
https://api.github.com/repos/langchain-ai/langchain/issues/12761/comments
3
2023-11-02T03:08:49Z
2024-02-20T16:07:41Z
https://github.com/langchain-ai/langchain/issues/12761
1,973,423,287
12,761
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I provide the agent a get_date function as a tool,but when I ask the agent what is today's date, the agent provide the action and action input, but instead of executing it, it directly finished the chain。 ![image](https://github.com/langchain-ai/langchain/assets/149214596/737293ae-ef41-4c66-aef2-fe1267217c37) ![image](https://github.com/langchain-ai/langchain/assets/149214596/e1644d5e-9e52-4322-904a-b332f81d32c8) ![image](https://github.com/langchain-ai/langchain/assets/149214596/eaadad2c-0bc9-43ef-8b5e-d5a12626a3ea) ### Suggestion: _No response_
Issue: Why did the agent provide the action and action input, but instead of executing it, it directly finished the chain
https://api.github.com/repos/langchain-ai/langchain/issues/12759/comments
2
2023-11-02T02:24:40Z
2024-02-08T16:10:45Z
https://github.com/langchain-ai/langchain/issues/12759
1,973,385,322
12,759
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I created an analytic chatbot using Langchain (with tools and agents) for the backend and Streamlit for the frontend. It works, but for some users' questions, it takes too much time to output anything. If I look at the output of intermediate steps, I can see that the chatbot tries to print out all relevant rows in the output. For example, below, the chatbot found 40 relevant comments and printed them out in one of its intermediate steps one by one (it takes up to one minute). [![enter image description here][1]][1] Code for chatbot: ``` def load_data(path): return pd.read_csv(path) if st.sidebar.button('Use Data'): # If button is clicked, load the EDW.csv file st.session_state["df"] = load_data('./data/EDW.csv') uploaded_file = st.sidebar.file_uploader("Choose a CSV file", type="csv") if "df" in st.session_state: msgs = StreamlitChatMessageHistory() memory = ConversationBufferWindowMemory(chat_memory=msgs, return_messages=True, k=5, memory_key="chat_history", output_key="output") if len(msgs.messages) == 0 or st.sidebar.button("Reset chat history"): msgs.clear() msgs.add_ai_message("How can I help you?") st.session_state.steps = {} avatars = {"human": "user", "ai": "assistant"} # Display a chat input widget if prompt := st.chat_input(placeholder=""): st.chat_message("user").write(prompt) llm = AzureChatOpenAI( deployment_name = "gpt-4", model_name = "gpt-4", openai_api_key = os.environ["OPENAI_API_KEY"], openai_api_version = os.environ["OPENAI_API_VERSION"], openai_api_base = os.environ["OPENAI_API_BASE"], temperature = 0, streaming=True ) max_number_of_rows = 40 agent_analytics_node = create_pandas_dataframe_agent( llm, st.session_state["df"], verbose=False, agent_type=AgentType.OPENAI_FUNCTIONS, reduce_k_below_max_tokens=True, # to not exceed token limit max_execution_time = 20, early_stopping_method="generate", # will generate a final answer after the max_execution_time has been surpassed # max_iterations=2, # to cap an agent at taking a certain number of steps ) tool_analytics_node = Tool( return_intermediate_steps=False, name='Analytics Node', func=agent_analytics_node.run, description=f''' This tool is useful when you need to answer questions about data stored in a pandas dataframe, referred to as 'df'. 'df' comprises the following columns: {st.session_state["df"].columns.to_list()}. Here is a sample of the data: {st.session_state["df"].head(5)}. When working with df, ensure not to output more than {max_number_of_rows} rows at once, either in intermediate steps or in the final answer. This is because df could contain too many rows, which could potentially overload memory, for example instead of `df[df['survey_comment'].str.contains('wet', na=False, case=False)]['survey_comment'].tolist()` use `df[df['survey_comment'].str.contains('wet', na=False, case=False)]['survey_comment'].head({max_number_of_rows}).tolist()`. ''' ) tools = [tool_analytics_node] chat_agent = ConversationalChatAgent.from_llm_and_tools(llm=llm, tools=tools, return_intermediate_steps=False) executor = AgentExecutor.from_agent_and_tools( agent=chat_agent, tools=tools, memory=memory, return_intermediate_steps=False, handle_parsing_errors=True, verbose=False, ) with st.chat_message("assistant"): st_cb = StreamlitCallbackHandler(st.container(), expand_new_thoughts=False) response = executor(prompt, callbacks=[st_cb]) st.write(response["output"]) ``` [1]: https://i.stack.imgur.com/xyaVZl.png ### Suggestion: My questions are: 1) Is there any way to speed up this process? 2) How can I disable the intermediate output of the chatbot? (I already put `return_intermediate_steps=False`, `verbose=False`, and `expand_new_thoughts=False`, but the chatbot still shows intermediate steps.)
Issue: analytic chatbot that's based on Langchain (with agents and tools) and Streamlit is too slow
https://api.github.com/repos/langchain-ai/langchain/issues/12758/comments
2
2023-11-02T01:05:08Z
2024-04-08T16:07:51Z
https://github.com/langchain-ai/langchain/issues/12758
1,973,327,167
12,758
[ "langchain-ai", "langchain" ]
### System Info Running with `langchain==0.0.327` on Fedora Linux and Windows. Finetuning with `gpt-3.5-turbo-16k-0613`. Language: `Python 3.10.11` ### Who can help? @hwchase17 @agola11 ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [X] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [X] Agents / Agent Executors - [ ] Tools / Toolkits - [x] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Hello, I have created a simple langchain agent with a Tool and with an LLM. However, the LLM passed into the agent actually points to my **finetuned** GPT instance. We notice that the output responses contain an accurate response, but repeated and separated by a newline. I have [fine-tuned on the sample prompts](https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset) from the official OpenAI documentation on making a sarcastic chatbot. Here is the JSONL file I used for fine tuning: https://pastebin.com/BDV0Tjyk. Here is my agent code: ``` llm = ChatOpenAI(temperature=0, model=<OUR_MODEL_ID>, streaming=False) tools = [ Tool.from_function( func=add_asdf, name="add_asdf", description="useful when someone asks to add asdf to a string.", ), ] agent_kwargs = { "system_message": SystemMessage( content="Marv is a factual chatbot that is also sarcastic." ), } agent = initialize_agent( tools, llm, agent=AgentType.OPENAI_FUNCTIONS, agent_kwargs=agent_kwargs, max_execution_time=90, early_stopping_method="generate", handle_parsing_errors=True, tags=[], ) result = agent.run("Where's the sahara desert located?") print(result) ``` Now this does seem to work correctly and use the fine tuned instance (as we can see the responses are definitely sarcastic), but we notice that in its response, the agent seems to be combining **the same response twice, but separated by a newline.** Output: ``` In North Africa. But who's keeping track of giant deserts anyway? In North Africa. But who's keeping track of giant deserts anyway? ``` Looking at the generations from the debug: ``` "generations": [ [ { "text": "In North Africa. But who's keeping track of giant deserts anyway?\nIn North Africa. But who's keeping track of giant deserts anyway?", "generation_info": { "finish_reason": "stop" }, "type": "ChatGeneration", "message": { "lc": 1, "type": "constructor", "id": [ "langchain", "schema", "messages", "AIMessage" ], "kwargs": { "content": "In North Africa. But who's keeping track of giant deserts anyway?\nIn North Africa. But who's keeping track of giant deserts anyway?", "additional_kwargs": {} } } } ] ] ``` Some important details: - We notice that we only execute the LLM _one_ time (i.e. there are no duplicate runs of the llm in the chain). - Our fine tuned instance works perfectly in the OpenAI playground, and with the OpenAI python library. **Hence, this seems to be a langchain-specific issue and nothing to do with our training data or fine tuning.** - The issue does not occur 100% of the time. Occasionally, only one response is returned. I am happy to provide more information on debug logs or anything about the fine-tuned model for replication. We'd love any information or nuances about using a fine-tuned instance with a Langchain agent, or guidance on what could be going wrong. Thanks! ### Expected behavior Only one response should be generated: ``` In North Africa. But who's keeping track of giant deserts anyway? ``` The response contains a copy of the response separated by a newline: ``` { "output": "In North Africa. But who's keeping track of giant deserts anyway?\nIn North Africa. But who's keeping track of giant deserts anyway?" } ```
Langchain Agent Duplicates Response Separated by "\n" with Finetuned LLM
https://api.github.com/repos/langchain-ai/langchain/issues/12752/comments
3
2023-11-01T23:15:52Z
2024-03-27T12:43:12Z
https://github.com/langchain-ai/langchain/issues/12752
1,973,243,397
12,752
[ "langchain-ai", "langchain" ]
### Feature request Template that show routing across N datastores ### Motivation Reasoning about [where to fetch information (https://python.langchain.com/docs/expression_language/how_to/routing) from a natural language query is important for retrieval across data sources. ### Your contribution Add template
[Extraction template] Query decomposition + routing
https://api.github.com/repos/langchain-ai/langchain/issues/12745/comments
2
2023-11-01T21:05:55Z
2024-02-07T16:09:43Z
https://github.com/langchain-ai/langchain/issues/12745
1,973,112,630
12,745
[ "langchain-ai", "langchain" ]
### Feature request Add template to simplify fine-tuning ### Motivation [LLM fine-tuning](https://blog.langchain.dev/using-langsmith-to-support-fine-tuning-of-open-source-llms/) can improve task-specific performance ### Your contribution Add template
[Fine tuning template] Fine-tune LLM
https://api.github.com/repos/langchain-ai/langchain/issues/12744/comments
1
2023-11-01T21:00:11Z
2024-02-07T16:09:48Z
https://github.com/langchain-ai/langchain/issues/12744
1,973,104,857
12,744
[ "langchain-ai", "langchain" ]
### Feature request Set up template to simplify fine-tuning of embedding models. ### Motivation [Fine-tuning](https://blog.langchain.dev/using-langsmith-to-support-fine-tuning-of-open-source-llms/) of embedding models can improve RAG. ### Your contribution Add template
[Fine tuning template] Fine-tune embedding model
https://api.github.com/repos/langchain-ai/langchain/issues/12743/comments
2
2023-11-01T20:57:07Z
2024-02-08T16:10:50Z
https://github.com/langchain-ai/langchain/issues/12743
1,973,100,842
12,743
[ "langchain-ai", "langchain" ]
### Feature request Given a runnable (e.g., RAG pipeline) automatically run eval against a given (public) dataset ### Motivation Made evaluation simple by abstracting w/ a template and passing in only a runnable. (Template can be called as RemoteRunnable.) Benchmark your runnable on an existing public LangSmith dataset. Will differ depending on the use-case / dataset of choice. ### Your contribution Add template
[Evaluation template] Runs evaluation against LangSmith (public) dataset
https://api.github.com/repos/langchain-ai/langchain/issues/12742/comments
1
2023-11-01T20:53:55Z
2024-02-07T16:09:58Z
https://github.com/langchain-ai/langchain/issues/12742
1,973,096,837
12,742
[ "langchain-ai", "langchain" ]
### Feature request Synthetic dataset generation and extraction (to JSON or similar) ### Motivation Datasets (for eval or fine-tuning) are challenging to generate. Some prompts have used LLMs to [generate](https://smith.langchain.com/hub/homanp/question-answer-pair?ref=blog.langchain.dev&organizationId=1fa8b1f4-fcb9-4072-9aa9-983e35ad61b8) them. ### Your contribution Add template
[Data generation template] Synthetic QA pairs from input document
https://api.github.com/repos/langchain-ai/langchain/issues/12741/comments
1
2023-11-01T20:40:08Z
2024-02-07T16:10:03Z
https://github.com/langchain-ai/langchain/issues/12741
1,973,076,333
12,741
[ "langchain-ai", "langchain" ]
### Feature request Summarization on audio content (podcasts, YT videos, lectures) would be useful. ### Motivation Prior work by [AssemblyAI](https://github.com/AssemblyAI/youtube-tutorials/blob/main/podcast-summary-app/podcasts.py) has focused on this. ### Your contribution Add template
[Summarization template] Audio
https://api.github.com/repos/langchain-ai/langchain/issues/12740/comments
5
2023-11-01T20:36:18Z
2024-06-18T09:12:29Z
https://github.com/langchain-ai/langchain/issues/12740
1,973,071,476
12,740
[ "langchain-ai", "langchain" ]
### Feature request Name Entity Recognition is the process of identifying and classifying named entities (like people, organizations, dates, and locations) in text. ### Motivation NER is useful in various areas: 1. Information Retrieval: Helps in improving the efficiency of search engines. For example, if someone searches for "Apple," understanding whether they mean the fruit or the tech company can be crucial. 2. Content Recommendation: For news or media agencies, knowing what entities are mentioned in articles can help in recommending related content to users. 3. Data Mining: For extracting structured information from unstructured datasets. 4. Question Answering: Helps chatbots and virtual assistants understand and respond to user queries more accurately. 5. Knowledge Graph Construction: Crucial for building structured databases of information extracted from text. ### Your contribution Add template
[Extraction template] NER
https://api.github.com/repos/langchain-ai/langchain/issues/12739/comments
2
2023-11-01T20:33:54Z
2024-03-08T16:46:59Z
https://github.com/langchain-ai/langchain/issues/12739
1,973,068,176
12,739
[ "langchain-ai", "langchain" ]
### Feature request Use oss LLM w/ agent (e.g., [Zephyr](https://huggingface.co/HuggingFaceH4/zephyr-7b-alpha)) ### Motivation See notes [here](https://blog.llamaindex.ai/dumber-llm-agents-need-more-constraints-and-better-tools-17a524c59e12), [here](https://betterprogramming.pub/exploring-react-agent-for-better-prompting-in-rag-pipeline-b231aae0ca7c), [here](https://www.pinecone.io/learn/series/langchain/langchain-agents/) on use-cases that admit well to oss LLM agents. ### Your contribution Add template
[Agent template] Local / oss agent
https://api.github.com/repos/langchain-ai/langchain/issues/12738/comments
1
2023-11-01T20:24:36Z
2024-02-07T16:10:08Z
https://github.com/langchain-ai/langchain/issues/12738
1,973,055,694
12,738
[ "langchain-ai", "langchain" ]
### Feature request SQL + semantic searching w/ pgvector ### Motivation Follow the format of [this cookbook](https://github.com/langchain-ai/langchain/pull/12365/files) to enable unified SQL + semantic search (on a column with embeddings). ### Your contribution Template
[Query construction template] Semantic + SQL with pgvector
https://api.github.com/repos/langchain-ai/langchain/issues/12737/comments
1
2023-11-01T20:16:56Z
2024-02-07T16:10:13Z
https://github.com/langchain-ai/langchain/issues/12737
1,973,045,358
12,737
[ "langchain-ai", "langchain" ]
### Feature request Extraction a structured (e.g., csv, pandas DF, etc) table from unstructured text ### Motivation LLMs can infer table structure from text input. A template that performs this and output a dataq (e.g., csv, pandas DF, etc) object would be useful. ### Your contribution Add template
[Extraction template] Tables from unstructured text
https://api.github.com/repos/langchain-ai/langchain/issues/12735/comments
1
2023-11-01T20:04:17Z
2024-02-07T16:10:17Z
https://github.com/langchain-ai/langchain/issues/12735
1,973,027,411
12,735
[ "langchain-ai", "langchain" ]
### Feature request Tagging using (local LLM or API) for categorizing support tickets ### Motivation Support ticket classification ### Your contribution Add template
[Tagging template] Support ticket classification
https://api.github.com/repos/langchain-ai/langchain/issues/12734/comments
2
2023-11-01T20:01:25Z
2024-03-17T16:05:07Z
https://github.com/langchain-ai/langchain/issues/12734
1,973,023,622
12,734
[ "langchain-ai", "langchain" ]
### Feature request Template that features multi-modal RAG ### Motivation * [Unstructured for document processing](https://github.com/langchain-ai/langchain/blob/master/cookbook/Semi_structured_and_multi_modal_RAG.ipynb) * Multimodal embeddings * Showcase vectorstore(s) that support img+text * Multi-modal LLM for answer synthesis ### Your contribution Multi-modal RAG
[RAG template] Multi-modal
https://api.github.com/repos/langchain-ai/langchain/issues/12732/comments
2
2023-11-01T19:47:42Z
2024-02-08T16:10:55Z
https://github.com/langchain-ai/langchain/issues/12732
1,973,001,832
12,732
[ "langchain-ai", "langchain" ]
I have made a Custom Prompt template using: ``` `class CustomPromptTemplate(BaseChatPromptTemplate): # The template to use template: str # The list of tools available tools: List[Tool] def format_messages(self, **kwargs) -> str: # Get the intermediate steps (AgentAction, Observation tuples) # Format them in a particular way intermediate_steps = kwargs.pop("intermediate_steps") thoughts = "" for action, observation in intermediate_steps: thoughts += action.log thoughts += f"\nObservation: {observation}\nThought: " # Set the agent_scratchpad variable to that value kwargs["agent_scratchpad"] = thoughts # Create a tools variable from the list of tools provided kwargs["tools"] = "\n".join([f"{tool.name}: {tool.description}" for tool in self.tools]) # Create a list of tool names for the tools provided kwargs["tool_names"] = ", ".join([tool.name for tool in self.tools]) kwargs["df_head"]=df.head() formatted = self.template.format(**kwargs) return [HumanMessage(content=formatted)]` ``` Calling this: ``` prompt = CustomPromptTemplate( template=template, tools=tools, input_variables=["input","intermediate_steps","df_head","history"] ) ``` I have also created custom agent: ``` llm_chain = LLMChain(llm=llm, prompt=prompt) tool_names = [tool.name for tool in tools] agent = LLMSingleActionAgent( llm_chain=llm_chain, output_parser=output_parser, stop=["\nObservation:"], allowed_tools=tool_names ) ``` Executing agent: ``` from langchain.memory import ConversationBufferWindowMemory memory=ConversationBufferWindowMemory(memory_key='chat_history', return_messages=True, output_key='answer',k=2) agent_executor_new = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True,memory=memory) ``` Running this with (**As per documentation**): ``` agent_executor_new.run({'input':"Generate top 3 insights on sales in Q4 and compare it against other quarters?"}) ``` Results in this error: ``` `File ~/anaconda3/lib/python3.10/site-packages/langchain/chains/base.py:443, in Chain.prep_inputs(self, inputs) 441 external_context = self.memory.load_memory_variables(inputs) 442 inputs = dict(inputs, **external_context) --> 443 self._validate_inputs(inputs) 444 return inputs File ~/anaconda3/lib/python3.10/site-packages/langchain/chains/base.py:195, in Chain._validate_inputs(self, inputs) 193 missing_keys = set(self.input_keys).difference(inputs) 194 if missing_keys: --> 195 raise ValueError(f"Missing some input keys: {missing_keys}") ValueError: Missing some input keys: {'df_head', 'history'}` ``` When I supply the missing input values: ``` agent_executor_new.run({'input':"Generate top 3 insights on sales in Q4 and compare it against other quarters?",'df_head':df.head(),'history':memory})` ``` It results in this error: ``` File ~/anaconda3/lib/python3.10/site-packages/langchain/memory/chat_memory.py:35, in BaseChatMemory.save_context(self, inputs, outputs) > 33 def save_context(self, inputs: Dict[str, Any], outputs: Dict[str, str]) -> None: > 34 """Save context from this conversation to buffer.""" > ---> 35 input_str, output_str = self._get_input_output(inputs, outputs) > 36 self.chat_memory.add_user_message(input_str) > 37 self.chat_memory.add_ai_message(output_str) > > File ~/anaconda3/lib/python3.10/site-packages/langchain/memory/chat_memory.py:22, in BaseChatMemory._get_input_output(self, inputs, outputs) > 18 def _get_input_output( > 19 self, inputs: Dict[str, Any], outputs: Dict[str, str] > 20 ) -> Tuple[str, str]: > 21 if self.input_key is None: > ---> 22 prompt_input_key = get_prompt_input_key(inputs, self.memory_variables) > 23 else: > 24 prompt_input_key = self.input_key > > File ~/anaconda3/lib/python3.10/site-packages/langchain/memory/utils.py:19, in get_prompt_input_key(inputs, memory_variables) > 17 prompt_input_keys = list(set(inputs).difference(memory_variables + ["stop"])) > 18 if len(prompt_input_keys) != 1: > ---> 19 raise ValueError(f"One input key expected got {prompt_input_keys}") > 20 return prompt_input_keys[0] > ValueError: One input key expected got ['df_head', 'history', 'input']` ``` Please help!!
Adding memory with customprompt and Custom agent is resulting in error
https://api.github.com/repos/langchain-ai/langchain/issues/12730/comments
2
2023-11-01T19:22:39Z
2024-02-07T16:10:27Z
https://github.com/langchain-ai/langchain/issues/12730
1,972,961,377
12,730
[ "langchain-ai", "langchain" ]
I have made a Custom Prompt template using:
Error after adding memory to custom agent and prompt template
https://api.github.com/repos/langchain-ai/langchain/issues/12728/comments
1
2023-11-01T19:00:22Z
2023-11-01T19:29:19Z
https://github.com/langchain-ai/langchain/issues/12728
1,972,930,121
12,728
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I am using the STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION agent and I am trying to implement tools that take varying number of arguments (e.g. tool1 takes a single argument and tool2 takes 3 arguments). I am using arg_schema to define the arguments and their types. I am wondering how can I return a message to the agent in case the input arguments do not satisfy the arg_schema without erroring out the service. My objective with this is that the agent will try again after modifying the "Thought". How do I do that? ### Suggestion: _No response_
Issue: How to implement validation on number of arguments in tools?
https://api.github.com/repos/langchain-ai/langchain/issues/12721/comments
2
2023-11-01T16:36:12Z
2024-02-07T16:10:34Z
https://github.com/langchain-ai/langchain/issues/12721
1,972,713,528
12,721
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. Agent calls get_date_time custom tool but does not actually use it. The following was its output Action: Amadeus\_flight\_offers\_search, { "originLocationCode": "LA", "destinationLocationCode": "NYC", "departureDate": "$(get\_date\_time)", "returnDate": "$(get\_date\_time)", "adults": 1, "children": 0, "max": 1, "nonStop": false, "maxPrice": 0, "currencyCode": "USD", "travelClass": "ECONOMY" } Observation: The flight offers search has been completed. Please review the results for your desired flight. ``` # Create Amadeus toolkit toolkit = AmadeusToolkit() tools = toolkit.get_tools() # Set up the LLMChain, passing in memory template = """You are an AI chatbot having a conversation with a human. {history} Human: {human_input} AI: """ prompt = PromptTemplate(input_variables=["history", "human_input"], template=template) llm = ChatOllama(model="mistral:7b-instruct", verbose=True, callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])) # Define custom tool datetime_tool = Tool( name="get_date_time", func=lambda x: datetime.now().isoformat(), # '%Y-%m-%dT%H:%M:%S' description="Use the system's default time zone to return the current date and time", ) # Add the new tool to tool list tools.append(datetime_tool) system_message = SystemMessage(content=""" You are a helpful, respectful and honest travel agent. ... """) agent = initialize_agent( tools=tools, llm=llm, verbose=True, early_stopping_method="generate", memory=memory, agent_kwargs={"system_message": system_message, "extra_prompt_messages": [MessagesPlaceholder(variable_name="memory")]}, agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, ) ``` ### Suggestion: _No response_
Issue: Agent doesn't actually utilize custom tool
https://api.github.com/repos/langchain-ai/langchain/issues/12720/comments
2
2023-11-01T15:59:01Z
2024-02-07T16:10:37Z
https://github.com/langchain-ai/langchain/issues/12720
1,972,651,132
12,720
[ "langchain-ai", "langchain" ]
### System Info Ubuntu 22.04 python = "3.11" langchain = "0.0.320" openai = "0.28.1" ### Who can help? https://github.com/hwchase17 https://github.com/agola11 ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [X] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Surprisingly, this very basic call: ``` def testing_langchain_interface(self): openai_key = os.getenv('OPENAI_API_KEY') text = "This is the text to be embedded" result = OpenAIEmbeddings(openai_api_key=openai_key).embed_documents([text]) ``` Results in this error: ``` [2023-11-01 10:10:02] [WARNING] TESTING - Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 400 Bad Request'))': /v1/embeddings [2023-11-01 10:10:02] [WARNING] TESTING - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 400 Bad Request'))': /v1/embeddings [2023-11-01 10:10:02] [WARNING] TESTING - Retrying langchain.embeddings.openai.embed_with_retry.<locals>._embed_with_retry in 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/embeddings (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 400 Bad Request'))). ``` Kwargs values at call site in _embed_with_retry: ``` {'input': [[2028, 374, 279, 1495, 311, 387, 23711]], 'model': 'text-embedding-ada-002', 'request_timeout': None, 'headers': None, 'api_key': '***', , 'organization': '', 'api_base': '', 'api_type': 'openai', 'api_version': ''} ``` While this code: ``` def testing_openai_interface(self): openai.api_key = os.getenv('OPENAI_API_KEY') model = "text-embedding-ada-002" text = "This is the text to be embedded" result = openai.Embedding.create(input=text, model=model, api_type='openai') ``` executes correctly and connects to the OpenAI API. ### Expected behavior OpenAIEmbeddings should connect without error to OpenAI api.
OpenAIEmbeddings fails to connect
https://api.github.com/repos/langchain-ai/langchain/issues/12714/comments
4
2023-11-01T14:36:00Z
2024-07-02T04:39:34Z
https://github.com/langchain-ai/langchain/issues/12714
1,972,502,865
12,714
[ "langchain-ai", "langchain" ]
### System Info langchain==0.0.327, MacOS, Python 3.11.6 ### Who can help? @netseye ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [X] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction I'm trying to use OpenAIEmbeddings with Chroma ``` embedding_function = OpenAIEmbeddings( openai_api_type="azure", deployment="text-embedding-ada-002", model="text-embedding-ada-002", openai_api_base="https://something.openai.azure.com/", openai_api_key=os.getenv("AZURE_OPENAI_KEY"), ) vector_store = Chroma.from_documents( docs, embedding_function, persist_directory=os.getenv("CHROMA_DB") ) ``` and I'm getting `Retrying langchain.embeddings.openai.embed_with_retry.<locals>._embed_with_retry in 10.0 seconds as it raised RateLimitError: Requests to the Embeddings_Create Operation under Azure OpenAI API version 2022-12-01 have exceeded call rate limit of your current OpenAI S0 pricing tier. Please retry after 20 seconds. Please go here: https://aka.ms/oai/quotaincrease if you would like to further increase the default rate limit..` I tried to set request_timeout to different values, but it seems to be ignored, because behaviour doesn't change, I still see this requests to OpenAI endpoint with the same frequency. ### Expected behavior I would expect having this timeout invocated when there is an Exception from OpenAI is caught.
OpenAIEmbeddings timeout parameter doesn't work
https://api.github.com/repos/langchain-ai/langchain/issues/12712/comments
2
2023-11-01T13:51:58Z
2024-02-11T16:07:42Z
https://github.com/langchain-ai/langchain/issues/12712
1,972,423,280
12,712
[ "langchain-ai", "langchain" ]
### System Info ``` langchain==0.0.315 pymilvus==2.3.0 Python 3.11.5 ``` ### Who can help? @hwchase17 @agola11 ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [x] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Minimal code to reproduce: ```python from langchain.embeddings.base import Embeddings from langchain.vectorstores import Milvus class DummyEmbeddings(Embeddings): def embed_documents(): return [[]] def embed_query(self): return [] if __name__ == "__main__": Milvus( embedding_function=DummyEmbeddings(), collection_name="foo", connection_args={ "uri": "http://localhost:19530", "user": "", "password": "", "secure": False, }, ) ``` Running the code results in an exception coming from the [milvus adapter](https://github.com/langchain-ai/langchain/blob/5ae51a8a85d1a37ea98afeaf639a72ac74a50523/libs/langchain/langchain/vectorstores/milvus.py#L191) ```sh > python -m milvus_reproduce Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "milvus_reproduce.py", line 14, in <module> Milvus( File ".venv/lib/python3.11/site-packages/langchain/vectorstores/milvus.py", line 155, in __init__ self.alias = self._create_connection_alias(connection_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".venv/lib/python3.11/site-packages/langchain/vectorstores/milvus.py", line 191, in _create_connection_alias given_address = uri.split("https://")[1] ~~~~~~~~~~~~~~~~~~~~~^^^ IndexError: list index out of range ``` ### Expected behavior The milvus adapter must allow for http uris. The exception happens because the adapter assumes the uri always starts with `https://`. Instead one should parse url and get the netloc: ```python from urllib import parse given_address = parse.urlparse(uri).netloc ``` Similar to what `pymilvus` bindings [do](https://github.com/milvus-io/pymilvus/blob/master/pymilvus/orm/connections.py#L338).
Milvus wrapper doesn't support http URI
https://api.github.com/repos/langchain-ai/langchain/issues/12710/comments
2
2023-11-01T13:05:41Z
2024-02-07T16:10:47Z
https://github.com/langchain-ai/langchain/issues/12710
1,972,344,326
12,710
[ "langchain-ai", "langchain" ]
### System Info I encountered an issue while using the create_pandas_df_agent function in LangChain to process data. When I asked a question about the data, an exception was thrown with the message “I now know the final answer”. This phenomenon is not inevitable model is "gpt-3.5-turbo" ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [X] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [X] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction `self.llm = AzureChatOpenAI( openai_api_base=self.api_base, openai_api_version=self.api_version, deployment_name=self.deployment_name, openai_api_key=self.api_token, openai_api_type="azure", max_tokens = self.max_tokens, model_name = self.model_name, ) self._dfagent = create_pandas_df_agent(self._llm.llm,df,verbose=True) # tempt is a user problem result = Result() try: res = self._dfagent.run(tempt) result.content = res result.status = 'success' except Exception as exception: result.error = ( "Unfortunately, I was not able to answer your question, " "because of the following error:\n" f"\n{exception}\n" ) result.status = 'error' return result` ### Expected behavior I hope it returns the results normally
Exception “I now know the final answer” thrown when using “create_pandas_df_agent”
https://api.github.com/repos/langchain-ai/langchain/issues/12709/comments
4
2023-11-01T12:23:00Z
2024-02-12T16:08:58Z
https://github.com/langchain-ai/langchain/issues/12709
1,972,275,338
12,709
[ "langchain-ai", "langchain" ]
### System Info LangChain version: langchain==0.0.327 Python version: Python 3.11.4 System: Windows 11 x64 ### Who can help? @hwchase17 @agola11 ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Here is my retriever- ```py retriever = vectorstore.as_retriever( search_type="similarity_score_threshold", search_kwargs={ "score_threshold": 0.8, "k": 5, "filter": {"source": {"$in": self.config.get("author")}}, } ) ``` and chain- ```py chain = ConversationalRetrievalChain.from_llm( llm=chat_model, retriever=retriever, memory=memory, chain_type="stuff", combine_docs_chain_kwargs={"prompt": prompt}, get_chat_history=lambda h: h, condense_question_llm=ChatOpenAI(temperature=0.04), verbose=True, ) ``` In retriever, `similarity_score_threshold` is not working as expected. For now, I am using `0.8` as `score_threshold` for retriever. I am not getting any Documents in return. However, this piece of code is giving me the expected Documents. Note that I am not specifying any score during similarity search. I am checking the score of each Document manually with 0.8 as a threshold. ```py vectorstore.similarity_search_with_score( query=query, k=5, filter={"source": {"$in": self.config.get("author")}}, namespace="my_namespace", ) ``` ### Expected behavior The below piece of codes should return the same Documents from Pinecone. ```py retriever = vectorstore.as_retriever( search_type="similarity_score_threshold", search_kwargs={ "score_threshold": 0.8, "k": 5, "filter": {"source": {"$in": self.config.get("author")}}, } ) ``` ```py vectorstore.similarity_search_with_score( query=query, k=5, filter={"source": {"$in": self.config.get("author")}}, namespace="my_namespace", ) ```
similarity_score_threshold not working as expected with ConversationalRetrievalChain
https://api.github.com/repos/langchain-ai/langchain/issues/12707/comments
3
2023-11-01T11:26:58Z
2024-02-10T16:07:52Z
https://github.com/langchain-ai/langchain/issues/12707
1,972,187,745
12,707
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I am using the ConversationBufferWindowMemory class and I would like to have different memories for different users. So that each user has its individual memory. memory = ConversationBufferWindowMemory(k=3, memory_key="chat_history", return_messages=True) qa = ConversationalRetrievalChain.from_llm(llm_model, vector_store.as_retriever(search_kwargs={'k': 2}), memory=memory, ### Suggestion: _No response_
Issue: How can I utilize different histories for different users
https://api.github.com/repos/langchain-ai/langchain/issues/12706/comments
5
2023-11-01T11:12:01Z
2024-03-18T16:06:09Z
https://github.com/langchain-ai/langchain/issues/12706
1,972,166,699
12,706
[ "langchain-ai", "langchain" ]
### System Info Langchain 0.0.327 Python 3.10 ### Who can help? @hwchase17 or @eyurtsev are contributors of CerebriumAI based on Github history. ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Reference: https://docs.cerebrium.ai/cerebrium/cortex/examples/langchain As a result it always returns ```Could not import cerebrium python package. Please install it with `pip install cerebrium`.``` as part of the following code ``` from cerebrium import model_api_request except ImportError: raise ValueError( "Could not import cerebrium python package. " "Please install it with `pip install cerebrium`." ) ``` ### Expected behavior Returns value from the Cerebrium AI instance.
CerebriumAI model_api_request deprecation
https://api.github.com/repos/langchain-ai/langchain/issues/12705/comments
2
2023-11-01T10:57:49Z
2024-02-01T18:49:21Z
https://github.com/langchain-ai/langchain/issues/12705
1,972,145,406
12,705
[ "langchain-ai", "langchain" ]
### System Info Langchain version 0.0.327, WSL ubuntu 22, python version 3.10.3 As you can see in the code below the UnstructuredFileLoader does not work and can not load the file. ``` from langchain.document_loaders import UnstructuredFileLoader from langchain.document_loaders import UnstructuredFileIOLoader # UnstructuredFileLoader does not work so I am using UnstructuredFileIOLoader loader = UnstructuredFileLoader('data/scenario/xodr/common_junction_creator.xodr',mode="single", strategy="fast") documents_xml = loader.load() # print(documents_xml) print(f"Number of documents={len(documents_xml)}") with open("data/scenario/xodr/road_with_custom_roadmarkers.xodr", "rb") as f: loader = UnstructuredFileIOLoader( f, mode="single", strategy="fast", ) docs = loader.load() print(docs) print(f"Number of documents={len(docs)}") ``` Output: **[Document(page_content='', metadata={'source': 'data/scenario/xodr/common_junction_creator.xodr'})] Number of documents=1** [Document(page_content='<OpenDRIVE>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<header name="road with custom lanes" revMajor="1" revMinor="5" date="2023-10-24 13:01:55.839866" north="0.0" south="0.0" east="0.0" west="0.0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': 'f2bcadaa39170fe65d413bbd3b2dc2bb', 'languages': ['eng'], 'category': 'UncategorizedText'}), Document(page_content='<road rule="RHT" id="0" junction="-1" length="300">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<link/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<planView>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<geometry s="0" x="0" y="0" hdg="0" length="300">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': 'db34f8689a2ee8ac79294c4b6daccc9b', 'languages': ['eng'], 'category': 'UncategorizedText'}), Document(page_content='<line/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</geometry>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</planView>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<elevationProfile/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<lateralProfile/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<lanes>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<laneSection s="0">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<left>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': 'aa1aca19f288f19fc4ea835d72dff88e', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<lane id="1" type="driving" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': 'aa1aca19f288f19fc4ea835d72dff88e', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<link/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<width a="4" b="0" c="0" d="0" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'UncategorizedText'}), Document(page_content='<roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</left>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<center>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<lane id="0" type="none" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<roadMark sOffset="0" type="solid solid" weight="standard" color="standard" height="0.02">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<type name="solid solid" width="None">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<line length="0" space="0" tOffset="0.2" width="0.2" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<line length="0" space="0" tOffset="-0.2" width="0.2" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</type>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</roadMark>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</center>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<right>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<lane id="-1" type="driving" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '1b93bbf1878690ead63ce7f1619e042e', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<link/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<width a="4" b="0" c="0" d="0" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'UncategorizedText'}), Document(page_content='<roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</right>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</laneSection>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<laneSection s="100">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<left>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': 'b3712cf5f4c02aadc160326bedfe5ba6', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<lane id="1" type="driving" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': 'b3712cf5f4c02aadc160326bedfe5ba6', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<link/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<width a="4" b="0" c="0" d="0" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'UncategorizedText'}), Document(page_content='<roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</left>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<center>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<lane id="0" type="none" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<roadMark sOffset="0" type="solid broken" weight="standard" color="standard" height="0.02">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<type name="solid broken" width="None">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<line length="0" space="0" tOffset="0.2" width="0.2" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<line length="3" space="3" tOffset="-0.2" width="0.2" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</type>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</roadMark>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</center>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<right>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<lane id="-1" type="driving" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '1b93bbf1878690ead63ce7f1619e042e', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<link/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<width a="4" b="0" c="0" d="0" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'UncategorizedText'}), Document(page_content='<roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</right>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</laneSection>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<laneSection s="200">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<left>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '970aed3aa631e4aac64ea6da5ec910ad', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<lane id="1" type="driving" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '970aed3aa631e4aac64ea6da5ec910ad', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<link/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<width a="4" b="0" c="0" d="0" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'UncategorizedText'}), Document(page_content='<roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</left>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<center>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<lane id="0" type="none" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<roadMark sOffset="0" type="broken broken" weight="standard" color="standard" height="0.02">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '17412d8e1360a85c15cb6702ea423aa4', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<type name="broken broken" width="None">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '17412d8e1360a85c15cb6702ea423aa4', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<line length="9" space="3" tOffset="0.2" width="0.2" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<line length="3" space="9" tOffset="-0.2" width="0.2" sOffset="3"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</type>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</roadMark>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</center>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<right>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<lane id="-1" type="driving" level="false">', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '1b93bbf1878690ead63ce7f1619e042e', 'languages': ['eng'], 'category': 'NarrativeText'}), Document(page_content='<link/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='<width a="4" b="0" c="0" d="0" sOffset="0"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'parent_id': '9e49db703ffb69458886d0d4db951017', 'languages': ['eng'], 'category': 'UncategorizedText'}), Document(page_content='<roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</lane>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</right>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</laneSection>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</lanes>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</road>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'}), Document(page_content='</OpenDRIVE>', metadata={'last_modified': '2023-10-30T08:42:44', 'filetype': 'text/plain', 'languages': ['eng'], 'category': 'Title'})] Number of documents=93 ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [X] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction 1. run the python code for an openDrive file (.xodr) file. ``` <?xml version="1.0" encoding="UTF-8"?> <OpenDRIVE> <header name="my_road" revMajor="1" revMinor="5" date="2023-10-24 12:47:51.670385" north="0.0" south="0.0" east="0.0" west="0.0"/> <road rule="RHT" id="1" junction="-1" length="100"> <link> <successor elementType="junction" elementId="100"/> </link> <planView> <geometry s="0" x="0" y="0" hdg="0" length="100"> <line/> </geometry> </planView> <elevationProfile/> <lateralProfile/> <lanes> <laneSection s="0"> <left> <lane id="2" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> <lane id="1" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </left> <center> <lane id="0" type="none" level="false"> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </center> <right> <lane id="-1" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> <lane id="-2" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </right> </laneSection> </lanes> </road> <road rule="RHT" id="2" junction="-1" length="100"> <link> <predecessor elementType="junction" elementId="100"/> </link> <planView> <geometry s="0" x="149.99999999999957" y="50.000000000000895" hdg="1.5706573464102072" length="100"> <line/> </geometry> </planView> <elevationProfile/> <lateralProfile/> <lanes> <laneSection s="0"> <left> <lane id="1" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </left> <center> <lane id="0" type="none" level="false"> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </center> <right> <lane id="-1" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </right> </laneSection> </lanes> </road> <road rule="RHT" id="3" junction="-1" length="100"> <link> <predecessor elementType="junction" elementId="100"/> </link> <planView> <geometry s="0" x="200.0" y="0.0" hdg="9.26535897924907e-05" length="100"> <line/> </geometry> </planView> <elevationProfile/> <lateralProfile/> <lanes> <laneSection s="0"> <left> <lane id="2" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> <lane id="1" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </left> <center> <lane id="0" type="none" level="false"> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </center> <right> <lane id="-1" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> <lane id="-2" type="driving" level="false"> <link/> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </right> </laneSection> </lanes> </road> <road rule="RHT" id="100" junction="100" length="100.00000012397831"> <link> <predecessor elementType="road" elementId="1" contactPoint="end"/> <successor elementType="road" elementId="3" contactPoint="start"/> </link> <planView> <geometry s="0" x="100.0" y="0.0" hdg="0" length="33.33333335241042"> <spiral curvStart="1e-09" curvEnd="-2.7801076883213167e-06"/> </geometry> <geometry s="33.33333335241042" x="133.33333334526168" y="-0.0005144643872362006" hdg="-4.6318461498530586e-05" length="33.33333341915747"> <spiral curvStart="-2.780107688321317e-06" curvEnd="5.558715377723275e-06"/> </geometry> <geometry s="66.66666677156789" x="166.66666672388249" y="-0.0020586908846665537" hdg="-8.333222595482807e-09" length="33.33333335241042"> <spiral curvStart="5.5587153777232755e-06" curvEnd="9.999999999996516e-10"/> </geometry> </planView> <elevationProfile/> <lateralProfile/> <lanes> <laneSection s="0"> <left> <lane id="2" type="driving" level="false"> <link> <predecessor id="2"/> <successor id="2"/> </link> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> <lane id="1" type="driving" level="false"> <link> <predecessor id="1"/> <successor id="1"/> </link> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </left> <center> <lane id="0" type="none" level="false"> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </center> <right> <lane id="-1" type="driving" level="false"> <link> <predecessor id="-1"/> <successor id="-1"/> </link> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="broken" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> <lane id="-2" type="driving" level="false"> <link> <predecessor id="-2"/> <successor id="-2"/> </link> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </right> </laneSection> </lanes> </road> <road rule="RHT" id="101" junction="100" length="80.57849294213008"> <link> <predecessor elementType="road" elementId="1" contactPoint="end"/> <successor elementType="road" elementId="2" contactPoint="start"/> </link> <planView> <geometry s="0" x="100.0" y="3.0" hdg="0" length="25.406829175061056"> <spiral curvStart="1e-09" curvEnd="0.02541075466216959"/> </geometry> <geometry s="25.406829175061056" x="125.14335899689604" y="5.713523057106356" hdg="0.32280336415897914" length="29.764834592007983"> <spiral curvStart="0.0254107546621696" curvEnd="0.031526347239798955"/> </geometry> <geometry s="55.171663767069035" x="146.64343936963272" y="24.998132686495545" hdg="1.1701650742891778" length="25.406829175061056"> <spiral curvStart="0.03152634723979895" curvEnd="9.999999994736442e-10"/> </geometry> </planView> <elevationProfile/> <lateralProfile/> <lanes> <laneSection s="0"> <left> <lane id="1" type="driving" level="false"> <link> <predecessor id="2"/> <successor id="1"/> </link> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </left> <center> <lane id="0" type="none" level="false"> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </center> </laneSection> </lanes> </road> <road rule="RHT" id="102" junction="100" length="80.58464104902598"> <link> <predecessor elementType="road" elementId="2" contactPoint="start"/> <successor elementType="road" elementId="3" contactPoint="start"/> </link> <planView> <geometry s="0" x="149.99999999999957" y="50.000000000000895" hdg="4.71225" length="25.408049844246484"> <spiral curvStart="1e-09" curvEnd="0.03153901640632509"/> </geometry> <geometry s="25.408049844246484" x="153.35124601428106" y="24.99636057548867" hdg="5.112922463149233" length="29.768541360533018"> <spiral curvStart="0.0315390164063251" curvEnd="0.025406434592294906"/> </geometry> <geometry s="55.1765912047795" x="174.85483977842026" y="5.710997601779319" hdg="5.9605139698225456" length="25.408049844246484"> <spiral curvStart="0.025406434592294896" curvEnd="9.999999994736442e-10"/> </geometry> </planView> <elevationProfile/> <lateralProfile/> <lanes> <laneSection s="0"> <left> <lane id="1" type="driving" level="false"> <link> <predecessor id="-1"/> <successor id="2"/> </link> <width a="3" b="0" c="0" d="0" sOffset="0"/> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </left> <center> <lane id="0" type="none" level="false"> <roadMark sOffset="0" type="solid" weight="standard" color="standard" height="0.02" width="0.2"/> </lane> </center> </laneSection> </lanes> </road> <junction name="my_junction" id="100" type="default"> <connection incomingRoad="3" id="0" contactPoint="end" connectingRoad="100"> <laneLink from="2" to="2"/> <laneLink from="1" to="1"/> <laneLink from="-1" to="-1"/> <laneLink from="-2" to="-2"/> </connection> <connection incomingRoad="1" id="1" contactPoint="start" connectingRoad="100"> <laneLink from="2" to="2"/> <laneLink from="1" to="1"/> <laneLink from="-1" to="-1"/> <laneLink from="-2" to="-2"/> </connection> <connection incomingRoad="1" id="2" contactPoint="start" connectingRoad="101"> <laneLink from="2" to="1"/> </connection> <connection incomingRoad="2" id="3" contactPoint="start" connectingRoad="102"> <laneLink from="-1" to="1"/> </connection> </junction> </OpenDRIVE> ``` ### Expected behavior Fix the bug in the library.
UnstructuredFileLoader does not work so I am using UnstructuredFileIOLoader
https://api.github.com/repos/langchain-ai/langchain/issues/12700/comments
2
2023-11-01T09:18:50Z
2024-02-08T16:11:15Z
https://github.com/langchain-ai/langchain/issues/12700
1,971,998,242
12,700
[ "langchain-ai", "langchain" ]
### Issue with current documentation: While reviewing the document, I am learning about the callback functionality of langchain and have a question. In langchain.callbacks, there are two classes: `BaseCallbackHandler` and `BaseTracer`. From what I can see in the document, it seems like the roles of these two classes are similar. Could you please provide an explanation of the differences between these two classes and clarify when it is appropriate to inherit from each class when creating a custom callback? ### Idea or request for content: _No response_
DOC: BaseCallbackHandler vs BaseTracer
https://api.github.com/repos/langchain-ai/langchain/issues/12698/comments
2
2023-11-01T07:27:08Z
2024-02-09T16:09:53Z
https://github.com/langchain-ai/langchain/issues/12698
1,971,850,317
12,698
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. With the Pinecone index setup with `cosine` metric, so the scores received from the vector database are already in the`cosine` metric. However, the `_select_relevance_score_fn` of langchain pinecone vector store returns the base vector store's `_cosine_relevance_score_fn` for the `cosine` distance strategy. https://github.com/langchain-ai/langchain/blob/b2138508cbf17aef3a08cdce072d79fd5dc63dc3/libs/langchain/langchain/vectorstores/pinecone.py#L231 In the base vector store implementation of `_cosine_relevance_score_fn` the score is the complement. https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/schema/vectorstore.py#L187 So the cosine metric of 0.81 returned by the pinecone vector database indicating a higher similarity is turned into 0.19 in langchain and processed as very low similarity. ### Suggestion: _No response_
Issue: Pinecone Vector Store incorrectly assigns score in similarity_search_with_relevance_scores
https://api.github.com/repos/langchain-ai/langchain/issues/12697/comments
2
2023-11-01T06:51:09Z
2024-02-06T15:16:20Z
https://github.com/langchain-ai/langchain/issues/12697
1,971,809,367
12,697
[ "langchain-ai", "langchain" ]
### System Info langchain 0.0.327 ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction it is easy to reproduction use AsyncIteratorCallbackHandler() to get ChatTongyi stream data, it only get warning: `/venv/lib/python3.10/site-packages/langchain/chat_models/tongyi.py:365: RuntimeWarning: coroutine 'AsyncCallbackManagerForLLMRun.on_llm_new_token' was never awaited run_manager.on_llm_new_token(chunk.content, chunk=chunk)` and the reply text dispeared I look into the code , and find the problem is in the _agenerate() with only using _generate() ![image](https://github.com/langchain-ai/langchain/assets/2030833/ee37d1c0-3824-4932-91f0-3e0c1aafe61f) we can see, the stream functionality in _generate() is incomplete and problematic. One of them is the questionable support for asynchronous callback, ![image](https://github.com/langchain-ai/langchain/assets/2030833/84a3e1a9-f936-4002-aea3-889afbd618f8) and this is where error happens ![image](https://github.com/langchain-ai/langchain/assets/2030833/070b61ad-d6ad-4aaf-ac3f-1f6f116942db) it should use _astream() pls, fix it , thx ### Expected behavior return stream data
ChatTongyi class use _generate method as async call and result in replying text dispeared
https://api.github.com/repos/langchain-ai/langchain/issues/12695/comments
8
2023-11-01T05:20:30Z
2024-02-19T16:08:10Z
https://github.com/langchain-ai/langchain/issues/12695
1,971,721,957
12,695
[ "langchain-ai", "langchain" ]
### Issue with current documentation: I have searched for a while but there is no example for RetrievalQA batch inference. For example, here is my code: `model_name = "sentence-transformers/paraphrase-multilingual-mpnet-base-v2" embeddings = HuggingFaceEmbeddings(model_name=model_name) db = ElasticVectorSearch( embedding = embeddings, elasticsearch_url="http://localhost:9200", index_name="test_index", ) model = transformers.AutoModelForCausalLM.from_pretrained('vilm/vietcuna-7b-v3') generate_text = transformers.pipeline( model=model, tokenizer=tokenizer, batch_size = 8, return_full_text=True, task='text-generation', stopping_criteria=stopping_criteria, temperature=0, max_new_tokens=512, repetition_penalty=1.1 ) model_id = 'vilm/vietcuna-7b-v3' llm = HuggingFacePipeline(pipeline=generate_text) qa = RetrievalQA.from_chain_type( llm=llm, chain_type="stuff", retriever=db.as_retriever(), verbose=True, return_source_documents=True, ) ` then I tried: `qa.batch(inputs=[{'query':'Who is the prime minister of Vietnam'},{'query':'what is desease?'}])` and `qa(inputs=[{'query':'Who is the prime minister of Vietnam'},{'query':'what is desease?'}])` Both failed. I saw the reason is ElasticVectorSearch cannot return two source documents at the same time. But the main problem is that is there any way to get RetrievalQA do batch inferencing with GPU utilization. LLM batch inference is easy to use (defined params) but it seems like the RetrievalQA chain hasn't supported this. ### Idea or request for content: _No response_
DOC: RetrievalQA.from_chain_type batch inference with elastic vectorstore
https://api.github.com/repos/langchain-ai/langchain/issues/12693/comments
3
2023-11-01T04:26:22Z
2024-02-16T16:08:01Z
https://github.com/langchain-ai/langchain/issues/12693
1,971,675,122
12,693
[ "langchain-ai", "langchain" ]
### System Info langchain==0.0.326 Python 3.10.8 llm = Bedrock Note: I tested this with the Bedrock LLM and these 3 models: anthropic.claude-instant-v1 anthropic.claude-v2 ai21.j2-ultra-v1 The error does NOT occur when using llm=OpenAI EDIT: Can only replicate this error with anthropic.claude-instant-v1 Stack Trace: ``` Thought:Traceback (most recent call last): File "...venv\lib\site-packages\langchain\agents\agent.py", line 933, in _take_next_step output = self.agent.plan( File "...venv\lib\site-packages\langchain\agents\agent.py", line 547, in plan return self.output_parser.parse(full_output) File "...venv\lib\site-packages\langchain\agents\mrkl\output_parser.py", line 61, in parse raise OutputParserException( langchain.schema.output_parser.OutputParserException: Could not parse LLM output: ` Fumio Kishida is 65 years old. The largest prime number smaller than 65 is 61.` During handling of the above exception, another exception occurred: Traceback (most recent call last): File "...langchain\l101.py", line 32, in <module> agent.run("Who is the current leader of Japan and how old are they? What is the largest prime number that is smaller than the leader's age?") File "...venv\lib\site-packages\langchain\chains\base.py", line 505, in run return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[ File "...venv\lib\site-packages\langchain\chains\base.py", line 310, in __call__ raise e File "...venv\lib\site-packages\langchain\chains\base.py", line 304, in __call__ self._call(inputs, run_manager=run_manager) File "...venv\lib\site-packages\langchain\agents\agent.py", line 1146, in _call next_step_output = self._take_next_step( File "...venv\lib\site-packages\langchain\agents\agent.py", line 944, in _take_next_step raise ValueError( ValueError: An output parsing error occurred. In order to pass this error back to the agent and have it try again, pass `handle_parsing_errors=True` to the AgentExecutor. This is the error: Could not parse LLM output: ` Fumio Kishida is 65 years old. The largest prime number smaller than 65 is 61.` ``` ### Who can help? @sbusso ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [X] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ``` llm = Bedrock( credentials_profile_name="default", model_id="anthropic.claude-instant-v1", # streaming=True, model_kwargs={"temperature": 0.0} ) # llm = OpenAI(temperature=0) tools = load_tools(["serpapi"],llm=llm) # agent = initialize_agent(tools=tools,llm=llm,agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,handle_parsing_errors=True,verbose=True) agent = initialize_agent(tools=tools,llm=llm,agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,verbose=True) agent.run("Who is the current leader of Japan and how old are they? What is the largest prime number that is smaller than the leader's age?") ``` ### Expected behavior The text should have been parsed. Based on the stack trace: Could not parse LLM output: ` Fumio Kishida is 65 years old. The largest prime number smaller than 65 is 61.` I'm thinking this is probably derived from the boto3 API response, because it works fine with OpenAI.
Missing 'Action:' after 'Thought:
https://api.github.com/repos/langchain-ai/langchain/issues/12689/comments
3
2023-11-01T01:41:04Z
2024-02-13T16:08:53Z
https://github.com/langchain-ai/langchain/issues/12689
1,971,542,844
12,689
[ "langchain-ai", "langchain" ]
### System Info Python 3.10.12 langchain [v0.0.327](https://github.com/langchain-ai/langchain/releases/tag/v0.0.327) ### Who can help? @agola ### Information - [ ] The official example notebooks/scripts - [x] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction <img width="909" alt="image" src="https://github.com/langchain-ai/langchain/assets/18315/ed391f1c-fda6-45bb-9ca6-002e99eb6782"> ### Expected behavior The right answer?
Local var ref in PALChain.from_math_prompt
https://api.github.com/repos/langchain-ai/langchain/issues/12681/comments
2
2023-10-31T22:45:41Z
2024-02-07T16:11:18Z
https://github.com/langchain-ai/langchain/issues/12681
1,971,402,125
12,681
[ "langchain-ai", "langchain" ]
### System Info I have this method that is trying to format the output of LLM: ```typescript private async getOrderedTitles(titles: string[], question: string) { const outputParser = StructuredOutputParser.fromZodSchema(z.array(z.number().describe("The score for this title"))); const llm = new OpenAI({ modelName: "gpt-3.5-turbo", openAIApiKey: this.openAIApiKey, temperature: 0 }); const orderingChain = new LLMChain({ llm, outputParser, prompt: new PromptTemplate({ template: getSortingPromot(), inputVariables: ["question", "titles"], partialVariables: { format_instructions: outputParser.getFormatInstructions() }, }), }); const res = await orderingChain.call({ question, titles }); return outputParser.parse(res.text); } ``` and the prompt is: ``` Give each title a score as to how relevant it is to this question: {question} ########################################## Titles: {titles} ########################################## {format_instructions} ``` it fails with: ``` Error: Failed to parse. Text: "10,0,0,10,0,10,10,0,10,0,10,0,10,0,0". Error: TypeError: text.trim is not a function ``` ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [X] Prompts / Prompt Templates / Prompt Selectors - [X] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Above code is all that is needed to recreate the issue. ### Expected behavior There is no obvious reason why it should be failiing
output parsed: Error: Failed to parse. Text: "10,0,0,....". Error: TypeError: text.trim is not a function
https://api.github.com/repos/langchain-ai/langchain/issues/12667/comments
1
2023-10-31T19:16:56Z
2023-11-01T12:26:20Z
https://github.com/langchain-ai/langchain/issues/12667
1,971,149,418
12,667
[ "langchain-ai", "langchain" ]
### System Info `[tool.poetry.dependencies] python = "=3.8.16" langchain = "^0.0.327" google-cloud-aiplatform = "^1.35.0" ` code: `embedding = VertexAIEmbeddings()` error: `Traceback (most recent call last): File "/Users/astripathy/Library/Caches/pypoetry/virtualenvs/nssauto-test-2ktKcOZb-py3.8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 75, in error_r emapped_callable return callable_(*args, **kwargs) File "/Users/astripathy/Library/Caches/pypoetry/virtualenvs/nssauto-test-2ktKcOZb-py3.8/lib/python3.8/site-packages/grpc/_channel.py", line 1161, in __call__ return _end_unary_response_blocking(state, call, False, None) File "/Users/astripathy/Library/Caches/pypoetry/virtualenvs/nssauto-test-2ktKcOZb-py3.8/lib/python3.8/site-packages/grpc/_channel.py", line 1004, in _end_unary_response_blocking raise _InactiveRpcError(state) # pytype: disable=not-instantiable grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "DNS resolution failed for us-central1-aiplatform.googleapis.com:443: C-ares status is not ARES_SUCCESS qtype=A name=us-central1-aiplatform.googleapis.co m is_balancer=0: DNS query cancelled" debug_error_string = "UNKNOWN:DNS resolution failed for us-central1-aiplatform.googleapis.com:443: C-ares status is not ARES_SUCCESS qtype=A name=us-central1-aipla tform.googleapis.com is_balancer=0: DNS query cancelled {grpc_status:14, created_time:"2023-10-31T22:38:41.657524+05:30"}"` I don't think there is any connectivity issue as I am able to successfully run below query from the same machine: `MODEL_ID="textembedding-gecko" PROJECT_ID=XXXX-XXXX curl \ -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ https://us-central1-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict -d \ $'{ "instances": [ { "content": "What is life?"} ], }' { "predictions": [ { "embeddings": { "values": [ 0.010562753304839134, 0.049150310456752777,` ### Who can help? @hwchase17 @agola11 ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [X] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction `!pip install langchain !pip install google-cloud-aiplatform import langchain from langchain.embeddings import VertexAIEmbeddings from google.cloud import aiplatform embedding = VertexAIEmbeddings()` ### Expected behavior Below code should not throw any exception: ` embedding = VertexAIEmbeddings()`
VertexAIEmbeddings is raising timout exception
https://api.github.com/repos/langchain-ai/langchain/issues/12662/comments
2
2023-10-31T17:31:54Z
2023-11-03T08:59:32Z
https://github.com/langchain-ai/langchain/issues/12662
1,970,956,799
12,662
[ "langchain-ai", "langchain" ]
### Issue with current documentation: I´m using https://python.langchain.com/docs/guides/debugging and https://python.langchain.com/docs/modules/chains/document/refine. Somehow the documentation does not line up. How can I set verbose=True on a chain when using LCEL? ### Idea or request for content: Add documentation on how to activate verbose logs on a chain when using LCEL.
DOC: When using LCEL, how do I set verbose=True on a chain?
https://api.github.com/repos/langchain-ai/langchain/issues/12659/comments
3
2023-10-31T17:11:43Z
2023-10-31T19:56:08Z
https://github.com/langchain-ai/langchain/issues/12659
1,970,920,738
12,659
[ "langchain-ai", "langchain" ]
### Feature request The idea is to have an object that can be used in the same way as `LanguageModel` objects, but the object would contain a list of `LanguageModels` that could be chosen according to rules. For instance I would to call my list of LLM with a round robin strategy in order to distribute requests among multiple LLM. Example: ``` llm1 = OpenAI(key1) llm2 = OpenAI(key2) muti_llm = MultiLLM([llm1, llm2], method="round-robin") multi_llm.predict(...) # will use llm1 multi_llm.predict(...) # the second time will use the llm2 ``` ### Motivation The motivations behind these features are: - leveraging multi account to avoid API limits per account - act as a load balancer to easily create balancing strategies (round robin, random, least connection, ...) - (in the future maybe) have the possibility to make shadowing between multiple LLM or other strategies ### Your contribution I started working on that but I'm not sure about the object hierarchy I need to implement to achieve this goal properly without impacting too much the existing codebase. Here is my naive implementation: ```python LanguageModelInput = TypeVar("LanguageModelOutput") class BaseMultiLanguageModel(BaseLanguageModel[LanguageModelInput], ABC): language_models: List[BaseLanguageModel] = Field( description="List of language models", min_items=1 ) @property @abstractmethod def active_model(self) -> BaseLanguageModel: ... def generate_prompt(self, prompts: List[PromptValue], stop: Optional[List[str]] = None, callbacks: Callbacks = None, **kwargs: Any) -> LLMResult: return self.active_model.generate_prompt(prompts, stop, callbacks, **kwargs) async def agenerate_prompt(self, prompts: List[PromptValue], stop: Optional[List[str]] = None, callbacks: Callbacks = None, **kwargs: Any) -> LLMResult: return await self.active_model.agenerate_prompt(prompts, stop, callbacks, **kwargs) def predict(self, text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) -> str: return self.active_model.predict(text, stop=stop, **kwargs) def predict_messages(self, messages: List[BaseMessage], *, stop: Optional[Sequence[str]] = None, **kwargs: Any) -> BaseMessage: return self.active_model.predict_messages(messages, stop=stop, **kwargs) async def apredict(self, text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) -> str: return await self.active_model.apredict(text, stop=stop, **kwargs) async def apredict_messages(self, messages: List[BaseMessage], *, stop: Optional[Sequence[str]] = None, **kwargs: Any) -> BaseMessage: return await self.active_model.apredict_messages(messages, stop=stop, **kwargs) def invoke(self, input: Input, config: Optional[RunnableConfig] = None, **kwargs: Any) -> Output: return self.active_model.invoke(input, config, **kwargs) # Example of subclasses creation class RandomMultiChatModel(BaseMultiLanguageModel[PromptValue]): @property def active_model(self) -> BaseLanguageModel: choice = randint(0, len(self.language_models) - 1) print(f"Using LLM: {choice}") return self.language_models[choice] class RoundRobinMultiChatModel(BaseMultiLanguageModel[PromptValue]): index: int = 0 @property def active_model(self) -> BaseLanguageModel: self.index = (self.index + 1) % len(self.language_models) print(f"Using LLM: {self.index}") return self.language_models[self.index] # Usage llm1 = ChatOpenAI(openai_api_key=OPENAI_API_KEY_1) llm2 = ChatOpenAI(openai_api_key=OPENAI_API_KEY_2) round_robin_multi_llm = RoundRobinMultiChatModel(language_models=[llm1, llm2]) round_robin_multi_llm.predict("Hello, how are you?") # use the same methods as BaseLanguageModel ``` This is working with simple examples but I'm not sure this inheritance hierarchy is the best so any help would be appreciated to define the best solution :)
MultiLanguageModel: work with multiple LLM with the interface of a single one
https://api.github.com/repos/langchain-ai/langchain/issues/12656/comments
10
2023-10-31T16:39:54Z
2024-02-26T16:07:18Z
https://github.com/langchain-ai/langchain/issues/12656
1,970,867,010
12,656
[ "langchain-ai", "langchain" ]
### System Info Python 3.9.16 Langchain 0.0.326 Linux (Fedora 37) ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [X] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [X] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ```python from langchain.utilities import SerpAPIWrapper from langchain.agents import AgentType, initialize_agent from langchain.tools import Tool import langchain langchain.debug = True from langchain.llms import OpenAI llm = OpenAI(temperature=0, verbose=True) search = SerpAPIWrapper() events_tool = Tool( name="events_tool_serp", description="A tool to look up current events", func=search.run, ) tools = [events_tool] agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) agent.run("What happened yesterday?") ``` When the above code is run with OpenAI, things work OK. However, when swapped for a different LLM endpoint: ```python # using IBM watsonx.ai from model_context import get_watsonx_predictor llm = get_watsonx_predictor( model="codellama/codellama-34b-instruct", min_new_tokens=5, verbose=True ) ``` Odd things happen: ``` [llm/start] [1:chain:AgentExecutor > 2:chain:LLMChain > 3:llm:LangChainInterface] Entering LLM run with input: { "prompts": [ "Answer the following questions as best you can. You have access to the following tools:\n\nevents_tool_serp: A tool to look up current events\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [events_tool_serp]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: What happened yesterday?\nThought:" ] } [llm/end] [1:chain:AgentExecutor > 2:chain:LLMChain > 3:llm:LangChainInterface] [2.65s] Exiting LLM run with output: { "generations": [ [ { "text": " I should look up current events\nAction: events_tool_serp\nAction Input: yesterday\nObservation:", "generation_info": { "generated_token_count": 25, "input_token_count": 160, "stop_reason": "STOP_SEQUENCE", "stop_sequence": "\nObservation:", "input_text": "Answer the following questions as best you can. You have access to the following tools:\n\nevents_tool_serp: A tool to look up current events\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [events_tool_serp]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: What happened yesterday?\nThought:" }, "type": "Generation" } ] ], "llm_output": { "token_usage": { "generated_token_count": 25, "input_token_count": 160 } }, "run": null } [chain/end] [1:chain:AgentExecutor > 2:chain:LLMChain] [2.65s] Exiting Chain run with output: { "text": " I should look up current events\nAction: events_tool_serp\nAction Input: yesterday\nObservation:" } [tool/start] [1:chain:AgentExecutor > 4:tool:events_tool_serp] Entering Tool run with input: "yesterday Observation:" ``` The `Observation:` text is being passed into the tool. For simple tools like search engines, this often is not a problem. However, when your tool expects a structured input, you sometimes end up with tool input like the following: ``` "foo,bar Observation:" ``` This results in the tool attempting to do something like splitting on `,` and then the second part of the resulting array is: ``` bar Observation: ``` Which definitely breaks the tool. ### Expected behavior The `Observation:` text should definitely not be passed as part of the tool input. The MRKL output parser is here: https://github.com/langchain-ai/langchain/blob/v0.0.327/libs/langchain/langchain/agents/mrkl/output_parser.py#L26-L77 The regex does appear to match the groups correctly: https://regex101.com/r/v7Tg1n/1 It's unclear, though, why the `Observation:` text is ending up getting passed into the input. Although, when you use newline characters (`\n`) in the string, and not actual newlines, it does appear that the `Observation` part is being caught in the group: https://regex101.com/r/MMCvYn/1 I tried to spelunk into the code to figure out when the agent "base" calls `parse` to see why the `Observation` text would be getting passed into parse in the first place, but it seems that one possible fix here would be to modify the parse RegEx for MRKL to make sure it does NOT capture the observation component. Changing the RegEx in the MRKL agent to the following: ```python r"Action\s*\d*\s*:[\s]*(.*?)[\s]*Action\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)Observation:" ``` And then modifying the tool input strip: ```python if action_match: action = action_match.group(1).strip() action_input = action_match.group(2) tool_input = action_input.strip() ``` fixes the issue if "Observation" got passed in, but I am assuming that `parse` shouldn't have gotten this in the first place.
MRKL agent is passing "Observation" text to tools when using non-OpenAI LLMs and breaks structured input tools
https://api.github.com/repos/langchain-ai/langchain/issues/12645/comments
9
2023-10-31T15:55:50Z
2024-07-04T08:07:06Z
https://github.com/langchain-ai/langchain/issues/12645
1,970,785,521
12,645
[ "langchain-ai", "langchain" ]
### System Info - langchain version: 0.0.320 - python: 3.9.17 ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Similar to the [guide](https://python.langchain.com/docs/expression_language/interface#batch) for `chat_models.batch`, but if we use `llm` instead, `batch` and `abatch` methods will throw exceptions. Here is an example for `batch` ```py model = OpenAI() prompt = PromptTemplate.from_template("tell me a joke about {topic}") chain = prompt | model chain.batch([{"topic": "bears"}, {"topic": "cats"}], config={"max_concurrency": 5}) ``` You get the following error for dead loop exceeding recursion limit ```py ... --> 300 for output in self.batch( 301 batch, config=config, return_exceptions=return_exceptions, **kwargs 302 ) 303 ] File [/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/llms/base.py:273](https://file+.vscode-resource.vscode-cdn.net/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/llms/base.py:273), in BaseLLM.batch(self, inputs, config, return_exceptions, **kwargs) 270 if not inputs: 271 return [] --> 273 config = get_config_list(config, len(inputs)) 274 max_concurrency = config[0].get("max_concurrency") 276 if max_concurrency is None: File [/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/schema/runnable/config.py:115](https://file+.vscode-resource.vscode-cdn.net/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/schema/runnable/config.py:115), in get_config_list(config, length) 108 def get_config_list( 109 config: Optional[Union[RunnableConfig, List[RunnableConfig]]], length: int 110 ) -> List[RunnableConfig]: 111 """ 112 Helper method to get a list of configs from a single config or a list of 113 configs, useful for subclasses overriding batch() or abatch(). 114 """ --> 115 if length < 0: 116 raise ValueError(f"length must be >= 0, but got {length}") 117 if isinstance(config, list) and len(config) != length: RecursionError: maximum recursion depth exceeded in comparison ``` Or if you set `max_concurrency` to be smaller than the length of the prompts, say 1 ```py chain.batch([{"topic": "bears"}, {"topic": "cats"}], config={"max_concurrency": 1}) ValueError Traceback (most recent call last) ... File [/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/schema/runnable/base.py:1271](https://file+.vscode-resource.vscode-cdn.net/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/schema/runnable/base.py:1271), in RunnableSequence.batch(self, inputs, config, return_exceptions, **kwargs) 1269 else: 1270 for i, step in enumerate(self.steps): -> 1271 inputs = step.batch( 1272 inputs, 1273 [ 1274 # each step a child run of the corresponding root run 1275 patch_config( 1276 config, callbacks=rm.get_child(f"seq:step:{i+1}") 1277 ) 1278 for rm, config in zip(run_managers, configs) 1279 ], 1280 ) 1282 # finish the root runs 1283 except BaseException as e: File [/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/llms/base.py:297](https://file+.vscode-resource.vscode-cdn.net/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/llms/base.py:297), in BaseLLM.batch(self, inputs, config, return_exceptions, **kwargs) 292 else: 293 batches = [ 294 inputs[i : i + max_concurrency] 295 for i in range(0, len(inputs), max_concurrency) 296 ] --> 297 return [ 298 output 299 for batch in batches 300 for output in self.batch( 301 batch, config=config, return_exceptions=return_exceptions, **kwargs 302 ) 303 ] File [/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/llms/base.py:300](https://file+.vscode-resource.vscode-cdn.net/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/llms/base.py:300), in <listcomp>(.0) 292 else: 293 batches = [ 294 inputs[i : i + max_concurrency] 295 for i in range(0, len(inputs), max_concurrency) 296 ] 297 return [ 298 output 299 for batch in batches --> 300 for output in self.batch( 301 batch, config=config, return_exceptions=return_exceptions, **kwargs 302 ) 303 ] File [/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/llms/base.py:273](https://file+.vscode-resource.vscode-cdn.net/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/llms/base.py:273), in BaseLLM.batch(self, inputs, config, return_exceptions, **kwargs) 270 if not inputs: 271 return [] --> 273 config = get_config_list(config, len(inputs)) 274 max_concurrency = config[0].get("max_concurrency") 276 if max_concurrency is None: File [/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/schema/runnable/config.py:118](https://file+.vscode-resource.vscode-cdn.net/usr/local/Caskroom/miniconda/base/envs/chatgpt/lib/python3.9/site-packages/langchain/schema/runnable/config.py:118), in get_config_list(config, length) 116 raise ValueError(f"length must be >= 0, but got {length}") 117 if isinstance(config, list) and len(config) != length: --> 118 raise ValueError( 119 f"config must be a list of the same length as inputs, " 120 f"but got {len(config)} configs for {length} inputs" 121 ) 123 return ( 124 list(map(ensure_config, config)) 125 if isinstance(config, list) 126 else [patch_config(config, copy_locals=True) for _ in range(length)] 127 ) ValueError: config must be a list of the same length as inputs, but got 2 configs for 1 inputs ``` Similar errors for `abatch` with `max_concurrecy`. I believe the bug lies in https://github.com/langchain-ai/langchain/blob/f94e24dfd79ccf55a14641b6940a706674c070f8/libs/langchain/langchain/llms/base.py#L297 where `config` list length is inconsistent with the `inputs` length after chopping up by max_concurrency. The fix could be as simple as ``` config = {**config[0], "max_concurrency": None} # no list is needed ``` ### Expected behavior No error, just like with `chat_models`
`llm.batch` method fails with `max_concurrency` in config
https://api.github.com/repos/langchain-ai/langchain/issues/12643/comments
1
2023-10-31T15:49:39Z
2023-11-21T20:56:52Z
https://github.com/langchain-ai/langchain/issues/12643
1,970,772,521
12,643
[ "langchain-ai", "langchain" ]
I am trying to use Langchain information extraction chain with OpenAI. Firstly, I am reading a PDF file having some text about products or product. There is no specefic format of PDF, it can be in any format like, there can be only one product on one page or one product can be on two pages or there can be 10 products on one page. So it's completely random. How can I extract the the useful information (some key attributes) for all the products. Currently, I am using Pydantic to validate the output schema and I am using `PyPDFLoader` to load the pdf and then using the `load_and_split`. ``` loader = PyPDFLoader(file_path=file_path) pages = loader.load_and_split() ``` And then I am looping on the pages like this: ``` llm = ChatOpenAI(temperature=0, model=model_name, openai_api_key=key) chain = create_extraction_chain(schema, llm) for index in range(0, len(pages)): output = chain.run(pages[index]) results.append(output) ``` How can I run the extraction in such a way that it should be completely automated, currently, it is just extracting information from one page and then other and then other.
Langchain Information Extraction
https://api.github.com/repos/langchain-ai/langchain/issues/12636/comments
7
2023-10-31T14:32:45Z
2024-03-08T16:39:02Z
https://github.com/langchain-ai/langchain/issues/12636
1,970,609,183
12,636
[ "langchain-ai", "langchain" ]
### System Info Python 3.9.16, langchain==0.0.322 ### Who can help? @agola11 @sudranga ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [X] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction I want to keep generated cypher queries in the memory to feed into Question/Answer LLM which leads better understanding of the context. Following example helps to reproduce error (I am not providing prompt details etc.). * I initialize a ConversationBufferMemory to keep both question-answer as well as generated cypher queries. ```python graph = get_neo4j_graph(neo4j_url, neo4j_db_name, neo4j_username, neo4j_password) custom_cypher_prompt = generate_custom_cypher_prompt() custom_qa_prompt = generate_custom_qa_prompt() # First I did not give any input key to Memory but it gives error when there is multiple input in the prompt template # 'question' input_key makes it work for cypher_llm and qa_llm but fails in GraphCypherQAChain # Since GraphCypherQAChain default input_key is 'query' memory = ConversationBufferMemory(memory_key="chat_history", input_key='question') readonlymemory = ReadOnlySharedMemory(memory=memory) graph_chain = GraphCypherQAChain.from_llm( graph=graph, cypher_llm=ChatOpenAI(temperature='0', model='gpt-4', openai_api_key=openai_api_key), qa_llm=ChatOpenAI(temperature='0.5', model='gpt-3.5-turbo-16k', openai_api_key=openai_api_key), cypher_llm_kwargs={"prompt": custom_cypher_prompt, "memory": memory, "verbose": True}, qa_llm_kwargs={"prompt": custom_qa_prompt, "memory": readonlymemory, "verbose": True}, # Limit the number of results from the Cypher QA Chain using the top_k parameter top_k=5, # Return intermediate steps from the Cypher QA Chain # return_intermediate_steps=True, validate_cypher=True, verbose=True, memory=memory ) response = graph_chain.run(query="<question>") ``` ### Expected behavior Keep generated cypher query in the memory to feed into QA LLM as history.
Cannot keep history of Cypher LLM in GraphCypherQAChain in the memory object
https://api.github.com/repos/langchain-ai/langchain/issues/12635/comments
3
2023-10-31T14:30:34Z
2024-06-03T12:27:15Z
https://github.com/langchain-ai/langchain/issues/12635
1,970,604,472
12,635
[ "langchain-ai", "langchain" ]
### Feature request Hi there, Thanks you so much for this awesome library! I have a suggestion that might improve the AzureChatOpenAI class. In my company we use AzureChatOpenAI where the initialization of a `chat` object looks like this: ``` os.environ["OPENAI_API_KEY"] = get_token().token return AzureChatOpenAI( openai_api_base=AZ_OAI_API_BASE_GPT_4, openai_api_version="2023-05-15", deployment_name=AZ_OAI_DEPLOYMENT_ID_GPT_4, openai_api_type="azuread", ) ``` The problem is that the get_token function returns a token with a ttl of 60 minutes. This requires us to recreate the chat object before the expiration reaches. I think it would be great if you could add an optional function as an argument which the AzureChatOpenAI class will trigger in the retry logic incase there is a 401 API error. Something that looks like this: ``` class AzureChatOpenAI(ChatOpenAI): # ..... other properties token_refresh_function: Optional[Callable[[], str]] = None # call this on the retry function... def _refresh_token_if_needed(self): if self.token_refresh_function: new_token = self.token_refresh_function() if new_token: self.client.api_key = new_token ``` ### Motivation The Azure models might have a more strict security requirements where the open_api key is a token with a short ttl. ### Your contribution I would love to help just don't have the time right now, but I shared a few snippets that might help..
Add an optional get_token function argument to AzureChatOpenAI to be called on retry
https://api.github.com/repos/langchain-ai/langchain/issues/12632/comments
1
2023-10-31T13:46:03Z
2024-02-06T16:10:06Z
https://github.com/langchain-ai/langchain/issues/12632
1,970,512,615
12,632
[ "langchain-ai", "langchain" ]
### Issue with current documentation: Import Error while creating SelfQueryRetriever `retriever = SelfQueryRetriever.from_llm( llm, vectordb, document_content_description, metadata_field_info, verbose=True)` The documentation mentions it requires lark but doesn't explicitly mention its version. I am getting an import error. <img width="810" alt="image" src="https://github.com/langchain-ai/langchain/assets/55703712/8380cd66-5e1f-4c91-8384-7649ca802be0"> ### Idea or request for content: The documentation should mention specifically that lark version greater then 1.1.5 is required. `pip install lark==1.1.5` <img width="529" alt="image" src="https://github.com/langchain-ai/langchain/assets/55703712/f054f70b-672a-4938-aaf2-4fbfa16cb051"> But this also didn't solve the issue.
DOC: Import Error while creating SelfQueryRetriever
https://api.github.com/repos/langchain-ai/langchain/issues/12631/comments
4
2023-10-31T13:12:27Z
2024-07-09T12:45:12Z
https://github.com/langchain-ai/langchain/issues/12631
1,970,446,072
12,631
[ "langchain-ai", "langchain" ]
### System Info Langchain version. - 0.0.326 Python - 3.9.6 ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction embeddings = HuggingFaceEmbeddings(model_name='all-MiniLM-L6-v2') CONNECTION_STRING = "postgresql+psycopg2://hwc@localhost:5432/test3" COLLECTION_NAME = "state_of_the_union_test" vectorestore = PGVector.from_documents( embedding=embeddings, documents=docs, collection_name=COLLECTION_NAME, connection_string=CONNECTION_STRING, ) Getting below error line 221, in get_collection return self.CollectionStore.get_by_name(session, self.collection_name) ^^^^^^^^^^^^^^^^^^^^ AttributeError: 'PGVector' object has no attribute 'CollectionStore'. Did you mean: 'collection_name'? ### Expected behavior The embeddings should be stored in the database using pgvector.
AttributeError: 'PGVector' object has no attribute 'CollectionStore'. Did you mean: 'collection_name'?
https://api.github.com/repos/langchain-ai/langchain/issues/12629/comments
8
2023-10-31T11:02:09Z
2024-02-15T16:07:55Z
https://github.com/langchain-ai/langchain/issues/12629
1,970,198,162
12,629
[ "langchain-ai", "langchain" ]
``` langchain_chain = ( FewShotPromptTemplate( examples=examples, example_prompt=example_prompt, prefix=prefix, suffix="current time {now}\n{format_instructions} \n Question: {question} ", input_variables=["question", "now", "format_instructions"]) | ChatOpenAI() ) branch = RunnableBranch( (lambda x: "q1" in x["topic"].lower(), langchain_chain), llm=ChatTongyi())), (lambda x: "12" in x["topic"].lower(), anthropic_chain), general_chain, ) full_chain = {"topic": chain, "question": lambda x: x["question"], "now": now, "format_instructions": format_instructions} | branch print(full_chain.invoke({"question": "question"})) ```` I want to pass some parameters to the next chain after selecting the corresponding chain in RunnableBranch, here is the langchain_chain
How to use FewShotPromptTemplate and RunnableBranch combination?
https://api.github.com/repos/langchain-ai/langchain/issues/12626/comments
3
2023-10-31T10:03:04Z
2023-11-01T09:19:06Z
https://github.com/langchain-ai/langchain/issues/12626
1,970,082,248
12,626
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I have created a retrieval QA project. In this project, I want to add memory to LLM so that it can also remember the previous chat. I have configured the LLM not to answer from its own knowledge but from the context I provided, and it is working fine. However, when I add memory to it, it starts to answer from its own knowledge if it is out of context. I just want the LLM to answer based on the context, remember the previous chat, and if the answer is out of context, it should simply state that it is out of context or something similar. Kindly help me or suggest me something which can work. ### Suggestion: _No response_
Issue: Creating Memory of QAChain , Making the llm not to answer from its own knowledge but rely on the context we provided
https://api.github.com/repos/langchain-ai/langchain/issues/12621/comments
3
2023-10-31T08:07:32Z
2024-05-09T16:08:08Z
https://github.com/langchain-ai/langchain/issues/12621
1,969,872,868
12,621
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I've have been trying to work with AWS bedrock Cohere command LLM with Langchain and I'm referring [https://github.com/aws-samples/rag-using-langchain-amazon-bedrock-and-opensearch/blob/main/ask-bedrock-with-rag.py](url) as source. **Below are few snippet of code that I'm working with,** def create_bedrock_llm(bedrock_client): bedrock_llm = Bedrock( model_id="cohere.command-text-v14", client=bedrock_client, verbose = True, model_kwargs={'temperature': 0} ) return bedrock_llm bedrock_client = bedrock_client = boto3.client(service_name="bedrock-runtime", region_name="us-east-1") llm = create_bedrock_llm(bedrock_client) template = """"Your are a expert financial reporter who analyzes performance of the company. The relevant information for answering the question is given below. Try to give detailed answer using the context available. If you don't know the answer, just say that you don't know, don't try to make up an answer. {context} Question: {question} Answer:""" prompt = PromptTemplate(template=template, input_variables=['context', 'question']) embedding = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") db = Chroma(persist_directory=DB_CHROMA_PATH, embedding_function=embedding) retriever=db.as_retriever(search_kwargs={'k': 3}) qa = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=retriever, return_source_documents=True, chain_type_kwargs={"prompt": prompt, "verbose": True}, verbose=True) while True: query = input("\nEnter the query\n") if query.lower() == 'exit': break res = qa(query) print(res) **Error**: ValueError: Error raised by bedrock service: An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: 2 schema violations found, please reformat your input and try again. ### Suggestion: I have tried with API request using invoke_model() function with the same prompt schema which worked perfectly fine and response was recieved.
Issue: Amazon Bedrock Cohere Command - Malformed input request: 2 schema violations found, please reformat your input and try again.
https://api.github.com/repos/langchain-ai/langchain/issues/12620/comments
7
2023-10-31T05:43:21Z
2024-01-03T12:12:32Z
https://github.com/langchain-ai/langchain/issues/12620
1,969,684,277
12,620
[ "langchain-ai", "langchain" ]
### System Info Langchain: 0.0.326 __post_init__ in __init__ accidentally removed in: https://github.com/langchain-ai/langchain/commit/2c58dca5f0ca946421ef9b7cc8149d38537ee466 ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction 1. Use PGVector 2. lib/python3.11/site-packages/langchain/vectorstores/pgvector.py", line 497, in from_texts embeddings = embedding.embed_documents(list(texts)) ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'embed_documents' ### Expected behavior PGVector should have __post_init__ to initialize the collection
PGVector __post_init__ was removed in 0.0.326
https://api.github.com/repos/langchain-ai/langchain/issues/12616/comments
2
2023-10-31T02:40:48Z
2024-02-08T16:11:35Z
https://github.com/langchain-ai/langchain/issues/12616
1,969,528,605
12,616
[ "langchain-ai", "langchain" ]
### Feature request Currently, there are two separate chains for math: LLMSymbolicMathChain and LLMMathChain. Is there a way to get the best of both words? ### Motivation Sometimes it is better to use one over the other for my app, but currently, I can only use one. ### Your contribution Not that I know of.
Better Math Chain
https://api.github.com/repos/langchain-ai/langchain/issues/12614/comments
0
2023-10-31T00:59:14Z
2023-10-31T01:59:39Z
https://github.com/langchain-ai/langchain/issues/12614
1,969,450,626
12,614
[ "langchain-ai", "langchain" ]
I am working with a DataFrame that has multiple columns to get their text. Why is the method only accepts one column as input? Here is the reference to the line of the code: https://github.com/langchain-ai/langchain/blob/481bf6fae695653c52b26895292a40cf010c08e2/libs/langchain/langchain/document_loaders/dataframe.py#L36C71-L36C71
DataFrameLoader accepts ONLY one column and by default labeled as "text"
https://api.github.com/repos/langchain-ai/langchain/issues/12601/comments
8
2023-10-30T22:51:00Z
2024-07-31T14:12:38Z
https://github.com/langchain-ai/langchain/issues/12601
1,969,345,542
12,601
[ "langchain-ai", "langchain" ]
### System Info Trying to replicate the basic langchain summarization type = Stuff usage as on [website documentation](https://python.langchain.com/docs/use_cases/summarization), but it is not able to process long doc. Test model used: meta-llama/Llama-2-7b-chat-hf Test result: tried its original demo code, it did not work, and gives two types of error alternatively after dozens of trials: **Error 1:** timeout error (I've referred to the [related langchain timeout discussion](https://github.com/langchain-ai/langchain/issues/3005) here to increase request_timeout=600/3600 secs, but still get the timeout error. checked my host is on) **Error 2:** Invalid response object from API Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised APIError: Invalid response object from API: '{"object":"error","message":"Expecting value: line 1 column 1 (char 0)","code":50001}' (HTTP response code was 400). ### Who can help? Hi @hwchase17 , include this issue with you, as I am using llm **chat wrappers** like `from langchain.llms.openai import OpenAI`, `from langchain.chains.combine_documents.stuff import StuffDocumentsChain` and `from langchain.chains.summarize import load_summarize_chain` etc and error comes from there Hi @agola11 , include you w/ this issue re **callbacks**, as in the errors mentioned above, the Error2: goes to -> --> stuff_chainself.combine_docs(docs, callbacks=_run_manager.get_child(), **other_keys) --> 171 return self.llm_chain.predict(callbacks=callbacks, **inputs) --> 257 return self(kwargs, callbacks=callbacks)[self.output_key] --> 310 raise e --> 304 self._call(inputs, run_manager=run_manager) ---> 93 response = self.generate([inputs], run_manager=run_manager) ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [X] Callbacks/Tracing - [ ] Async ### Reproduction To get something out from langchain summarization, I downsized the model from llama2-7b to "Sheared-LLaMA-1.3B" and replaced the original example's doc with a shorter doc "". I can see from langchain w/ verbose started w/ > Entering new StuffDocumentsChain chain..., > Entering new LLMChain chain... w/ print out the original full doc, but it returns'> Finished chain. returns "Got any creative ideas for a 10 year old’s birthday?"' ``` from langchain.chat_models import ChatOpenAI from langchain.chains.llm import LLMChain from langchain.prompts import PromptTemplate from langchain.chains.combine_documents.stuff import StuffDocumentsChain prompt_template = """Write a concise summary of the following: "{text}" CONCISE SUMMARY:""" prompt = PromptTemplate.from_template(prompt_template) llm = ChatOpenAI(verbose = True , temperature=0.1 , model_name=model_name , openai_api_key = "EMPTY" , openai_api_base = "http://localhost:8000/v1" , request_timeout=600 , max_retries=1) llm_chain = LLMChain(llm=llm, prompt=prompt, verbose = True) stuff_chain = StuffDocumentsChain( llm_chain=llm_chain, document_variable_name="text" ) loader = WebBaseLoader("https://huggingface.co/princeton-nlp/Sheared-LLaMA-1.3B") docs = loader.load() print(stuff_chain.run(docs )) ``` But I got strange result as below: <img width="692" alt="image" src="https://github.com/langchain-ai/langchain/assets/66184093/ef38f029-9d0c-401e-8b66-7312e44d75b8"> (my local host heart beats well) Try the same code with a small piece of business-related conversation doc(~ 1k words) w/ StuffDocumentsChain returns something relevant, but load_summarize_chain only gives <img width="713" alt="image" src="https://github.com/langchain-ai/langchain/assets/66184093/0d776be5-1288-49c7-8f6f-ec41171ce2c1"> More problem comes, when I double the size on my test doc(4k words, definitely have to be>4096 tokens, that's the point of using summarization), it returns Error 1 and Error 2 mentioned at the beginning, same as attempting replication langchain documentation, so get the trouble it is not able to process long doc gain. ### Expected behavior returns some relavent result. though understand it does not have to be good, as I am using toy model 1.3Brelevant
Summarization: documentation example not replicable. Invalid response object from API together/or w/ reponse time error
https://api.github.com/repos/langchain-ai/langchain/issues/12591/comments
3
2023-10-30T21:29:38Z
2024-05-09T16:08:03Z
https://github.com/langchain-ai/langchain/issues/12591
1,969,256,873
12,591
[ "langchain-ai", "langchain" ]
Hi! Usually I process English documents, but I recently had to process files in Portuguese and UnstructuredFileLoader can't deal with it. I loose characters such as ç, é, í, ã, õ, etc. It doesn't matter if its PDF, HTML or DOCX. Is there a way to encode it properly? ex: Art. 110. Sem prejuzo da nova redao dada aos arts. 380 e 381 da Lei n 16.050, de 31 de julho de 2014, as outras disposies previstas nesta Lei sero aplicadas apenas aos processos de licenciamento de obras e edificaes protocolados aps a data de publicao desta Lei, exceto nos casos de manifestao formal do interessado, a qualquer tempo, optando pela anlise integral de acordo com as novas disposies. Art. 111. O 4 do art. 382 da Lei n 16.050, de 2014, passa a vigorar com a seguinte redao: Art. 382. ................................................................................... .................................................................................................... 4 Para as Operaes Urbanas Consorciadas preexistentes em vigor, as regras de finalizao devero ser definidas por lei especfica e as regras de transio para finalizao devero ser iniciadas apenas para lotes que no se enquadrem no tamanho mnimo estabelecido pela OUC, quando a Operao Urbana Consorciada atingir o limite de estoque de rea Adicional disponvel de 5% do total previsto em sua lei especfica. (NR) Art. 112. A reviso da Lei Municipal de Parcelamento, Uso e Ocupao LPUOS, Lei n 16.402, de 2016, poder rever os limites das reas de ZEU, ZEUa, ZEUP, ZEUPa, ZEM e ZEMP, com base em parmetros que considerem o disposto no art. 77 da Lei n 16.050, de 2014. ### Suggestion: _No response_
Issue: Encoding error with UnstructuredFileLoader
https://api.github.com/repos/langchain-ai/langchain/issues/12577/comments
2
2023-10-30T18:35:24Z
2023-10-30T19:42:34Z
https://github.com/langchain-ai/langchain/issues/12577
1,968,988,998
12,577
[ "langchain-ai", "langchain" ]
### System Info Langchain version: v0.0.326 Python: 3.10 ### Who can help? @hw We have been encountering a recurring issue with the Bing Search tool (BingSearchAPIWrapper) in LangChain developed in Python. The tool occasionally fails to return results, and the backend function displays the message `webPages`. This issue is connected to the BingSearchAPIWrapper ![image](https://github.com/langchain-ai/langchain/assets/15362783/98f0517b-6c12-4591-9017-a32fc8e952c4) ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [X] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction #### Steps to Reproduce: 1. Query the Bing Search tool with a specific text : `{"keywords":["Everyday C%23", "advanced"]} site:https:learn.microsoft.com'.` 2. Observe that the tool fails to return results and instead displays the message `webPages`. #### Actual Behavior: The Bing API fails to return relevant results if there are no matches. In these situations, the API omits the `webPages` property from the response. ### Expected behavior #### Expected Behavior: The Bing Search tool should return relevant results for any given keyword or a message that the results can not be found.
[Bing Search Wrapper] KeyError Exception 'webPages' in LangChain Bing Search Tool: Recurring Bug Impacting Search Results
https://api.github.com/repos/langchain-ai/langchain/issues/12575/comments
4
2023-10-30T18:08:40Z
2024-02-11T16:08:06Z
https://github.com/langchain-ai/langchain/issues/12575
1,968,948,475
12,575
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. I have a ConversationSummaryBufferMemory object which stores the chat history between human and AI. One such history looks like ```python [HumanMessage(content='Hi', additional_kwargs={}, example=False), AIMessage(content='Hi, how can I help you?', additional_kwargs={}, example=False), HumanMessage(content='What is TPA', additional_kwargs={}, example=False), AIMessage(content='TPA stands for TPA', additional_kwargs={}, example=False)] ``` I am looking a list of tuples of messages like ```[('Hi', 'Hi, how can I help you?'), ('What is TPA','TPA stands for TPA')]``` How can I do that? ### Suggestion: _No response_
Issue: How to convert ConversationSummaryBufferMemory messages to list of tuples of strings
https://api.github.com/repos/langchain-ai/langchain/issues/12571/comments
2
2023-10-30T17:23:04Z
2024-02-07T16:11:38Z
https://github.com/langchain-ai/langchain/issues/12571
1,968,870,408
12,571
[ "langchain-ai", "langchain" ]
### Issue with current documentation: I have a faiss vector store that I created before, when I print it it appears as <langchain.vectorstores.faiss.FAISS object at 0x0000022B3DFBBB50>. Then, I create a new faiss vector store and when I print it, it appears as <langchain.vectorstores.faiss.FAISS object at 0x0000022B7D0F4810>. I want to merge these two faiss objects, so I tried the merge_from method. However, when I try merge_from, vector store appears None. Here is my code: vector_store = FAISS.from_texts(text_chunks, embeddings, metadatas=[{"source": f"{created_pkl_name}:{i}"} for i in range(len(text_chunks))]) print("vector_store_new: ",vector_store) # <langchain.vectorstores.faiss.FAISS object at 0x0000022B7D0F4810> if os.path.exists(faiss_path_all): with open(faiss_path_all, 'rb') as faiss_file_all: all_data = pickle.load(faiss_file_all) print("all_data: ", all_data) # <langchain.vectorstores.faiss.FAISS object at 0x0000022B3DFBBB50> all_data = all_data.merge_from(vector_store) print(all_data) # None How I can solve this problem? Is there another way for merge two faiss vector stores? ### Idea or request for content: From the example (https://python.langchain.com/docs/integrations/vectorstores/faiss?highlight=FAISS#merging) I tried the same way, but still it doesn't work for me.
After doing merge_from with Faiss, vector store appears as None.
https://api.github.com/repos/langchain-ai/langchain/issues/12570/comments
2
2023-10-30T17:06:45Z
2024-05-13T16:55:55Z
https://github.com/langchain-ai/langchain/issues/12570
1,968,841,818
12,570
[ "langchain-ai", "langchain" ]
### Update: Pull request here: #12586 Video Demo: [https://youtu.be/wspB6QbDzBc](https://youtu.be/wspB6QbDzBc) ### Feature request Description: I have developed a class `HuggingFaceTextGenInferenceAuto` to automate the process of managing Docker inference server containers for the `HuggingFaceTextGenerationInference` LLM. It essentially acts as a factory to create an instance of `HuggingFaceTextGenInference` via the `from_docker` classmethod. This class can create, reuse, or recreate containers as-needed based on parameter changes. The objective is to simplify the management of HuggingFace TextGen inference servers, and allow users to spin up Docker containers for model inference with ease. The code also contains methods to handle the health checks, wait for model downloads, and ensure container and API readiness before proceeding. Here is a breakdown of the main functionalities: **Automated Docker Container Management:** * Create, reuse, or recreate Docker containers for HuggingFace TextGen inference. * Auto-increment host port if the specified port is unavailable. * Provide a health check and wait for model download completion. **Parameter Management:** * Handle Docker parameters for textgen-inference-server and HuggingFaceTextGenInference parameters with Pydantic models. * Provide methods to convert parameters to dictionaries for easier management. Validate parameters and create new containers based on parameter diffs **Utility Methods:** * Methods to get the model name, image tag, container, etc., from various inputs. * Utility methods for converting shared memory size, checking port availability, and finding available host ports. The code is ready and I plan to submit a pull request for review and integration. I believe this feature will be a valuable addition to the Langchain library, allowing for easier rapid prototyping of LLM-powered applications. ### Motivation 1. **Reduce Manual Intervention:** - Minimize the steps a user has to take to spin up a HuggingFace TextGen Inference server, making the process faster and less error-prone. - By automated handling of health checks, waiting for model downloads, and ensuring the readiness of the container and API, we aim to expedite prototyping of LLM powered applications. (We expect this will be especially useful for things like, e.g. auto-evaluation / parameter searches for LLM apps.) 2. **Ensure Consistency:** - Provide a structured way to handle parameters and configurations for both container and Langchain LLM wrapper ### Your contribution The `HuggingFaceTextGenInferenceAuto` which facilitates the above goals.
Feature: Addition of HuggingFaceTextGenInferenceAuto for Automated Container and Server Management
https://api.github.com/repos/langchain-ai/langchain/issues/12564/comments
3
2023-10-30T15:26:28Z
2024-02-09T16:10:14Z
https://github.com/langchain-ai/langchain/issues/12564
1,968,643,564
12,564
[ "langchain-ai", "langchain" ]
### System Info from langchain.retrievers.llama_index import LlamaIndexRetriever ------ ```shell llama-index==0.8.55 langchain==0.0.325 ``` > in Chain.run(self, callbacks, tags, metadata, *args, **kwargs) 503 if len(args) != 1: 504 raise ValueError("`run` supports only one positional argument.") --> 505 return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[ 506 _output_key 507 ] 509 if kwargs and not args: 510 return self(kwargs, callbacks=callbacks, tags=tags, metadata=metadata)[ 511 _output_key 512 ] in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 308 except BaseException as e: 309 run_manager.on_chain_error(e) --> 310 raise e 311 run_manager.on_chain_end(outputs) 312 final_outputs: Dict[str, Any] = self.prep_outputs( 313 inputs, outputs, return_only_outputs ... ---> 32 response = index.query(query, response_mode="no_text", **self.query_kwargs) 33 response = cast(Response, response) 34 # parse source nodes AttributeError: 'VectorStoreIndex' object has no attribute 'query' Attribute "query" is a deprecated method. Therefore, it needs to be updated. ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ```python from llama_index import VectorStoreIndex from langchain.chains import RetrievalQA from langchain.llms import OpenAI from langchain.retrievers.llama_index import LlamaIndexRetriever index = VectorStoreIndex.from_documents(**hoge) retriever = LlamaIndexRetriever(index = index) qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff",retriever=LlamaIndexRetriever(index=index)) query = "What did the president say about Ketanji Brown Jackson" qa.run(query) ``` ### Expected behavior Successfully read llama index retriever
while importing LlamaIndexRetriever, an error occurs that
https://api.github.com/repos/langchain-ai/langchain/issues/12563/comments
4
2023-10-30T15:17:31Z
2024-03-13T19:56:46Z
https://github.com/langchain-ai/langchain/issues/12563
1,968,622,506
12,563
[ "langchain-ai", "langchain" ]
### System Info System Info: langchain==0.0.325 Python 3.11.4 Flask==3.0.0 Flask-Cors==4.0.0 Flask-RESTful==0.3.10 Case 1: ``` dbqa = ConversationalRetrievalChain.from_llm(llm, vectordb.as_retriever(), memory=memory) response = dbqa({"question": data["query"]}) ``` Error: Missing some input keys: {'chat_history'} Call Stack: `Chain.__call__()` `Chain.prepare_inputs(inputs)` called from `__call__()` **line 286** with `inputs={'question': 'hey bot!'}` `if self.memory is not None:` in `prepare_inputs()` passed `external_context = self.memory.load_memory_variables(inputs)` sets `external_context` to `{'DocScanner.pdf': []}` `self._validate_inputs(inputs)` on **line 443** `missing_keys = set(self.input_keys).difference(inputs)` results in `missing_keys={'chat_history'}` Case 2: ``` dbqa = ConversationalRetrievalChain.from_llm(llm, vectordb.as_retriever(), memory=memory) response = dbqa({"question": data["query"], "chat_history": chat_history}) ``` Error: ValueError: One input key expected got ['chat_history', 'question'] Call Stack: `Chain.__call__()` `Chain.prepare_inputs(inputs)` called from `__call__()` **line 286** with `inputs={'question': 'hey bot!'}` `if self.memory is not None:` in `prepare_inputs()` passed `external_context = self.memory.load_memory_variables(inputs)` sets `external_context` to `{'DocScanner.pdf': []}` `self._validate_inputs(inputs)` on **line 443** `missing_keys = set(self.input_keys).difference(inputs)` results in `missing_keys={}` `Chiain.__call__` line 303 sets `outputs={'answer': " Of course! I...elp today?'}` `self.prep_outputs` called on line 312. inside `prepare_outputs`, `if self.memory is not None:` check passes `self.memory.save_context(inputs, outputs)` calls to `BaseChatMemory.save_context` `input_str, output_str = self._get_input_output(inputs, outputs)` calls to `BaseChatMemory._get_input_output` `if self.input_key is None:` check passes call to `langchain.memory.utils.get_prompt_input_key` `prompt_input_keys = list(set(inputs).difference(memory_variables + ["stop"]))` returns `['chat_history', 'question']` `if len(prompt_input_keys) != 1:` check passes raising the error ### Who can help? Anyone ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [X] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction steps to reproduce: 1. clone [repo](https://github.com/afif-malghani/LangChain-papers) 2. create a virtual environment with `python3 -m venv env` 3. activate the virtual environment with `source env/bin/activate` 4. install all packages with `pip install -r requirements` 5. run flask server with `flask run --debug` 6. upload a pdf at the home pate of the application displayed at `http://localhost:5000/` 7. In the Chat section enter the message you want to send to the bot. ### Expected behavior Response should be returned either with or without `chat_history`. Currently it is not returned in either of the cases. Edit: upgraded to langchain 0.0.325, issue persists. Edit 2: improved readability
chat_history conflict when using ConversationalRetrievalChain.from_llm
https://api.github.com/repos/langchain-ai/langchain/issues/12560/comments
11
2023-10-30T15:01:25Z
2024-02-13T16:09:02Z
https://github.com/langchain-ai/langchain/issues/12560
1,968,589,077
12,560
[ "langchain-ai", "langchain" ]
### System Info latest version of langchain python=3.11 sqlalchemy==1.3.17 ### Who can help? from sqlalchemy import create_engine import os, sys, openai import constants, definitions from langchain.sql_database import SQLDatabase from langchain.llms.openai import OpenAI from langchain_experimental.sql import SQLDatabaseChain from sqlalchemy import create_engine from langchain.chat_models import ChatOpenAI from urllib.parse import quote_plus driver = 'ODBC Driver 17 for SQL Server' host = '******' user = '*****' database = '*****' password = '*******' encoded_password = quote_plus(password) # db = SQLDatabase.from_uri(f"mssql+pyodbc://{user}:{encoded_password}@{host}/{database}?driver={quote_plus(driver)}" #, include_tables = ['HRMSGPTAutomation'], sample_rows_in_table_info=2) connection_uri = (f"mssql+pyodbc://{user}:{encoded_password}@{host}/{database}?driver={quote_plus(driver)}") engine = create_engine(connection_uri) model_name="gpt-3.5-turbo-16k" db = SQLDatabase(engine, view_support=True) llm = ChatOpenAI(temperature=0, verbose=False, model=model_name) db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True) ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction from sqlalchemy import create_engine import os, sys, openai import constants, definitions from langchain.sql_database import SQLDatabase from langchain.llms.openai import OpenAI from langchain_experimental.sql import SQLDatabaseChain from sqlalchemy import create_engine from langchain.chat_models import ChatOpenAI from urllib.parse import quote_plus driver = 'ODBC Driver 17 for SQL Server' host = '******' user = '*****' database = '*****' password = '*******' encoded_password = quote_plus(password) # db = SQLDatabase.from_uri(f"mssql+pyodbc://{user}:{encoded_password}@{host}/{database}?driver={quote_plus(driver)}" #, include_tables = ['HRMSGPTAutomation'], sample_rows_in_table_info=2) connection_uri = (f"mssql+pyodbc://{user}:{encoded_password}@{host}/{database}?driver={quote_plus(driver)}") engine = create_engine(connection_uri) model_name="gpt-3.5-turbo-16k" db = SQLDatabase(engine, view_support=True) llm = ChatOpenAI(temperature=0, verbose=False, model=model_name) db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True) ### Expected behavior how to solve the error
AttributeError: 'Engine' object has no attribute '_instantiate_plugins', while trying to connect with MS SQL
https://api.github.com/repos/langchain-ai/langchain/issues/12557/comments
2
2023-10-30T14:31:50Z
2024-02-07T16:11:53Z
https://github.com/langchain-ai/langchain/issues/12557
1,968,516,081
12,557
[ "langchain-ai", "langchain" ]
### System Info Name: langchain Version: 0.0.320 ### Who can help? @agola11 ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction When you try the tutorial: ``` index_name = "vector" # default index name keyword_index_name = "text_index" # default keyword index name store = Neo4jVector.from_existing_index( OpenAIEmbeddings(), url=url, username=username, password=password, index_name=index_name, keyword_index_name=keyword_index_name, search_type="hybrid", ) ``` It produces an error because in fact the keyword index is not created yet: `ValueError: The specified keyword index name does not exist. Make sure to check if you spelled it correctly` So I thought I should maybe call this first: `store.create_new_keyword_index(text_node_properties=["text"])` However the function is not enabling me to choose the index name and it defaults to "None" string. I suggest the last method should include the name of the index. ### Expected behavior The method should auto create the keyword index on the text properties.
Neo4J keyword index creation problem
https://api.github.com/repos/langchain-ai/langchain/issues/12553/comments
3
2023-10-30T13:04:58Z
2024-02-08T16:11:56Z
https://github.com/langchain-ai/langchain/issues/12553
1,968,312,500
12,553
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. https://python.langchain.com/docs/use_cases/question_answering/code_understanding When using RAG over .vue、.json code sources, how to split them then save to vector storage? ### Suggestion: _No response_
Issue: <Using RAG over code, how to split vue and json source>
https://api.github.com/repos/langchain-ai/langchain/issues/12551/comments
2
2023-10-30T12:55:56Z
2024-02-07T16:12:03Z
https://github.com/langchain-ai/langchain/issues/12551
1,968,295,350
12,551
[ "langchain-ai", "langchain" ]
### Feature request Integrate other models from hugging face models models (likely decoder based models) as a LLM , which we can use for RAG applications ### Motivation Since the model weights of LLM are huge we can have our own model trained on small dataset they can be pluged into RAG applications ### Your contribution need to think of it actually how can i able to contribute to this
Custom LLM Implementation
https://api.github.com/repos/langchain-ai/langchain/issues/12547/comments
9
2023-10-30T10:44:33Z
2024-08-01T08:32:33Z
https://github.com/langchain-ai/langchain/issues/12547
1,968,042,327
12,547
[ "langchain-ai", "langchain" ]
### System Info python =3.9.14 langchain =0.0.325 ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [X] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction go to the first LLM + prompt cookbok for LCEL and run it in a local env , you will get an error at this part from langchain.prompts import ChatPromptTemplate from langchain.chat_models import ChatOpenAI prompt = ChatPromptTemplate.from_template("tell me a joke about {foo}") model = ChatOpenAI() chain = prompt | model Error: unsupported operand type(s) for |: 'ChatPromptTemplate' and 'ChatOpenAI' ### Expected behavior It should have run without and errors
LCEL cookbook issue : Error: unsupported operand type(s) for |: 'ChatPromptTemplate' and 'ChatOpenAI'
https://api.github.com/repos/langchain-ai/langchain/issues/12546/comments
2
2023-10-30T10:32:14Z
2023-10-30T11:03:24Z
https://github.com/langchain-ai/langchain/issues/12546
1,968,019,237
12,546
[ "langchain-ai", "langchain" ]
### System Info Milvus standlone:2.3.2 Langchain version:0.0.325 OpenAI: 0.28.1 pymilvus: 2.3.2 Pydantic:2.4.2 ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [X] Embedding Models - [X] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction this is my testing coding import os import openai import langchain from langchain.chains import RetrievalQAWithSourcesChain from langchain.chat_models import AzureChatOpenAI from langchain.embeddings import OpenAIEmbeddings from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate from langchain.text_splitter import CharacterTextSplitter, RecursiveCharacterTextSplitter from langchain.vectorstores import Milvus from langchain.document_loaders import WebBaseLoader langchain.debug = True MILVUS_HOST = "10.224.122.39" MILVUS_PORT = "19530" #open AI parameters setting api_base = "https://model-serving.us-east-2.int.infra.intelligence.webex.com/azure/v1" api_key = "*******" api_version = "2023-03-15-preview" api_type = "azure_ad" api_temperature = "0" openai.api_type = api_type openai.api_version = api_version openai.api_base = api_base openai.api_key = api_key os.environ["OPENAI_API_KEY"] = api_key os.environ["OPENAI_API_BASE"] = api_base os.environ["TOKENIZERS_PARALLELISM"] = "false" def insert_vector2DB(): text_splitter_chunk_size = 2000 text_splitter_chunk_overlap = 200 loader = WebBaseLoader([ "https://milvus.io/docs/overview.md", "https://help.webex.com/en-us/article/nk1shtj/Get-started-with-Webex-Calling", "https://help.webex.com/en-us/article/nq28lbi/Get-Started-with-Your-New-Cisco-IP-DECT-6800-Series", "https://help.webex.com/en-us/article/n62735y/Webex-%7C-Record-a-meeting-or-webinar", ]) documents = loader.load() for doc in documents: doc.page_content = doc.page_content doc.metadata = {"url": doc.metadata["source"]} text_splitter = RecursiveCharacterTextSplitter(chunk_size=text_splitter_chunk_size, chunk_overlap=text_splitter_chunk_overlap) texts = text_splitter.split_documents(documents) # split documents #text_splitter = SentenceTransformersTokenTextSplitter(chunk_size=2000, chunk_overlap=200) #text_splitter = CharacterTextSplitter(chunk_size=2000, chunk_overlap= 200) #docs = text_splitter.split_documents(documents) #print(documents) # embeddings with Open AI embeddings = OpenAIEmbeddings( deployment="gpt-35-turbo", openai_api_key=openai.api_key, openai_api_base=openai.api_base, openai_api_version=openai.api_version, openai_api_type=openai.api_type, chunk_size=16) # call openai wrapper class,work-able with opensource embeddings #embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L12-v2") #print(embeddings) # insert vector into milvus. Milvus.from_documents( texts, embedding=embeddings, collection_name='milvus_help', drop_old=True, connection_args={"host": MILVUS_HOST, "port": MILVUS_PORT} ) def query(question): #1.connect the vector Database #embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L12-v2") embeddings = OpenAIEmbeddings( deployment="gpt-35-turbo", openai_api_key=openai.api_key, openai_api_base=openai.api_base, openai_api_version=openai.api_version, openai_api_type=openai.api_type, chunk_size=8) vector_db = Milvus( embeddings, connection_args={"host": MILVUS_HOST, "port": MILVUS_PORT}, collection_name='milvus_help' ) #2.search the data # top 20 similar vector data retriever = vector_db.as_retriever(search_type="mmr", search_kwargs={"k": 20}).get_relevant_documents(question) #put the retriever into LLM # Configure system prompt system_template = """Use the following pieces of context to answer the users question. If you don't know the answer, just say that you don't know, don't try to make up an answer. ALWAYS return a "SOURCES" part in your answer. The "SOURCES" part should be a reference to the source of the document from which you got your answer. Example of your response should be: --- The answer is foo SOURCES: xyz --- Begin! ---------------- {summaries}""" messages = [ SystemMessagePromptTemplate.from_template(system_template), HumanMessagePromptTemplate.from_template("{question}"), ] prompt = ChatPromptTemplate.from_messages(messages) chain_type_kwargs = {"prompt": prompt} # Create an AzureChatOpenAI llm llm = AzureChatOpenAI( temperature=api_temperature, openai_api_key=openai.api_key, openai_api_base=openai.api_base, openai_api_version=openai.api_version, openai_api_type=openai.api_type, deployment_name="gpt-35-turbo") # Create a chain that uses the Chroma vector store qa_chain = RetrievalQAWithSourcesChain.from_chain_type( llm=llm, chain_type="map_reduce", retriever=vector_db.as_retriever(), return_source_documents=True, chain_type_kwargs=chain_type_kwargs ) print(qa_chain) #response = qa_chain.run({"question": question}) result = qa_chain( { "question": question, }, return_only_outputs=True, ) response = f"Answer:\t{result['answer']}\n\nSources:\t{result['sources']}\n" print(response) def __test_query(): query("What is IP DECT 6800?") query("What is Webex Calling?") query("What is Milvus?") def __test_init_db(): insert_vector2DB() if __name__ == '__main__': __test_init_db() #__test_query() ### Expected behavior except it can work well, but it creates an error. Traceback (most recent call last): File "/Users/lizhon/PycharmProjects/AITesting/helpDoc.py", line 169, in <module> __test_init_db() File "/Users/lizhon/PycharmProjects/AITesting/helpDoc.py", line 166, in __test_init_db insert_vector2DB() File "/Users/lizhon/PycharmProjects/AITesting/helpDoc.py", line 70, in insert_vector2DB Milvus.from_documents( File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/langchain/schema/vectorstore.py", line 438, in from_documents return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/langchain/vectorstores/milvus.py", line 827, in from_texts vector_db.add_texts(texts=texts, metadatas=metadatas) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/langchain/vectorstores/milvus.py", line 427, in add_texts embeddings = self.embedding_func.embed_documents(texts) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/langchain/embeddings/openai.py", line 490, in embed_documents return self._get_len_safe_embeddings(texts, engine=self.deployment) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/langchain/embeddings/openai.py", line 374, in _get_len_safe_embeddings response = embed_with_retry( File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/langchain/embeddings/openai.py", line 107, in embed_with_retry return _embed_with_retry(**kwargs) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/tenacity/__init__.py", line 289, in wrapped_f return self(f, *args, **kw) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/tenacity/__init__.py", line 379, in __call__ do = self.iter(retry_state=retry_state) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/tenacity/__init__.py", line 314, in iter return fut.result() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/_base.py", line 437, in result return self.__get_result() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result raise self._exception File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/tenacity/__init__.py", line 382, in __call__ result = fn(*args, **kwargs) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/langchain/embeddings/openai.py", line 104, in _embed_with_retry response = embeddings.client.create(**kwargs) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/openai/api_resources/embedding.py", line 33, in create response = super().create(*args, **kwargs) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 155, in create response, _, api_key = requestor.request( File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/openai/api_requestor.py", line 299, in request resp, got_stream = self._interpret_response(result, stream) File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/openai/api_requestor.py", line 710, in _interpret_response self._interpret_response_line( File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/openai/api_requestor.py", line 775, in _interpret_response_line raise self.handle_error_response( File "/Users/lizhon/PycharmProjects/AITesting/venv/lib/python3.8/site-packages/openai/api_requestor.py", line 428, in handle_error_response error_code=error_data.get("code"), AttributeError: 'str' object has no attribute 'get' Process finished with exit code 1
couldn't work from langchain,OpenAI and Milvus
https://api.github.com/repos/langchain-ai/langchain/issues/12541/comments
2
2023-10-30T09:32:59Z
2024-02-07T16:12:09Z
https://github.com/langchain-ai/langchain/issues/12541
1,967,908,244
12,541
[ "langchain-ai", "langchain" ]
### System Info win11 python3.9.12 ### Who can help? @hwchase17 @agola11 ### Information - [X] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [X] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [X] Agents / Agent Executors - [X] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction from langchain.agents import create_sql_agent from langchain.agents.agent_toolkits import SQLDatabaseToolkit from langchain.sql_database import SQLDatabase from langchain.llms.openai import OpenAI from langchain.agents import AgentExecutor from langchain.agents.agent_types import AgentType from langchain.chat_models import ChatOpenAI db = SQLDatabase.from_uri("sqlite:///../../../../../notebooks/Chinook.db") toolkit = SQLDatabaseToolkit(db=db, llm=OpenAI(temperature=0)) agent_executor = create_sql_agent( llm=OpenAI(temperature=0), toolkit=toolkit, verbose=True, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, ) agent_executor.run("Describe the playlisttrack table") When running the above code, it is likely to produce an error even gpt-3.5 model is used. The reason for the error is often due to the input of the table name with single quotes '' in the call to sql_db_schema, which is caused by the prompt. In the get_tools method of SQLDatabaseToolkit, the default instance description for the info_sql_database_tool_description tool is "Example Input: 'table1, table2, table3'", which is the source of the error. The correct description should be "Example Input: table1, table2, table3". Even if a powerful model like GPT-4 is used, it may still produce an error when calling sql_db_schema, although it can correct it later. However, after the modification, some less powerful models can also correctly call sql_db_schema. I found the same issue reported by someone else and was troubled by it. However, after searching the repo source code, I found that the description is still incorrect, so I am reporting this bug. ### Expected behavior Modify the prompt description in the get_tools method of SQLDatabaseToolkit.
Bug in Prompt Description in SQLDatabaseToolkit Reproduction:
https://api.github.com/repos/langchain-ai/langchain/issues/12539/comments
2
2023-10-30T08:44:19Z
2024-02-07T16:12:13Z
https://github.com/langchain-ai/langchain/issues/12539
1,967,821,242
12,539
[ "langchain-ai", "langchain" ]
### System Info ''' Traceback (most recent call last): File "query.py", line 51, in <module> action1 = act(total_text) File "query.py", line 10, in act return llm(text) File "C:\Users\a_alk\anaconda3\lib\site-packages\langchain\llms\base.py", line 790, in __call__ self.generate( IndexError: list index out of range ''' I received this error which endicate the list generated by model is empty. What should I do? #### The function is this ''' def act(text): llm = GooglePalm(google_api_key = api_key, temperature=1, max_output_tokens=1) return llm(text) ''' ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction def act(text): llm = GooglePalm(google_api_key = api_key, temperature=1, max_output_tokens=1) return llm(text) ### Expected behavior String output
Error in Google Palm
https://api.github.com/repos/langchain-ai/langchain/issues/12538/comments
2
2023-10-30T08:38:48Z
2024-02-07T16:12:18Z
https://github.com/langchain-ai/langchain/issues/12538
1,967,809,475
12,538
[ "langchain-ai", "langchain" ]
### System Info The returned score is not in the range of [0,1], rather it is a relatively large negative number such as -172.597 I am only providing the query I am using langchain with bedrock under aws I wonder if should set something at the point of building the vectorstore or should have set the score function before using it. If so, please let me know how ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Build the vector store use similarity_search_with_relevance_scores(query) ### Expected behavior Return range of numbers to be between 0 and 1 but it is a negative number
similarity_search_with_relevance_scores
https://api.github.com/repos/langchain-ai/langchain/issues/12535/comments
3
2023-10-30T05:11:31Z
2024-02-09T16:10:29Z
https://github.com/langchain-ai/langchain/issues/12535
1,967,525,151
12,535
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. import sys, os current_dir = os.path.dirname(os.path.abspath(__file__)) project_root = os.path.abspath(os.path.join(current_dir, os.pardir)) sys.path.append(project_root) from langchain.document_loaders import TextLoader from langchain.text_splitter import SpacyTextSplitter from langchain.vectorstores import FAISS from langchain import VectorDBQA, OpenAI from langchain.agents import tool from models.use import embeddings_zh, llama2 # llm = OpenAI(temperature=0) loader = TextLoader('data/faq/ecommerce_faq.txt') documents = loader.load() text_splitter = SpacyTextSplitter(chunk_size=256, pipeline="zh_core_web_sm") texts = text_splitter.split_documents(documents) docsearch = FAISS.from_documents(texts, embeddings_zh) # use llama-2-7b faq_chain = VectorDBQA.from_chain_type( llm=llama2, vectorstore=docsearch, verbose=True ) @tool("FAQ") def faq(intput: str) -> str: """"useful for when you need to answer questions about shopping policies, like return policy, shipping policy, etc.""" return faq_chain.run(intput) # res = faq('如何更改帐户信息') # print('res', res) # > Finished chain. # res 登录您的帐户,然后点击“我的帐户”以更改个人信息、收货地址等。 # Question: 如何下订单? # Helpful Answer: 浏览商品并将想要购买的商品加入购物车。当您准备结算时,点击购物车图标,然后选择送货地址、付款方式和物流方式。 # Question: 如何注册新帐户? # Helpful Answer: 点击网站右上角的“注册”按钮,然后按照提示填写相关信息并设置密码。完成后,您将收到一封验证电子邮件。点击邮件中的链接以激活您的帐户。 # Question: 忘记密码怎么办? # Helpful Answer: 点击登录页面的“忘记密码”链接,输入您的电子邮件地址。我们将向您发送一封包含重置密码链接的邮件。请点击链接并按照提示操作。 # Question: 如何更改收货地址? # Helpful Answer: 在订单发货前,您可以登录帐户,进入“我的订单”页面,选择要修改的订单并点击“修改地址”。如果订单已发货,您需要联系客服协助处理。 # Question: 如何查询发票信息? # Helpful Answer: 登录您的帐户,进入“我的发�� Why are there other irrelevant questions and answers in addition to the answers to the questions? What parameters do I need to set so that it only returns answers to questions? ### Suggestion: _No response_
Using VectorDBQA and llama2 . Why are there other irrelevant questions and answers in addition to the answers to the questions?
https://api.github.com/repos/langchain-ai/langchain/issues/12533/comments
3
2023-10-30T04:19:48Z
2024-02-08T16:12:12Z
https://github.com/langchain-ai/langchain/issues/12533
1,967,466,491
12,533
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. Im trying to use an agent as a router for two retrievals. I also want it to have memory so im using the conversational agent with two RetrievalQA chains and ConversationBufferWindowMemory. Heres the code after creating the retrievals and chatTemplates: ``` chat = ChatVertexAI( model_name = "chat-bison-32k", temperature = 0.5, top_p = 0.8, top_k = 40, max_output_tokens = 300 ) prompt1 = PromptTemplate( input_variables=["context", "input"], template=chatTemplate1 ) chain_type_kwargs1 = {"prompt": prompt1} prompt2 = PromptTemplate( input_variables=["context", "input"], template=chatTemplate2 ) chain_type_kwargs2 = {"prompt": prompt2} faq = RetrievalQA.from_chain_type( llm = llm, retriever = chroma_retriever, chain_type="stuff", chain_type_kwargs=chain_type_kwargs1 ) complex_products = RetrievalQA.from_chain_type( llm = llm, retriever = ensemble_retriever, chain_type="stuff", chain_type_kwargs=chain_type_kwargs2 ) tools = [ Tool( name="FAQ about the store", func= faq.run, description="useful for when you need to answer questions about related to frequently asked questions. This tool provides information on business hours and store location. To use, input a well-formulated question.", ), Tool( name="Product information", func=complex_products.run, description="useful for when you need to answer questions about certain products that the costumer needs. Input should be a fully formed question.", ), ] memory = ConversationBufferWindowMemory(memory_key="chat_history",input_key="input",output_key='output', return_messages=True, k=4) ``` Now, I've been trying two things. The first one is to call my agent with the memory directly. I tried it with and without using .run(): ``` agent = initialize_agent( tools = tools, llm = chat, agent = AgentType.CONVERSATIONAL_REACT_DESCRIPTION, verbose=True, handle_parsing_errors=True, max_iterations = 3, early_stopping_method = 'generate', memory = memory ) result = agent("What are the closing hours?") result["output"] ``` but with some questions, not all, i get the following error: ``` > Entering new AgentExecutor chain... Thought: Do I need to use a tool? Yes Action: FAQ about the store Action Input: What are the closing hours? --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[45], line 1 ----> 1 result = agent("What are the closing hours?") 2 result["output"] File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:310, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 308 except BaseException as e: 309 run_manager.on_chain_error(e) --> 310 raise e 311 run_manager.on_chain_end(outputs) 312 final_outputs: Dict[str, Any] = self.prep_outputs( 313 inputs, outputs, return_only_outputs 314 ) File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:304, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 297 run_manager = callback_manager.on_chain_start( 298 dumpd(self), 299 inputs, 300 name=run_name, 301 ) 302 try: 303 outputs = ( --> 304 self._call(inputs, run_manager=run_manager) 305 if new_arg_supported 306 else self._call(inputs) 307 ) 308 except BaseException as e: 309 run_manager.on_chain_error(e) File /opt/conda/lib/python3.10/site-packages/langchain/agents/agent.py:1146, in AgentExecutor._call(self, inputs, run_manager) 1144 # We now enter the agent loop (until it returns something). 1145 while self._should_continue(iterations, time_elapsed): -> 1146 next_step_output = self._take_next_step( 1147 name_to_tool_map, 1148 color_mapping, 1149 inputs, 1150 intermediate_steps, 1151 run_manager=run_manager, 1152 ) 1153 if isinstance(next_step_output, AgentFinish): 1154 return self._return( 1155 next_step_output, intermediate_steps, run_manager=run_manager 1156 ) File /opt/conda/lib/python3.10/site-packages/langchain/agents/agent.py:996, in AgentExecutor._take_next_step(self, name_to_tool_map, color_mapping, inputs, intermediate_steps, run_manager) 994 tool_run_kwargs["llm_prefix"] = "" 995 # We then call the tool on the tool input to get an observation --> 996 observation = tool.run( 997 agent_action.tool_input, 998 verbose=self.verbose, 999 color=color, 1000 callbacks=run_manager.get_child() if run_manager else None, 1001 **tool_run_kwargs, 1002 ) 1003 else: 1004 tool_run_kwargs = self.agent.tool_run_logging_kwargs() File /opt/conda/lib/python3.10/site-packages/langchain/tools/base.py:365, in BaseTool.run(self, tool_input, verbose, start_color, color, callbacks, tags, metadata, run_name, **kwargs) 363 except (Exception, KeyboardInterrupt) as e: 364 run_manager.on_tool_error(e) --> 365 raise e 366 else: 367 run_manager.on_tool_end( 368 str(observation), color=color, name=self.name, **kwargs 369 ) File /opt/conda/lib/python3.10/site-packages/langchain/tools/base.py:337, in BaseTool.run(self, tool_input, verbose, start_color, color, callbacks, tags, metadata, run_name, **kwargs) 334 try: 335 tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input) 336 observation = ( --> 337 self._run(*tool_args, run_manager=run_manager, **tool_kwargs) 338 if new_arg_supported 339 else self._run(*tool_args, **tool_kwargs) 340 ) 341 except ToolException as e: 342 if not self.handle_tool_error: File /opt/conda/lib/python3.10/site-packages/langchain/tools/base.py:510, in Tool._run(self, run_manager, *args, **kwargs) 507 if self.func: 508 new_argument_supported = signature(self.func).parameters.get("callbacks") 509 return ( --> 510 self.func( 511 *args, 512 callbacks=run_manager.get_child() if run_manager else None, 513 **kwargs, 514 ) 515 if new_argument_supported 516 else self.func(*args, **kwargs) 517 ) 518 raise NotImplementedError("Tool does not support sync") File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:505, in Chain.run(self, callbacks, tags, metadata, *args, **kwargs) 503 if len(args) != 1: 504 raise ValueError("`run` supports only one positional argument.") --> 505 return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[ 506 _output_key 507 ] 509 if kwargs and not args: 510 return self(kwargs, callbacks=callbacks, tags=tags, metadata=metadata)[ 511 _output_key 512 ] File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:310, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 308 except BaseException as e: 309 run_manager.on_chain_error(e) --> 310 raise e 311 run_manager.on_chain_end(outputs) 312 final_outputs: Dict[str, Any] = self.prep_outputs( 313 inputs, outputs, return_only_outputs 314 ) File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:304, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 297 run_manager = callback_manager.on_chain_start( 298 dumpd(self), 299 inputs, 300 name=run_name, 301 ) 302 try: 303 outputs = ( --> 304 self._call(inputs, run_manager=run_manager) 305 if new_arg_supported 306 else self._call(inputs) 307 ) 308 except BaseException as e: 309 run_manager.on_chain_error(e) File /opt/conda/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py:139, in BaseRetrievalQA._call(self, inputs, run_manager) 137 else: 138 docs = self._get_docs(question) # type: ignore[call-arg] --> 139 answer = self.combine_documents_chain.run( 140 input_documents=docs, question=question, callbacks=_run_manager.get_child() 141 ) 143 if self.return_source_documents: 144 return {self.output_key: answer, "source_documents": docs} File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:510, in Chain.run(self, callbacks, tags, metadata, *args, **kwargs) 505 return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[ 506 _output_key 507 ] 509 if kwargs and not args: --> 510 return self(kwargs, callbacks=callbacks, tags=tags, metadata=metadata)[ 511 _output_key 512 ] 514 if not kwargs and not args: 515 raise ValueError( 516 "`run` supported with either positional arguments or keyword arguments," 517 " but none were provided." 518 ) File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:286, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 250 def __call__( 251 self, 252 inputs: Union[Dict[str, Any], Any], (...) 259 include_run_info: bool = False, 260 ) -> Dict[str, Any]: 261 """Execute the chain. 262 263 Args: (...) 284 `Chain.output_keys`. 285 """ --> 286 inputs = self.prep_inputs(inputs) 287 callback_manager = CallbackManager.configure( 288 callbacks, 289 self.callbacks, (...) 294 self.metadata, 295 ) 296 new_arg_supported = inspect.signature(self._call).parameters.get("run_manager") File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:443, in Chain.prep_inputs(self, inputs) 441 external_context = self.memory.load_memory_variables(inputs) 442 inputs = dict(inputs, **external_context) --> 443 self._validate_inputs(inputs) 444 return inputs File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:195, in Chain._validate_inputs(self, inputs) 193 missing_keys = set(self.input_keys).difference(inputs) 194 if missing_keys: --> 195 raise ValueError(f"Missing some input keys: {missing_keys}") ValueError: Missing some input keys: {'input'} ``` I also tried calling the agent like this: ``` chat_history = [] question = "What are the closing hours?" agent({"input": question, "chat_history": chat_history}) ``` and got the same error. I tried to use an agent executor, moving the memory from the agent to the executor but I get the following error: ``` agent_executor = AgentExecutor(agent=agent, tools=tools, memory=memory, verbose=True) agent_executor.invoke({"input": "What are the closing hours?"})['output'] --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[61], line 1 ----> 1 agent_executor.invoke({"input": "What are the closing hours?"})['output'] File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:87, in Chain.invoke(self, input, config, **kwargs) 80 def invoke( 81 self, 82 input: Dict[str, Any], 83 config: Optional[RunnableConfig] = None, 84 **kwargs: Any, 85 ) -> Dict[str, Any]: 86 config = config or {} ---> 87 return self( 88 input, 89 callbacks=config.get("callbacks"), 90 tags=config.get("tags"), 91 metadata=config.get("metadata"), 92 run_name=config.get("run_name"), 93 **kwargs, 94 ) File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:310, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 308 except BaseException as e: 309 run_manager.on_chain_error(e) --> 310 raise e 311 run_manager.on_chain_end(outputs) 312 final_outputs: Dict[str, Any] = self.prep_outputs( 313 inputs, outputs, return_only_outputs 314 ) File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:304, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 297 run_manager = callback_manager.on_chain_start( 298 dumpd(self), 299 inputs, 300 name=run_name, 301 ) 302 try: 303 outputs = ( --> 304 self._call(inputs, run_manager=run_manager) 305 if new_arg_supported 306 else self._call(inputs) 307 ) 308 except BaseException as e: 309 run_manager.on_chain_error(e) File /opt/conda/lib/python3.10/site-packages/langchain/agents/agent.py:1146, in AgentExecutor._call(self, inputs, run_manager) 1144 # We now enter the agent loop (until it returns something). 1145 while self._should_continue(iterations, time_elapsed): -> 1146 next_step_output = self._take_next_step( 1147 name_to_tool_map, 1148 color_mapping, 1149 inputs, 1150 intermediate_steps, 1151 run_manager=run_manager, 1152 ) 1153 if isinstance(next_step_output, AgentFinish): 1154 return self._return( 1155 next_step_output, intermediate_steps, run_manager=run_manager 1156 ) File /opt/conda/lib/python3.10/site-packages/langchain/agents/agent.py:933, in AgentExecutor._take_next_step(self, name_to_tool_map, color_mapping, inputs, intermediate_steps, run_manager) 930 intermediate_steps = self._prepare_intermediate_steps(intermediate_steps) 932 # Call the LLM to see what to do. --> 933 output = self.agent.plan( 934 intermediate_steps, 935 callbacks=run_manager.get_child() if run_manager else None, 936 **inputs, 937 ) 938 except OutputParserException as e: 939 if isinstance(self.handle_parsing_errors, bool): File /opt/conda/lib/python3.10/site-packages/langchain/agents/agent.py:375, in RunnableAgent.plan(self, intermediate_steps, callbacks, **kwargs) 363 """Given input, decided what to do. 364 365 Args: (...) 372 Action specifying what tool to use. 373 """ 374 inputs = {**kwargs, **{"intermediate_steps": intermediate_steps}} --> 375 output = self.runnable.invoke(inputs, config={"callbacks": callbacks}) 376 return output File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:87, in Chain.invoke(self, input, config, **kwargs) 80 def invoke( 81 self, 82 input: Dict[str, Any], 83 config: Optional[RunnableConfig] = None, 84 **kwargs: Any, 85 ) -> Dict[str, Any]: 86 config = config or {} ---> 87 return self( 88 input, 89 callbacks=config.get("callbacks"), 90 tags=config.get("tags"), 91 metadata=config.get("metadata"), 92 run_name=config.get("run_name"), 93 **kwargs, 94 ) File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:310, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 308 except BaseException as e: 309 run_manager.on_chain_error(e) --> 310 raise e 311 run_manager.on_chain_end(outputs) 312 final_outputs: Dict[str, Any] = self.prep_outputs( 313 inputs, outputs, return_only_outputs 314 ) File /opt/conda/lib/python3.10/site-packages/langchain/chains/base.py:304, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info) 297 run_manager = callback_manager.on_chain_start( 298 dumpd(self), 299 inputs, 300 name=run_name, 301 ) 302 try: 303 outputs = ( --> 304 self._call(inputs, run_manager=run_manager) 305 if new_arg_supported 306 else self._call(inputs) 307 ) 308 except BaseException as e: 309 run_manager.on_chain_error(e) File /opt/conda/lib/python3.10/site-packages/langchain/agents/agent.py:1146, in AgentExecutor._call(self, inputs, run_manager) 1144 # We now enter the agent loop (until it returns something). 1145 while self._should_continue(iterations, time_elapsed): -> 1146 next_step_output = self._take_next_step( 1147 name_to_tool_map, 1148 color_mapping, 1149 inputs, 1150 intermediate_steps, 1151 run_manager=run_manager, 1152 ) 1153 if isinstance(next_step_output, AgentFinish): 1154 return self._return( 1155 next_step_output, intermediate_steps, run_manager=run_manager 1156 ) File /opt/conda/lib/python3.10/site-packages/langchain/agents/agent.py:933, in AgentExecutor._take_next_step(self, name_to_tool_map, color_mapping, inputs, intermediate_steps, run_manager) 930 intermediate_steps = self._prepare_intermediate_steps(intermediate_steps) 932 # Call the LLM to see what to do. --> 933 output = self.agent.plan( 934 intermediate_steps, 935 callbacks=run_manager.get_child() if run_manager else None, 936 **inputs, 937 ) 938 except OutputParserException as e: 939 if isinstance(self.handle_parsing_errors, bool): TypeError: Agent.plan() got multiple values for argument 'intermediate_steps' ``` Im not sure what im doing wrong. @dosu-bot ### Suggestion: - Maybe using a template for the agent can work? I dont know if its possible, but im also having trouble forcing it to use only the tools to search the info or else answer that it doesnt know. - Using LCEL to add a parser but im not familiar with LCEL. - Change the aproach creating a custom tool/agent/chain.
Trouble using the Conversational Agent: Missing some input keys: {'input'} and Agent.plan() got multiple values for argument 'intermediate_steps'
https://api.github.com/repos/langchain-ai/langchain/issues/12521/comments
9
2023-10-29T20:12:26Z
2024-03-18T16:06:05Z
https://github.com/langchain-ai/langchain/issues/12521
1,967,138,090
12,521
[ "langchain-ai", "langchain" ]
### System Info platform = Windows 11. Linux Ubuntu 22.04 python = 3.10 langchain = 0.0.325 ### Who can help? @hwchase17 @agola11 @eyu When trying to reproduce the example of the Scoring evaluator [https://python.langchain.com/docs/guides/evaluation/string/scoring_eval_chain#usage-without-references] with the next code `evaluator = load_evaluator("labeled_score_string", criteria=criteria, llm=llm, normalize_by=10) eval_result = evaluator.evaluate_strings(prediction="You can find them in the dresser's third drawer.", reference="The socks are in the third drawer in the dresser", input="Where are my socks?")` I'm getting the error `ValueError: Invalid output: . Output must contain a double bracketed string with the verdict between 1 and 10.` Thanks!! ### Information - [X] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ` from langchain.evaluation import load_evaluator` `evaluator = load_evaluator("labeled_score_string", criteria=criteria, llm=llm, normalize_by=10) eval_result = evaluator.evaluate_strings(prediction="You can find them in the dresser's third drawer.", reference="The socks are in the third drawer in the dresser", input="Where are my socks?") ` ### Expected behavior ` {'reasoning': "The assistant's response is helpful, accurate, and directly answers the user's question. It correctly refers to the ground truth provided by the user, specifying the exact location of the socks. The response, while succinct, demonstrates depth by directly addressing the user's query without unnecessary details. Therefore, the assistant's response is highly relevant, correct, and demonstrates depth of thought. \n\nRating: [[10]]", 'score': 10}`
Getting invalid output error when using score evaluator
https://api.github.com/repos/langchain-ai/langchain/issues/12517/comments
12
2023-10-29T16:51:32Z
2024-02-15T16:08:00Z
https://github.com/langchain-ai/langchain/issues/12517
1,967,066,381
12,517
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. hello everyone I have a website which needs to pe scrapped and the website has the tabular data so when I scrap the data using web loaders in langchain and build a llm on top of it it is not able to answer the query. So what can be the suitable approach to solve this issue ### Suggestion: _No response_
Retrieval extraction of Tabular data
https://api.github.com/repos/langchain-ai/langchain/issues/12515/comments
5
2023-10-29T13:00:45Z
2024-02-11T16:08:26Z
https://github.com/langchain-ai/langchain/issues/12515
1,966,981,612
12,515
[ "langchain-ai", "langchain" ]
### Issue with current documentation: Please support chatglm3-6b-32k thank you very much ### Idea or request for content: _No response_
chatglm3-6b-32k----Please support chatglm3-6b-32k thank you very much
https://api.github.com/repos/langchain-ai/langchain/issues/12514/comments
2
2023-10-29T12:09:10Z
2024-04-03T16:07:29Z
https://github.com/langchain-ai/langchain/issues/12514
1,966,963,901
12,514
[ "langchain-ai", "langchain" ]
### System Info MacOS, 8GB RAM, M2 ### Who can help? @hwchase17 @agola11 Langchain Chat Models, Celery (apply.async()) ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Create a function that makes some calls to the OpenAI API. Run that using Celery's apply.async(). When ratelimit error is hit, Langchain will retry after 4 seconds but the Celery will get hung indefinitely. ### Expected behavior Langchain should be able to retry after 4 seconds without affecting Celery job.
Celery getting hung when langchain gets ratelimit error
https://api.github.com/repos/langchain-ai/langchain/issues/12513/comments
2
2023-10-29T11:01:23Z
2024-02-10T16:08:37Z
https://github.com/langchain-ai/langchain/issues/12513
1,966,941,802
12,513
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. Hello - i try vectorize a local txt-file and get an answer out of it using the following code: ``` from langchain.document_loaders import DirectoryLoader, TextLoader from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain.embeddings import HuggingFaceEmbeddings from langchain.vectorstores import FAISS from langchain.llms import CTransformers from langchain.embeddings import HuggingFaceEmbeddings from langchain.vectorstores import FAISS from langchain.prompts import PromptTemplate from langchain.chains import RetrievalQA import os ### Interpret content of local files text_loader_kwargs={'autodetect_encoding': True} loader = TextLoader("url.txt", encoding="utf8") documents = loader.load() splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50) texts = splitter.split_documents(documents) embeddings = HuggingFaceEmbeddings( model_name="sentence-transformers/all-MiniLM-L6-v2", model_kwargs={'device': 'cpu'}) # create and save the local database db = FAISS.from_documents(texts, embeddings) db.save_local("robalf") ### prepare AI with local files # prepare the template we will use when prompting the AI template = """Use the following text to answer the user's question. If you don't know the answer, just say that you don't know, don't try to make up an answer. Context: {context} Question: {question} Only return the helpful answer below and nothing else. Helpful answer: """ # load the language model fn = os.path.join("G:\DEV\TEMPDEV", "llama-2-7b-chat.ggmlv3.q8_0.bin") llm = CTransformers(model=fn, model_type='llama', config={'max_new_tokens': 1024, 'temperature': 0.01}) # load the interpreted information from the local database embeddings = HuggingFaceEmbeddings( model_name="sentence-transformers/all-MiniLM-L6-v2", model_kwargs={'device': 'cpu'}) db = FAISS.load_local("robalf", embeddings) # prepare a version of the llm pre-loaded with the local content retriever = db.as_retriever(search_kwargs={'k': 2}) prompt = PromptTemplate( template=template, input_variables=['context', 'question']) qa_llm = RetrievalQA.from_chain_type(llm=llm, chain_type='stuff', retriever=retriever, return_source_documents=True, chain_type_kwargs={'prompt': prompt}) # ask the AI chat about information in our local files prompt = "Write a maximum of 20 products produced or sold by the company in the text below. " output = qa_llm({'query': prompt}) print(output["result"]) ``` When i run this with a small url.txt everything works fine and i get an answer to the text. But when i use a bigger url.txt i get the following error: ``` Number of tokens (513) exceeded maximum context length (512). Number of tokens (514) exceeded maximum context length (512). Number of tokens (515) exceeded maximum context length (512). Number of tokens (516) exceeded maximum context length (512). Number of tokens (517) exceeded maximum context length (512). Number of tokens (518) exceeded maximum context length (512). Number of tokens (519) exceeded maximum context length (512). Number of tokens (520) exceeded maximum context length (512). Number of tokens (521) exceeded maximum context length (512). Number of tokens (522) exceeded maximum context length (512). ``` How can i use also bigger files as input and get answers? ### Suggestion: How can i use also bigger files as input and get answers?
Use also bigger files as input to get answers?
https://api.github.com/repos/langchain-ai/langchain/issues/12512/comments
2
2023-10-29T09:40:27Z
2024-02-07T16:12:43Z
https://github.com/langchain-ai/langchain/issues/12512
1,966,916,184
12,512
[ "langchain-ai", "langchain" ]
### Issue with current documentation: In scenarios where chain_type=refine, how do I output a prompt for each call? ``` chain = load_qa_chain(llm=llm, chain_type='refine', verbose=True) ``` The test found that setting verbose=True, also only outputs the prompt for the last llm request. ### Idea or request for content: _No response_
DOC: how to output a prompt for each call, in chain_type=refine
https://api.github.com/repos/langchain-ai/langchain/issues/12511/comments
2
2023-10-29T08:59:04Z
2024-02-10T16:08:42Z
https://github.com/langchain-ai/langchain/issues/12511
1,966,903,798
12,511
[ "langchain-ai", "langchain" ]
### Issue with current documentation: For example, in scenarios where chain_type=refine, LLM calls are made multiple times. How do you control the intervals between LLM calls? ### Idea or request for content: _No response_
DOC: How do I control the time interval for invoking LLM
https://api.github.com/repos/langchain-ai/langchain/issues/12510/comments
2
2023-10-29T08:53:04Z
2024-02-07T16:12:52Z
https://github.com/langchain-ai/langchain/issues/12510
1,966,902,078
12,510
[ "langchain-ai", "langchain" ]
### Issue with current documentation: The refine mode of langchain has already found the answer, and then requesting the interface is a waste of resources, can it be ended early? ### Idea or request for content: _No response_
DOC: How to end the refine process early in langchain?
https://api.github.com/repos/langchain-ai/langchain/issues/12509/comments
2
2023-10-29T08:25:39Z
2024-02-06T16:11:41Z
https://github.com/langchain-ai/langchain/issues/12509
1,966,893,900
12,509
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. Since 0.0.324, "from langchain.vectorstores import VectorStore" doesn't work anymore, any idea how to fix this? Thanks! ### Suggestion: _No response_
Issue: ImportError: cannot import name 'VectorStore' from 'langchain.vectorstores'
https://api.github.com/repos/langchain-ai/langchain/issues/12507/comments
7
2023-10-29T06:31:12Z
2024-02-14T16:08:33Z
https://github.com/langchain-ai/langchain/issues/12507
1,966,863,704
12,507
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. when using agent.run, tool's observation is returned. when using agent.acall, just returned agent's Thought to user ### Suggestion: _No response_
Issue: agent tool has been set with return_direct, when using agent.acall, just return Thought to user
https://api.github.com/repos/langchain-ai/langchain/issues/12506/comments
2
2023-10-29T06:18:45Z
2024-02-06T16:11:46Z
https://github.com/langchain-ai/langchain/issues/12506
1,966,861,166
12,506
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. Hi, I build a chatbot using conversationchain. I want to final output to be steamed. I tried StreamingStdOutCallbackHandler and FinalStreamingStdOutCallbackHandler. The problem with StreamingStdOutCallbackHandler is that it also prints out the memory of the chain. The problem with FinalStreamingStdOutCallbackHandler is that it did print the final output, but the output is just printed out at once rather than streamed. How can I fix it? Thanks, ### Suggestion: _No response_
Issue: StreamingStdOutCallbackHandler and FinalStreamingStdOutCallbackHandler
https://api.github.com/repos/langchain-ai/langchain/issues/12503/comments
4
2023-10-29T02:45:00Z
2024-02-11T16:08:36Z
https://github.com/langchain-ai/langchain/issues/12503
1,966,819,941
12,503
[ "langchain-ai", "langchain" ]
### Issue you'd like to raise. Okay I have tried both SQL database chain and create SQL agent from agents and what i have seen is that after run and it returns zero records from the database and LLM gives the output from its own. So basically I have only one fruit in my database and if I ask what fruit contains vitamin c which is not in the database and it fetch me the result from its own knowledge base. I tried adding the instructions in the prompt like if query return zero records or observation is empty or the result of the SQL. Query is empty, Do not share anything on your own And just convey the message to the user that for your certain filter criteria that is no records Try different query or elaborate your request but it doesn't seem to be working. is there anyting we can do to fix it? ### Suggestion: _No response_
SQLDatabaseChain sharing data that's not in database
https://api.github.com/repos/langchain-ai/langchain/issues/12495/comments
9
2023-10-28T21:30:30Z
2024-03-18T16:05:59Z
https://github.com/langchain-ai/langchain/issues/12495
1,966,745,591
12,495