status
stringclasses
1 value
repo_name
stringlengths
9
24
repo_url
stringlengths
28
43
issue_id
int64
1
104k
updated_files
stringlengths
8
1.76k
title
stringlengths
4
369
body
stringlengths
0
254k
issue_url
stringlengths
37
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[ns, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
5,104
["langchain/document_loaders/googledrive.py"]
GoogleDriveLoader seems to be pulling trashed documents from the folder
### System Info Hi testing this loader, it looks as tho this is pulling trashed files from folders. I think this should be default to false if anything and be an opt in. ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts ### Related Components - [X] Document Loaders ### Reproduction use GoogleDriveLoader 1. point to folder 2. move a file to trash in folder Reindex File still can be searched in vector store. ### Expected behavior Should not be searchable
https://github.com/langchain-ai/langchain/issues/5104
https://github.com/langchain-ai/langchain/pull/5220
eff31a33613bcdc179d6ad22febbabf8dccf80c8
f0ea093de867e5f099a4b5de2bfa24d788b79133
2023-05-22T21:21:14Z
python
2023-05-25T05:26:17Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
5,072
["langchain/vectorstores/weaviate.py", "tests/integration_tests/vectorstores/test_weaviate.py"]
Add option to use _additional fields while executing a Weaviate query
### Feature request Weaviate has the option to pass _additional field while executing a query https://weaviate.io/developers/weaviate/api/graphql/additional-properties It would be good to be able to use this feature and add the response to the results. It is a small change, without breaking the API. We can use the kwargs argument, similar to where_filter in the python class weaviate.py. ### Motivation When comparing and understanding query results, using certainty is a good way. ### Your contribution I like to contribute to the PR. As it would be my first contribution, I need to understand the integration tests and build the project, and I already tested the change in my local code sample.
https://github.com/langchain-ai/langchain/issues/5072
https://github.com/langchain-ai/langchain/pull/5085
87bba2e8d3a7772a32eda45bc17160f4ad8ae3d2
b95002289409077965d99636b15a45300d9c0b9d
2023-05-21T22:37:40Z
python
2023-05-23T01:57:10Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
5,071
["docs/modules/models/llms/integrations/llamacpp.ipynb"]
Issue: LLamacpp wrapper slows down the model
### Issue you'd like to raise. Looks like the inference time of the LLamacpp model is a lot slower when using LlamaCpp wrapper (compared to the llama-cpp original wrapper). Here are the results for the same prompt on the RTX 4090 GPU. When using llamacpp-python Llama wrapper directly: ![llamacpp_runtime](https://github.com/hwchase17/langchain/assets/48142538/3cc4dd4b-3fab-4d9b-8887-d18451d56a4b) When using langchain LlamaCpp wrapper: ![runtime_langchain](https://github.com/hwchase17/langchain/assets/48142538/51551596-430c-44ed-8d79-8ed770647522) As you can see, it takes nearly 12x more time for the prompt_eval stage (2.67 ms per token vs 35 ms per token) Am i missing something? In both cases, the model is fully loaded to the GPU. In the case of the Langchain wrapper, no chain was used, just direct querying of the model using the wrapper's interface. Same parameters. Link to the example notebook (values are a lil different, but the problem is the same): https://github.com/mmagnesium/personal-assistant/blob/main/notebooks/langchain_vs_llamacpp.ipynb Appreciate any help. ### Suggestion: Unfortunately, no suggestion, since i don't understand whats the problem.
https://github.com/langchain-ai/langchain/issues/5071
https://github.com/langchain-ai/langchain/pull/5344
44b48d95183067bc71942512a97b846f5b1fb4c3
f6615cac41453a9bb3a061a3ffb29327f5e04fb2
2023-05-21T21:49:24Z
python
2023-05-29T13:43:26Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
5,065
["langchain/vectorstores/faiss.py"]
FAISS should allow you to specify id when using add_text
### System Info langchain 0.0.173 faiss-cpu 1.7.4 python 3.10.11 Void linux ### Who can help? @hwchase17 ### 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 It's a logic error in langchain.vectorstores.faiss.__add() https://github.com/hwchase17/langchain/blob/0c3de0a0b32fadb8caf3e6d803287229409f9da9/langchain/vectorstores/faiss.py#L94-L100 https://github.com/hwchase17/langchain/blob/0c3de0a0b32fadb8caf3e6d803287229409f9da9/langchain/vectorstores/faiss.py#L118-L126 The id is not possible to specify as a function argument. This makes it impossible to detect duplicate additions, for instance. ### Expected behavior It should be possible to specify id of inserted documents / texts using the add_documents / add_texts methods, as it is in the Chroma object's methods. As a side-effect this ability would also fix the inability to remove duplicates (see https://github.com/hwchase17/langchain/issues/2699 and https://github.com/hwchase17/langchain/issues/3896 ) by the approach of using ids unique to the content (I use a hash, for example).
https://github.com/langchain-ai/langchain/issues/5065
https://github.com/langchain-ai/langchain/pull/5190
f0ea093de867e5f099a4b5de2bfa24d788b79133
40b086d6e891a3cd1e678b1c8caac23b275d485c
2023-05-21T16:39:28Z
python
2023-05-25T05:26:46Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
5,039
["docs/modules/agents.rst"]
DOC: Misspelling in agents.rst
### Issue with current documentation: Within the documentation, in the last sentence change should be **charge**. Reference link: https://python.langchain.com/en/latest/modules/agents.html <img width="511" alt="image" src="https://github.com/hwchase17/langchain/assets/67931050/52f6eacd-7930-451f-abd7-05eca9479390"> ### Idea or request for content: I propose correcting the misspelling as in change does not make sense and that the Action Agent is supposed to be in charge of the execution.
https://github.com/langchain-ai/langchain/issues/5039
https://github.com/langchain-ai/langchain/pull/5038
f9f08c4b698830b6abcb140d42da98ca7084f082
424a573266c848fe2e53bc2d50c2dc7fc72f2c15
2023-05-20T15:50:20Z
python
2023-05-21T05:24:08Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
5,001
["libs/langchain/tests/integration_tests/embeddings/test_openai.py"]
Azure OpenAI Embeddings failed due to no deployment_id set.
### System Info Broken by #4915 Error: `Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.embedding.Embedding'>` I'm putting a PR out to fix this now. ### Who can help? _No response_ ### Information - [X] 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 Run example notebook: https://github.com/hwchase17/langchain/blob/22d844dc0795e7e53a4cc499bf4974cb83df490d/docs/modules/models/text_embedding/examples/azureopenai.ipynb ### Expected behavior Embedding using Azure OpenAI should work.
https://github.com/langchain-ai/langchain/issues/5001
https://github.com/langchain-ai/langchain/pull/5002
45741bcc1b65e588e560b60e347ab391858d53f5
1d3735a84c64549d4ef338506ae0b68d53541b44
2023-05-19T20:18:47Z
python
2023-08-11T22:43:01Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,959
["docs/modules/chains/examples/llm_summarization_checker.ipynb"]
DOC: Misspelling in LLMSummarizationCheckerChain documentation
### Issue with current documentation: In the doc as mentioned below:- https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html Assumptions is misspelled as assumtions. ### Idea or request for content: Fix the misspelling in the doc markdown.
https://github.com/langchain-ai/langchain/issues/4959
https://github.com/langchain-ai/langchain/pull/4961
bf5a3c6dec2536c4652c1ec960b495435bd13850
13c376345e5548cc12a8b4975696f7b625347a4b
2023-05-19T04:45:16Z
python
2023-05-19T14:40:04Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,896
["langchain/vectorstores/redis.py"]
Redis Vectorstore: Redis.from_texts_return_keys() got multiple values for argument 'cls'
### System Info ``` Python 3.10.4 langchain==0.0.171 redis==3.5.3 redisearch==2.1.1 ``` ### Who can help? @tylerhutcherson ### 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 I was able to override issue #3893 by temporarily disabling the ` _check_redis_module_exist`, post which I'm getting the below error when calling the `from_texts_return_keys` within the `from_documents` method in Redis class. Seems the argument `cls` is not needed in the `from_texts_return_keys` method, since it is already defined as a classmethod. ``` File "/workspaces/chatdataset_backend/adapters.py", line 96, in load vectorstore = self.rds.from_documents(documents=documents, embedding=self.embeddings) File "/home/codespace/.python/current/lib/python3.10/site-packages/langchain/vectorstores/base.py", line 296, in from_documents return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs) File "/home/codespace/.python/current/lib/python3.10/site-packages/langchain/vectorstores/redis.py", line 448, in from_texts instance, _ = cls.from_texts_return_keys( TypeError: Redis.from_texts_return_keys() got multiple values for argument 'cls' ``` ### Expected behavior Getting rid of cls argument from all the `Redis` class methods wherever required. Was able to solve the issue with this fix.
https://github.com/langchain-ai/langchain/issues/4896
https://github.com/langchain-ai/langchain/pull/4932
a87a2524c7f8f55846712a682ffc80b5fc224b73
616e9a93e08f4f042c492b89545e85e80592ffbe
2023-05-18T02:46:53Z
python
2023-05-19T20:02:03Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,878
["docs/modules/indexes/document_loaders/examples/google_drive.ipynb", "langchain/document_loaders/googledrive.py"]
Add the possibility to define what file types you want to load from a Google Drive
### Feature request It would be helpful if we could define what file types we want to load via the [Google Drive loader](https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/google_drive.html#) i.e.: only docs or sheets or PDFs. ### Motivation The current loads will load 3 file types: doc, sheet and pdf, but in my project I only want to load "application/vnd.google-apps.document". ### Your contribution I'm happy to contribute with a PR.
https://github.com/langchain-ai/langchain/issues/4878
https://github.com/langchain-ai/langchain/pull/4926
dfbf45f028bd282057c5d645c0ebb587fa91dda8
c06a47a691c96fd5065be691df6837143df8ef8f
2023-05-17T19:46:54Z
python
2023-05-18T13:27:53Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,833
["langchain/tools/jira/prompt.py", "langchain/utilities/jira.py", "tests/integration_tests/utilities/test_jira_api.py"]
Arbitrary code execution in JiraAPIWrapper
### System Info LangChain version:0.0.171 windows 10 ### Who can help? _No response_ ### 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 - [ ] Memory - [ ] Agents / Agent Executors - [X] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction 1. Set the environment variables for jira and openai ```python import os from langchain.utilities.jira import JiraAPIWrapper os.environ["JIRA_API_TOKEN"] = "your jira api token" os.environ["JIRA_USERNAME"] = "your username" os.environ["JIRA_INSTANCE_URL"] = "your url" os.environ["OPENAI_API_KEY"] = "your openai key" ``` 2. Run jira ```python jira = JiraAPIWrapper() output = jira.run('other',"exec(\"import os;print(os.popen('id').read())\")") ``` 3. The `id` command will be executed. Commands can be change to others and attackers can execute arbitrary code. ### Expected behavior The code can be executed without any check.
https://github.com/langchain-ai/langchain/issues/4833
https://github.com/langchain-ai/langchain/pull/6992
61938a02a1e76fa6c6e8203c98a9344a179c810d
a2f191a32229256dd41deadf97786fe41ce04cbb
2023-05-17T04:11:40Z
python
2023-07-05T19:56:01Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,830
["langchain/cache.py"]
GPTCache keep creating new gptcache cache_obj
### System Info Langchain Version: 0.0.170 Platform: Linux X86_64 Python: 3.9 ### Who can help? @SimFG _No response_ ### 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 - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Steps to produce behaviour: ```python from gptcache import Cache from gptcache.adapter.api import init_similar_cache from langchain.cache import GPTCache # Avoid multiple caches using the same file, causing different llm model caches to affect each other def init_gptcache(cache_obj: Cache, llm str): init_similar_cache(cache_obj=cache_obj, data_dir=f"similar_cache_{llm}") langchain.llm_cache = GPTCache(init_gptcache) llm = OpenAI(model_name="text-davinci-002", temperature=0.2) llm("tell me a joke") print("cached:", langchain.llm_cache.lookup("tell me a joke", llm_string)) # cached: None ``` the cache won't hits ### Expected behavior the gptcache should have a hit
https://github.com/langchain-ai/langchain/issues/4830
https://github.com/langchain-ai/langchain/pull/4827
c9e2a0187549f6fa2661b943c13af9d63d44eee1
a8ded21b6963b0041e9931f6e397573cb498cbaf
2023-05-17T03:26:37Z
python
2023-05-18T16:42:35Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,825
["langchain/retrievers/time_weighted_retriever.py"]
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'
### System Info langchain version 0.0.171 python version 3.9.13 macos ### Who can help? _No response_ ### 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 - [X] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction This is a problem with the generative agents. To reproduce please follow the tutorial outlines here: https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html When you get to the following line of code you will get an error: `print(tommie.get_summary(force_refresh=True))` ``` File ~/.pyenv/versions/3.9.13/lib/python3.9/site-packages/langchain/retrievers/time_weighted_retriever.py:14, in _get_hours_passed(time, ref_time) 12 def _get_hours_passed(time: datetime.datetime, ref_time: datetime.datetime) -> float: 13 """Get the hours passed between two datetime objects.""" ---> 14 return (time - ref_time).total_seconds() / 3600 TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType' ``` ### Expected behavior The ref time should be a datetime and tommies summary should be printed.
https://github.com/langchain-ai/langchain/issues/4825
https://github.com/langchain-ai/langchain/pull/5045
c28cc0f1ac5a1ddd6a9dbb7d6792bb0f4ab0087d
e173e032bcceae3a7d3bb400c34d554f04be14ca
2023-05-17T02:24:24Z
python
2023-05-22T22:47:03Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,818
["docs/modules/agents/agents/custom_agent.ipynb", "docs/modules/indexes/retrievers/examples/wikipedia.ipynb", "docs/use_cases/agents/wikibase_agent.ipynb", "docs/use_cases/code/code-analysis-deeplake.ipynb"]
Typo in DeepLake Code Analysis Tutorials
### Discussed in https://github.com/hwchase17/langchain/discussions/4817 <div type='discussions-op-text'> <sup>Originally posted by **markanth** May 16, 2023</sup> Under Use Cases -> Code Understanding, you will find: The full tutorial is available below. [Twitter the-algorithm codebase analysis with Deep Lake](https://python.langchain.com/en/latest/use_cases/code/twitter-the-algorithm-analysis-deeplake.html): A notebook walking through how to parse github source code and run queries conversation. [LangChain codebase analysis with Deep Lake](https://python.langchain.com/en/latest/use_cases/code/code-analysis-deeplake.html): A notebook walking through how to analyze and do question answering over THIS code base. In both full tutorials, I think that this line: model = ChatOpenAI(model='gpt-3.5-turbo') # switch to 'gpt-4' should be: model = ChatOpenAI(model_name='gpt-3.5-turbo') (model_name instead of model) </div>
https://github.com/langchain-ai/langchain/issues/4818
https://github.com/langchain-ai/langchain/pull/4851
8dcad0f2722d011bea2e191204aca9ac7d235546
e257380debb8640268d2d2577f89139b3ea0b46f
2023-05-16T22:21:09Z
python
2023-05-17T15:52:22Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,791
["langchain/retrievers/weaviate_hybrid_search.py", "langchain/vectorstores/redis.py", "langchain/vectorstores/weaviate.py", "tests/integration_tests/retrievers/test_weaviate_hybrid_search.py", "tests/integration_tests/vectorstores/test_weaviate.py"]
Accept UUID list as an argument to add texts and documents into Weaviate vectorstore
### Feature request When you call `add_texts` and `add_docuemnts` methods from a Weaviate instance, it always generate UUIDs for you, which is a neat feature https://github.com/hwchase17/langchain/blob/bee136efa4393219302208a1a458d32129f5d539/langchain/vectorstores/weaviate.py#L137 However, there are specific use cases where you want to generate UUIDs by yourself and pass them via `add_texts` and `add_docuemnts`. Therefore, I'd like to support `uuids` field in `kwargs` argument to these methods, and use those values instead of generating new ones inside those methods. ### Motivation Both `add_texts` and `add_documents` methods internally call [batch.add_data_object](https://weaviate-python-client.readthedocs.io/en/stable/weaviate.batch.html#weaviate.batch.Batch.add_data_object) method of a Weaviate client. The document states as below: > Add one object to this batch. NOTE: If the UUID of one of the objects already exists then the existing object will be replaced by the new object. This behavior is extremely useful when you need to update and delete document from a known field of the document. First of all, Weaviate expects UUIDv3 and UUIDv5 as UUID formats. You can find the information below: https://weaviate.io/developers/weaviate/more-resources/faq#q-are-there-restrictions-on-uuid-formatting-do-i-have-to-adhere-to-any-standards And UUIDv5 allows you to generate always the same value based on input string, as if it's a hash algorithm. https://docs.python.org/2/library/uuid.html Let's say you have unique identifier of the document, and use it to generate your own UUID. This way you can directly update, delete or replace documents without searching the documents by metadata. This will saves your time, your code, and network bandwidth and computer resources. ### Your contribution I'm attempting to make a PR,
https://github.com/langchain-ai/langchain/issues/4791
https://github.com/langchain-ai/langchain/pull/4800
e78c9be312e5c59ec96f22d6e531c28329ca6312
6561efebb7c1cbd3716f5e7f03f18ad9b3b1afa5
2023-05-16T15:31:48Z
python
2023-05-16T22:26:46Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,757
["docs/modules/models/llms/examples/llm_caching.ipynb"]
Have resolved:GPTcache :[Errno 63] File name too long: "similar_cache_[('_type', 'openai'), ('best_of', 2), ('frequency_penalty', 0), ('logit_bias', {}), ('max_tokens', 256), ('model_name', 'text-davinci-002'), ('n', 2), ('presence_penalty', 0), ('request_timeout', None), ('stop', None), ('temperature', 0.7), ('top_p', 1)]
### System Info langchain=0.017 python=3.9.16 ### 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 - [X] Memory - [X] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [X] Callbacks/Tracing - [ ] Async ### Reproduction ``` from gptcache import Cache from gptcache.manager.factory import manager_factory from gptcache.processor.pre import get_prompt from langchain.cache import GPTCache import hashlib # Avoid multiple caches using the same file, causing different llm model caches to affect each other def get_hashed_name(name): return hashlib.sha256(name.encode()).hexdigest() def init_gptcache(cache_obj: Cache, llm: str): hashed_llm = get_hashed_name(llm) cache_obj.init( pre_embedding_func=get_prompt, data_manager=manager_factory(manager="map", data_dir=f"map_cache_{hashed_llm}"), ) langchain.llm_cache = GPTCache(init_gptcache) llm("Tell me a joke") ``` ### Expected behavior import hashlib
https://github.com/langchain-ai/langchain/issues/4757
https://github.com/langchain-ai/langchain/pull/4985
ddc2d4c21e5bcf40e15896bf1e377e7dc2d63ae9
f07b9fde74dc3e30b836cc0ccfb478e5923debf5
2023-05-16T01:14:21Z
python
2023-05-19T23:35:36Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,742
["langchain/vectorstores/weaviate.py"]
Issue: Weaviate: why similarity_search uses with_near_text?
### Issue you'd like to raise. [similarity_search](https://github.com/hwchase17/langchain/blob/09587a32014bb3fd9233d7a567c8935c17fe901e/langchain/vectorstores/weaviate.py#L174-L175) in weaviate uses near_text. This requires weaviate to be set up with a [text2vec module](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules). At the same time, the weaviate also takes an [embedding model](https://github.com/hwchase17/langchain/blob/09587a32014bb3fd9233d7a567c8935c17fe901e/langchain/vectorstores/weaviate.py#L86) as one of it's init parameters. Why don't we use the embedding model to vectorize the search query and then use weaviate's near_vector operator to do the search? ### Suggestion: If a user is using langchain with weaviate, we can assume that they want to use langchain's features to generate the embeddings and as such, will not have any text2vec module enabled.
https://github.com/langchain-ai/langchain/issues/4742
https://github.com/langchain-ai/langchain/pull/4824
d1b6839d97ea1b0c60f226633da34d97a130c183
0a591da6db5c76722e349e03692d674e45ba626a
2023-05-15T18:37:07Z
python
2023-05-17T02:43:15Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,720
["langchain/llms/huggingface_endpoint.py", "langchain/llms/huggingface_hub.py", "langchain/llms/huggingface_pipeline.py", "langchain/llms/self_hosted_hugging_face.py", "tests/integration_tests/llms/test_huggingface_endpoint.py", "tests/integration_tests/llms/test_huggingface_hub.py", "tests/integration_tests/llms/test_huggingface_pipeline.py", "tests/integration_tests/llms/test_self_hosted_llm.py"]
Add summarization task type for HuggingFace APIs
### Feature request Add summarization task type for HuggingFace APIs. This task type is described by [HuggingFace inference API](https://huggingface.co/docs/api-inference/detailed_parameters#summarization-task) ### Motivation My project utilizes LangChain to connect multiple LLMs, including various HuggingFace models that support the summarization task. Integrating this task type is highly convenient and beneficial. ### Your contribution I will submit a PR.
https://github.com/langchain-ai/langchain/issues/4720
https://github.com/langchain-ai/langchain/pull/4721
580861e7f206395d19cdf4896a96b1e88c6a9b5f
3f0357f94acb1e669c8f21f937e3438c6c6675a6
2023-05-15T11:23:49Z
python
2023-05-15T23:26:17Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,714
["langchain/callbacks/manager.py"]
Error in on_llm callback: 'AsyncIteratorCallbackHandler' object has no attribute 'on_llm'
### System Info langchain version:0.0.168 python version 3.10 ### Who can help? @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 - [ ] Chains - [X] Callbacks/Tracing - [ ] Async ### Reproduction When using the RetrievalQA chain, an error message "Error in on_llm callback: 'AsyncIteratorCallbackHandler' object has no attribute 'on_llm'" This code can run at version 0.0.164 ```python class Chain: def __init__(self): self.cb_mngr_stdout = AsyncCallbackManager([StreamingStdOutCallbackHandler()]) self.cb_mngr_aiter = AsyncCallbackManager([AsyncIteratorCallbackHandler()]) self.qa_stream = None self.qa = None self.make_chain() def make_chain(self): chain_type_kwargs = {"prompt": MyPrompt.get_retrieval_prompt()} qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(model_name="gpt-3.5-turbo", max_tokens=1500, temperature=.1), chain_type="stuff", retriever=Retrieval.vectordb.as_retriever(search_kwargs={"k": Retrieval.context_num}), chain_type_kwargs=chain_type_kwargs, return_source_documents=True) qa_stream = RetrievalQA.from_chain_type(llm=ChatOpenAI(model_name="gpt-3.5-turbo", max_tokens=1500, temperature=.1, streaming=True, callback_manager=self.cb_mngr_aiter), chain_type="stuff", retriever=Retrieval.vectordb.as_retriever(search_kwargs={"k": Retrieval.context_num}), chain_type_kwargs=chain_type_kwargs, return_source_documents=True) self.qa = qa self.qa_stream = qa_stream ``` call function ```python resp = await chains.qa.acall({"query": "xxxxxxx"}) # no problem resp = await chains.qa_stream.acall({"query": "xxxxxxxx"}) # error ``` ### Expected behavior self.qa_stream return result like self.qa,or like langchain version 0.0.164
https://github.com/langchain-ai/langchain/issues/4714
https://github.com/langchain-ai/langchain/pull/4717
bf0904b676f458386096a008155ffeb805bc52c5
2e43954bc31dc5e23c7878149c0e061c444416a7
2023-05-15T06:30:00Z
python
2023-05-16T01:36:21Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,682
["langchain/vectorstores/deeplake.py", "tests/integration_tests/vectorstores/test_deeplake.py"]
Setting overwrite to False on DeepLake constructor still overwrites
### System Info Langchain 0.0.168, Python 3.11.3 ### Who can help? @anihamde ### 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 db = DeepLake(dataset_path=f"hub://{username_activeloop}/{lake_name}", embedding_function=embeddings, overwrite=False) ### Expected behavior Would expect overwrite to not take place; however, it does. This is easily resolvable, and I'll share a PR to address this shortly.
https://github.com/langchain-ai/langchain/issues/4682
https://github.com/langchain-ai/langchain/pull/4683
8bb32d77d0703665d498e4d9bcfafa14d202d423
03ac39368fe60201a3f071d7d360c39f59c77cbf
2023-05-14T19:15:22Z
python
2023-05-16T00:39:16Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,668
["docs/modules/agents/agents/custom_agent.ipynb", "docs/modules/indexes/retrievers/examples/wikipedia.ipynb", "docs/use_cases/agents/wikibase_agent.ipynb", "docs/use_cases/code/code-analysis-deeplake.ipynb"]
DOC: Typo in Custom Agent Documentation
### Issue with current documentation: https://python.langchain.com/en/latest/modules/agents/agents/custom_agent.html ### Idea or request for content: I was going through the documentation for creating a custom agent (https://python.langchain.com/en/latest/modules/agents/agents/custom_agent.html) and noticed a potential typo. In the section discussing the components of a custom agent, the text mentions that an agent consists of "three parts" but only two are listed: "Tools" and "The agent class itself". I believe the text should say "two parts" instead of "three". Could you please confirm if this is a typo, or if there's a missing third part that needs to be included in the list?
https://github.com/langchain-ai/langchain/issues/4668
https://github.com/langchain-ai/langchain/pull/4851
8dcad0f2722d011bea2e191204aca9ac7d235546
e257380debb8640268d2d2577f89139b3ea0b46f
2023-05-14T12:52:17Z
python
2023-05-17T15:52:22Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,631
["langchain/llms/huggingface_text_gen_inference.py"]
[feature] Add support for streaming response output to HuggingFaceTextGenInference LLM
### Feature request Per title, request is to add feature for streaming output response, something like this: ```python from langchain.llms.huggingface_text_gen_inference import HuggingFaceTextGenInference from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler llm = HuggingFaceTextGenInference( inference_server_url='http://localhost:8010', max_new_tokens=512, top_k=10, top_p=0.95, typical_p=0.95, temperature=0.01, stop_sequences=['</s>'], repetition_penalty=1.03, stream=True ) print(llm("What is deep learning?", callbacks=[StreamingStdOutCallbackHandler()])) ``` ### Motivation Having streaming response output is useful for chat situations to reduce perceived latency for the user. Current implementation of HuggingFaceTextGenInference class implemented in [PR 4447](https://github.com/hwchase17/langchain/pull/4447) does not support streaming. ### Your contribution Feature added in [PR #4633](https://github.com/hwchase17/langchain/pull/4633)
https://github.com/langchain-ai/langchain/issues/4631
https://github.com/langchain-ai/langchain/pull/4633
435b70da472525bfec4ced38a8446c878af2c27b
c70ae562b466ba9a6d0f587ab935fd9abee2bc87
2023-05-13T16:16:48Z
python
2023-05-15T14:59:12Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,628
["docs/modules/models/llms/integrations/gpt4all.ipynb", "langchain/llms/gpt4all.py"]
GPT4All Python Bindings out of date [move to new multiplatform bindings]
### Feature request The official gpt4all python bindings now exist in the `gpt4all` pip package. [Langchain](https://python.langchain.com/en/latest/modules/models/llms/integrations/gpt4all.html) currently relies on the no-longer maintained pygpt4all package. Langchain should use the `gpt4all` python package with source found here: https://github.com/nomic-ai/gpt4all/tree/main/gpt4all-bindings/python ### Motivation The source at https://github.com/nomic-ai/gpt4all/tree/main/gpt4all-bindings/python supports multiple OS's and platforms (other bindings do not). Nomic AI will be officially maintaining these bindings. ### Your contribution I will be happy to review a pull request and ensure that future changes are PR'd upstream to langchains :)
https://github.com/langchain-ai/langchain/issues/4628
https://github.com/langchain-ai/langchain/pull/4567
e2d7677526bd649461db38396c0c3b21f663f10e
c9e2a0187549f6fa2661b943c13af9d63d44eee1
2023-05-13T15:15:06Z
python
2023-05-18T16:38:54Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,575
["libs/langchain/langchain/embeddings/openai.py"]
AzureOpenAI InvalidRequestError: Too many inputs. The max number of inputs is 1.
### System Info Langchain version == 0.0.166 Embeddings = OpenAIEmbeddings - model: text-embedding-ada-002 version 2 LLM = AzureOpenAI ### Who can help? @hwchase17 @agola11 ### 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 - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Steps to reproduce: 1. Set up azure openai embeddings by providing key, version etc.. 2. Load a document with a loader 3. Set up a text splitter so you get more then 2 documents 4. add them to chromadb with `.add_documents(List<Document>)` This is some example code: ```py pdf = PyPDFLoader(url) documents = pdf.load() text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) texts = text_splitter.split_documents(documents) vectordb.add_documents(texts) vectordb.persist() ``` ### Expected behavior Embeddings be added to the database, instead it returns the error `openai.error.InvalidRequestError: Too many inputs. The max number of inputs is 1. We hope to increase the number of inputs per request soon. Please contact us through an Azure support request at: https://go.microsoft.com/fwlink/?linkid=2213926 for further questions.` This is because Microsoft only allows one embedding at a time while the script tries to add the documents all at once. The following code is where the issue comes up (I think): https://github.com/hwchase17/langchain/blob/258c3198559da5844be3f78680f42b2930e5b64b/langchain/embeddings/openai.py#L205-L214 The input should be a 1 dimentional array and not multi.
https://github.com/langchain-ai/langchain/issues/4575
https://github.com/langchain-ai/langchain/pull/10707
7395c2845549f77a3b52d9d7f0d70c88bed5817a
f0198354d93e7ba8b615b8fd845223c88ea4ed2b
2023-05-12T12:38:50Z
python
2023-09-20T04:50:39Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,513
["pyproject.toml"]
[pyproject.toml] add `tiktoken` to `tool.poetry.extras.openai`
### System Info langchain[openai]==0.0.165 Ubuntu 22.04.2 LTS (Jammy Jellyfish) python 3.10.6 ### Who can help? @vowelparrot ### 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 - [X] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction The OpenAI component requires `tiktoken` package, but if we install like below, the `tiktoken` package is not found. ``` langchain[openai]==0.0.165 ``` It's natural to add `tiktoken`, since there is a dependency in the `pyproject.toml` file. https://github.com/hwchase17/langchain/blob/46b100ea630b5d1d7fedd6a32d5eb9ecbadeb401/pyproject.toml#L35-L36 Besides, the missing of `tiktoken` would cause an issue under some dependency pinning tool, like bazel or [jazzband/pip-tools](https://github.com/jazzband/pip-tools) ``` Traceback (most recent call last): File "/home/ofey/.cache/bazel/_bazel_ofey/90bb890b04415910673f256b166d6c9b/sandbox/linux-sandbox/15/execroot/walking_shadows/bazel-out/k8-fastbuild/bin/src/backend/services/world/internal/memory/test/test_test.runfiles/pip_langchain/site-packages/langchain/embeddings/openai.py", line 186, in _get_len_safe_embeddings import tiktoken ModuleNotFoundError: No module named 'tiktoken' ... File "/home/ofey/.cache/bazel/_bazel_ofey/90bb890b04415910673f256b166d6c9b/sandbox/linux-sandbox/15/execroot/walking_shadows/bazel-out/k8-fastbuild/bin/src/backend/services/world/internal/memory/test/test_test.runfiles/pip_langchain/site-packages/langchain/embeddings/openai.py", line 240, in _get_len_safe_embeddings raise ValueError( ValueError: Could not import tiktoken python package. This is needed in order to for OpenAIEmbeddings. Please install it with `pip install tiktoken`. ``` ### Expected behavior Add a dependency in `pyproject.toml` ``` [tool.poetry.extras] ... openai = ["openai", "tiktoken"] ``` Actually I'm using langchain with bazel, this is my project: [ofey404/WalkingShadows](https://github.com/ofey404/WalkingShadows)
https://github.com/langchain-ai/langchain/issues/4513
https://github.com/langchain-ai/langchain/pull/4514
4ee47926cafba0eb00851972783c1d66236f6f00
1c0ec26e40f07cdf9eabae2f018dff05f97d8595
2023-05-11T07:54:40Z
python
2023-05-11T19:21:06Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,498
["langchain/embeddings/openai.py"]
Cannot subclass OpenAIEmbeddings
### System Info - langchain: 0.0.163 - python: 3.9.16 - OS: Ubuntu 22.04 ### Who can help? @shibanovp @hwchase17 ### 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 Steps to reproduce: Getting error when running this code snippet: ```python from langchain.embeddings import OpenAIEmbeddings class AzureOpenAIEmbeddings(OpenAIEmbeddings): pass ``` Error: ``` Traceback (most recent call last): File "test.py", line 3, in <module> class AzureOpenAIEmbeddings(OpenAIEmbeddings): File "pydantic/main.py", line 139, in pydantic.main.ModelMetaclass.__new__ File "pydantic/utils.py", line 693, in pydantic.utils.smart_deepcopy File "../lib/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "../lib/python3.9/copy.py", line 230, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "../lib/python3.9/copy.py", line 172, in deepcopy y = _reconstruct(x, memo, *rv) File "../lib/python3.9/copy.py", line 270, in _reconstruct state = deepcopy(state, memo) File "../lib/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "../lib/python3.9/copy.py", line 210, in _deepcopy_tuple y = [deepcopy(a, memo) for a in x] File "../lib/python3.9/copy.py", line 210, in <listcomp> y = [deepcopy(a, memo) for a in x] File "../lib/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "../lib/python3.9/copy.py", line 230, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "../lib/python3.9/copy.py", line 172, in deepcopy y = _reconstruct(x, memo, *rv) File "../lib/python3.9/copy.py", line 264, in _reconstruct y = func(*args) File "../lib/python3.9/copy.py", line 263, in <genexpr> args = (deepcopy(arg, memo) for arg in args) File "../lib/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "../lib/python3.9/copy.py", line 210, in _deepcopy_tuple y = [deepcopy(a, memo) for a in x] File "../lib/python3.9/copy.py", line 210, in <listcomp> y = [deepcopy(a, memo) for a in x] File "../lib/python3.9/copy.py", line 172, in deepcopy y = _reconstruct(x, memo, *rv) File "../lib/python3.9/copy.py", line 264, in _reconstruct y = func(*args) File "../lib/python3.9/typing.py", line 277, in inner return func(*args, **kwds) File "../lib/python3.9/typing.py", line 920, in __getitem__ params = tuple(_type_check(p, msg) for p in params) File "../lib/python3.9/typing.py", line 920, in <genexpr> params = tuple(_type_check(p, msg) for p in params) File "../lib/python3.9/typing.py", line 166, in _type_check raise TypeError(f"{msg} Got {arg!r:.100}.") TypeError: Tuple[t0, t1, ...]: each t must be a type. Got (). ``` ### Expected behavior Expect to allow subclass as normal.
https://github.com/langchain-ai/langchain/issues/4498
https://github.com/langchain-ai/langchain/pull/4500
08df80bed6e36150ea7c17fa15094a38d3ec546f
49e4aaf67326b3185405bdefb36efe79e4705a59
2023-05-11T04:42:23Z
python
2023-05-17T01:35:19Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,479
["docs/modules/indexes/document_loaders/examples/file_directory.ipynb", "langchain/document_loaders/helpers.py", "langchain/document_loaders/text.py", "poetry.lock", "pyproject.toml", "tests/unit_tests/document_loaders/test_detect_encoding.py", "tests/unit_tests/examples/example-non-utf8.txt", "tests/unit_tests/examples/example-utf8.txt"]
TextLoader: auto detect file encodings
### Feature request Allow the `TextLoader` to optionally auto detect the loaded file encoding. If the option is enabled the loader will try all detected encodings by order of detection confidence or raise an error. Also enhances the default raised exception to indicate which read path raised the exception. ### Motivation Permits loading large datasets of text files with unknown/arbitrary encodings. ### Your contribution Will submit a PR for this
https://github.com/langchain-ai/langchain/issues/4479
https://github.com/langchain-ai/langchain/pull/4927
8c28ad6daca3420d4428a464cd35f00df8b84f01
e46202829f30cf03ff25254adccef06184ffdcba
2023-05-10T20:46:24Z
python
2023-05-18T13:55:14Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,463
["docs/extras/use_cases/self_check/smart_llm.ipynb", "libs/experimental/langchain_experimental/smart_llm/__init__.py", "libs/experimental/langchain_experimental/smart_llm/base.py", "libs/experimental/tests/unit_tests/test_smartllm.py"]
`SmartGPT` workflow
### Feature request @hwchase17 Can we implement this [**SmartGPT** workflow](https://youtu.be/wVzuvf9D9BU)? Probably, it is also implemented but I didn't find it. Thi method looks like something simple but very effective. ### Motivation Improving the quality of the prompts and the resulting generation quality. ### Your contribution I can try to implement it but need direction.
https://github.com/langchain-ai/langchain/issues/4463
https://github.com/langchain-ai/langchain/pull/4816
1d3735a84c64549d4ef338506ae0b68d53541b44
8aab39e3ce640c681bbdc446ee40f7e34a56cc52
2023-05-10T15:52:11Z
python
2023-08-11T22:44:27Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,451
["langchain/document_loaders/youtube.py", "tests/unit_tests/document_loader/test_youtube.py"]
YoutubeLoader.from_youtube_url should handle common YT url formats
### Feature request `YoutubeLoader.from_youtube_url` accepts single URL format. It should be able to handle at least the most common types of Youtube urls out there. ### Motivation Current video id extraction is pretty naive. It doesn't handle anything than single specific type of youtube url. Any valid but different video address leads to exception. ### Your contribution I've prepared a PR where i've introduced `.extract_video_id` method. Under the hood it uses regex to find video id in most popular youtube urls. Regex is based on Youtube-dl solution which can be found here: https://github.com/ytdl-org/youtube-dl/blob/211cbfd5d46025a8e4d8f9f3d424aaada4698974/youtube_dl/extractor/youtube.py#L524
https://github.com/langchain-ai/langchain/issues/4451
https://github.com/langchain-ai/langchain/pull/4452
8b42e8a510d7cafc6ce787b9bcb7a2c92f973c96
c2761aa8f4266e97037aa25480b3c8e26e7417f3
2023-05-10T11:09:22Z
python
2023-05-15T14:45:19Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,423
["docs/modules/agents/toolkits/examples/csv.ipynb", "docs/modules/agents/toolkits/examples/pandas.ipynb", "docs/modules/agents/toolkits/examples/titanic_age_fillna.csv", "langchain/agents/agent_toolkits/csv/base.py", "langchain/agents/agent_toolkits/pandas/base.py", "langchain/agents/agent_toolkits/pandas/prompt.py", "tests/integration_tests/agent/test_csv_agent.py", "tests/integration_tests/agent/test_pandas_agent.py"]
Do Q/A with csv agent and multiple txt files at the same time.
### Issue you'd like to raise. I want to do Q/A with csv agent and multiple txt files at the same time. But I do not want to use csv loader and txt loader because they did not perform very well when handling cross file scenario. For example, the model needs to find answers from both the csv and txt file and then return the result. How should I do it? I think I may need to create a custom agent. ### Suggestion: _No response_
https://github.com/langchain-ai/langchain/issues/4423
https://github.com/langchain-ai/langchain/pull/5009
3223a97dc61366f7cbda815242c9354bff25ae9d
7652d2abb01208fd51115e34e18b066824e7d921
2023-05-09T22:33:44Z
python
2023-05-25T21:23:11Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,394
["libs/langchain/langchain/prompts/base.py", "libs/langchain/langchain/prompts/loading.py", "libs/langchain/langchain/prompts/prompt.py", "libs/langchain/tests/unit_tests/examples/jinja_injection_prompt.json", "libs/langchain/tests/unit_tests/examples/jinja_injection_prompt.yaml", "libs/langchain/tests/unit_tests/prompts/test_loading.py"]
Template injection to arbitrary code execution
### System Info windows 11 ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] 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 1. save the following data to pt.json ```json { "input_variables": [ "prompt" ], "output_parser": null, "partial_variables": {}, "template": "Tell me a {{ prompt }} {{ ''.__class__.__bases__[0].__subclasses__()[147].__init__.__globals__['popen']('dir').read() }}", "template_format": "jinja2", "validate_template": true, "_type": "prompt" } ``` 2. run ```python from langchain.prompts import load_prompt loaded_prompt = load_prompt("pt.json") loaded_prompt.format(history="", prompt="What is 1 + 1?") ``` 3. the `dir` command will be execute attack scene: Alice can send prompt file to Bob and let Bob to load it. analysis: Jinja2 is used to concat prompts. Template injection will happened note: in the pt.json, the `template` has payload, the index of `__subclasses__` maybe different in other environment. ### Expected behavior code should not be execute
https://github.com/langchain-ai/langchain/issues/4394
https://github.com/langchain-ai/langchain/pull/10252
b642d00f9f625969ca1621676990af7db4271a2e
22abeb9f6cc555591bf8e92b5e328e43aa07ff6c
2023-05-09T12:28:24Z
python
2023-10-10T15:15:42Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,368
["langchain/vectorstores/redis.py", "tests/integration_tests/vectorstores/test_redis.py"]
Add distance metric param to to redis vectorstore index
### Feature request Redis vectorstore allows for three different distance metrics: `L2` (flat L2), `COSINE`, and `IP` (inner product). Currently, the `Redis._create_index` method hard codes the distance metric to COSINE. ```py def _create_index(self, dim: int = 1536) -> None: try: from redis.commands.search.field import TextField, VectorField from redis.commands.search.indexDefinition import IndexDefinition, IndexType except ImportError: raise ValueError( "Could not import redis python package. " "Please install it with `pip install redis`." ) # Check if index exists if not _check_index_exists(self.client, self.index_name): # Constants distance_metric = ( "COSINE" # distance metric for the vectors (ex. COSINE, IP, L2) ) schema = ( TextField(name=self.content_key), TextField(name=self.metadata_key), VectorField( self.vector_key, "FLAT", { "TYPE": "FLOAT32", "DIM": dim, "DISTANCE_METRIC": distance_metric, }, ), ) prefix = _redis_prefix(self.index_name) # Create Redis Index self.client.ft(self.index_name).create_index( fields=schema, definition=IndexDefinition(prefix=[prefix], index_type=IndexType.HASH), ) ``` This should be parameterized. ### Motivation I'd like to be able to use L2 distance metrics. ### Your contribution I've already forked and made a branch that parameterizes the distance metric in `langchain.vectorstores.redis`: ```py def _create_index(self, dim: int = 1536, distance_metric: REDIS_DISTANCE_METRICS = "COSINE") -> None: try: from redis.commands.search.field import TextField, VectorField from redis.commands.search.indexDefinition import IndexDefinition, IndexType except ImportError: raise ValueError( "Could not import redis python package. " "Please install it with `pip install redis`." ) # Check if index exists if not _check_index_exists(self.client, self.index_name): # Define schema schema = ( TextField(name=self.content_key), TextField(name=self.metadata_key), VectorField( self.vector_key, "FLAT", { "TYPE": "FLOAT32", "DIM": dim, "DISTANCE_METRIC": distance_metric, }, ), ) prefix = _redis_prefix(self.index_name) # Create Redis Index self.client.ft(self.index_name).create_index( fields=schema, definition=IndexDefinition(prefix=[prefix], index_type=IndexType.HASH), ) def _create_index(self, dim: int = 1536, distance_metric: REDIS_DISTANCE_METRICS = "COSINE") -> None: try: from redis.commands.search.field import TextField, VectorField from redis.commands.search.indexDefinition import IndexDefinition, IndexType except ImportError: raise ValueError( "Could not import redis python package. " "Please install it with `pip install redis`." ) # Check if index exists if not _check_index_exists(self.client, self.index_name): # Define schema schema = ( TextField(name=self.content_key), TextField(name=self.metadata_key), VectorField( self.vector_key, "FLAT", { "TYPE": "FLOAT32", "DIM": dim, "DISTANCE_METRIC": distance_metric, }, ), ) prefix = _redis_prefix(self.index_name) # Create Redis Index self.client.ft(self.index_name).create_index( fields=schema, definition=IndexDefinition(prefix=[prefix], index_type=IndexType.HASH), ) ... @classmethod def from_texts( cls: Type[Redis], texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, index_name: Optional[str] = None, content_key: str = "content", metadata_key: str = "metadata", vector_key: str = "content_vector", distance_metric: REDIS_DISTANCE_METRICS = "COSINE", **kwargs: Any, ) -> Redis: """Create a Redis vectorstore from raw documents. This is a user-friendly interface that: 1. Embeds documents. 2. Creates a new index for the embeddings in Redis. 3. Adds the documents to the newly created Redis index. This is intended to be a quick way to get started. Example: .. code-block:: python from langchain.vectorstores import Redis from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() redisearch = RediSearch.from_texts( texts, embeddings, redis_url="redis://username:password@localhost:6379" ) """ redis_url = get_from_dict_or_env(kwargs, "redis_url", "REDIS_URL") if "redis_url" in kwargs: kwargs.pop("redis_url") # Name of the search index if not given if not index_name: index_name = uuid.uuid4().hex # Create instance instance = cls( redis_url=redis_url, index_name=index_name, embedding_function=embedding.embed_query, content_key=content_key, metadata_key=metadata_key, vector_key=vector_key, **kwargs, ) # Create embeddings over documents embeddings = embedding.embed_documents(texts) # Create the search index instance._create_index(dim=len(embeddings[0]), distance_metric=distance_metric) # Add data to Redis instance.add_texts(texts, metadatas, embeddings) return instance ``` I'll make the PR and link this issue
https://github.com/langchain-ai/langchain/issues/4368
https://github.com/langchain-ai/langchain/pull/4375
f46710d4087c3f27e95cfc4b2c96956d7c4560e8
f668251948c715ef3102b2bf84ff31aed45867b5
2023-05-09T00:40:32Z
python
2023-05-11T07:20:01Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,331
["langchain/chat_models/openai.py", "langchain/llms/openai.py", "tests/integration_tests/chat_models/test_openai.py", "tests/integration_tests/llms/test_openai.py"]
Issue: Model and model_name inconsistency in OpenAI LLMs such as ChatOpenAI
### Issue you'd like to raise. Argument `model_name` is the standard way of defining a model in LangChain's [ChatOpenAI](https://github.com/hwchase17/langchain/blob/65c95f9fb2b86cf3281f2f3939b37e71f048f741/langchain/chat_models/openai.py#L115). However, OpenAI uses `model` in their own [API](https://platform.openai.com/docs/api-reference/completions/create). To handle this discrepancy, LangChain transforms `model_name` into `model` [here](https://github.com/hwchase17/langchain/blob/65c95f9fb2b86cf3281f2f3939b37e71f048f741/langchain/chat_models/openai.py#L202). The problem is that, if you ignore model_name and use model in the LLM instantiation e.g. `ChatOpenAI(model=...)`, it still works! It works because model becomes part of `model_kwargs`, which takes precedence over the default `model_name` (which would be "gpt-3.5-turbo"). This leads to an inconsistency: the `model` can be anything (e.g. "gpt-4-0314"), but `model_name` will be the default value. This inconsistency won't cause any direct issue but can be problematic when you're trying to understand what models are actually being called and used. I'm raising this issue because I lost a couple of hours myself trying to understand what was happening. ### Suggestion: There are three ways to solve it: 1. Raise an error or warning if model is used as an argument and suggest using model_name instead 2. Raise a warning if model is defined differently from model_name 3. Change from model_name to model to make it consistent with OpenAI's API I think (3) is unfeasible due to the breaking change, but raising a warning seems low effort and safe enough.
https://github.com/langchain-ai/langchain/issues/4331
https://github.com/langchain-ai/langchain/pull/4366
02ebb15c4a92a23818c2c17486bdaf9f590dc6a5
ba0057c07712e5e725c7c5e14c02d223783b183c
2023-05-08T10:49:23Z
python
2023-05-08T23:37:34Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,328
["docs/ecosystem/serpapi.md", "docs/reference/integrations.md", "langchain/agents/load_tools.py", "langchain/utilities/serpapi.py"]
Issue: Can not configure serpapi base url via env
### Issue you'd like to raise. Currently, the base URL of Serpapi is been hard coded. While some search services(e.g. Bing, `BING_SEARCH_URL`) are configurable. In some companies, the original can not be allowed to access. We need to use nginx redirect proxy. So we need to make the base URL configurable via env. ### Suggestion: Make serpapi base url configurable via env
https://github.com/langchain-ai/langchain/issues/4328
https://github.com/langchain-ai/langchain/pull/4402
cb802edf75539872e18068edec8e21216f3e51d2
5111bec54071e42a7865766dc8bb8dc72c1d13b4
2023-05-08T09:27:24Z
python
2023-05-15T21:25:25Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,325
["docs/modules/agents/toolkits/examples/powerbi.ipynb", "langchain/utilities/powerbi.py", "tests/integration_tests/.env.example", "tests/integration_tests/agent/test_powerbi_agent.py", "tests/integration_tests/utilities/test_powerbi_api.py", "tests/unit_tests/tools/powerbi/__init__.py", "tests/unit_tests/tools/powerbi/test_powerbi.py"]
Power BI Dataset Agent Issue
### System Info We are using the below Power BI Agent guide to try to connect to Power BI dashboard. [Power BI Dataset Agent](https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html) We are able to connect to OpenAI API but facing issues with the below line of code. `powerbi=PowerBIDataset(dataset_id="<dataset_id>", table_names=['table1', 'table2'], credential=DefaultAzureCredential())` Error: > ConfigError: field "credential" not yet prepared so type is still a ForwardRef, you might need to call PowerBIDataset.update_forward_refs(). We tried searching to solve the issues we no luck so far. Is there any configuration we are missing? Can you share more details, is there any specific configuration or access required on power BI side? thanks in advance... ### Who can help? _No response_ ### 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 - [ ] Memory - [X] Agents / Agent Executors - [X] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Same steps mentioned your official PowerBI Dataset Agent documentation ### Expected behavior We should be able to connect to power BI
https://github.com/langchain-ai/langchain/issues/4325
https://github.com/langchain-ai/langchain/pull/4983
e68dfa70625b6bf7cfeb4c8da77f68069fb9cb95
06e524416c18543d5fd4dcbebb9cdf4b56c47db4
2023-05-08T07:57:11Z
python
2023-05-19T15:25:52Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,304
["langchain/document_loaders/url_selenium.py"]
[Feature Request] Allow users to pass binary location to Selenium WebDriver
### Feature request Problem: Unable to set binary_location for the Webdriver via SeleniumURLLoader Proposal: The proposal is to adding a new arguments parameter to the SeleniumURLLoader that allows users to pass binary_location ### Motivation To deploy Selenium on Heroku ([tutorial](https://romik-kelesh.medium.com/how-to-deploy-a-python-web-scraper-with-selenium-on-heroku-1459cb3ac76c)), the browser binary must be installed as a buildpack and its location must be set as the binary_location for the driver browser options. Currently when creating a Chrome or Firefox web driver via SeleniumURLLoader, users cannot set the binary_location of the WebDriver. ### Your contribution I can submit the PR to add this capability to SeleniumURLLoader
https://github.com/langchain-ai/langchain/issues/4304
https://github.com/langchain-ai/langchain/pull/4305
65c95f9fb2b86cf3281f2f3939b37e71f048f741
637c61cffbd279dc2431f9e224cfccec9c81f6cd
2023-05-07T23:25:37Z
python
2023-05-08T15:05:55Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,168
["docs/modules/models/llms/integrations/sagemaker.ipynb"]
DOC: Issues with the SageMakerEndpoint example
### Issue with current documentation: When I run the example from https://python.langchain.com/en/latest/modules/models/llms/integrations/sagemaker.html#example I first get the following error: ``` line 49, in <module> llm=SagemakerEndpoint( File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ pydantic.error_wrappers.ValidationError: 1 validation error for SagemakerEndpoint content_handler instance of LLMContentHandler expected (type=type_error.arbitrary_type; expected_arbitrary_type=LLMContentHandler) ``` I can replace `ContentHandlerBase` with `LLMContentHandler`. Then I get the following (against an Alexa 20B model running on SageMaker): ``` An error occurred (ModelError) when calling the InvokeEndpoint operation: Received server error (500) from primary and could not load the entire response body. See ... ``` The issue, I believe, is here: ``` def transform_input(self, prompt: str, model_kwargs: Dict) -> bytes: input_str = json.dumps({prompt: prompt, **model_kwargs}) return input_str.encode('utf-8') ``` The Sagemaker endpoints expect a body with `text_inputs` instead of `prompt` (see, e.g. https://aws.amazon.com/blogs/machine-learning/alexatm-20b-is-now-available-in-amazon-sagemaker-jumpstart/): ``` input_str = json.dumps({"text_inputs": prompt, **model_kwargs}) ``` Finally, after these fixes, I get this error: ``` line 44, in transform_output return response_json[0]["generated_text"] KeyError: 0 ``` The response body that I am getting looks like this: ``` {"generated_texts": ["Use the following pieces of context to answer the question at the end. Peter and Elizabeth"]} ``` so I think that `transform_output` should do: ``` return response_json["generated_texts"][0] ``` (That response that I am getting from the model is not very impressive, so there might be something else that I am doing wrong here) ### Idea or request for content: _No response_
https://github.com/langchain-ai/langchain/issues/4168
https://github.com/langchain-ai/langchain/pull/4598
e90654f39bf6c598936770690c82537b16627334
5372a06a8c52d49effc52d277d02f3a9b0ef91ce
2023-05-05T10:09:04Z
python
2023-05-17T00:28:16Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,167
["langchain/document_loaders/web_base.py", "tests/unit_tests/document_loader/test_web_base.py"]
User Agent on WebBaseLoader does not set header_template when passing `header_template`
### System Info Hi Team, When using WebBaseLoader and setting header_template the user agent does not get set and sticks with the default python user agend. ``` loader = WebBaseLoader(url, header_template={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36', }) data = loader.load() ``` printing the headers in the INIT function shows the headers are passed in the template BUT in the load function or scrape the self.sessions.headers shows FIX set the default_header_template in INIT if header template present NOTE: this is due to Loading a page on WPENGINE who wont allow python user agents LangChain 0.0.158 Python 3.11 ### 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 - [X] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Hi Team, When using WebBaseLoader and setting header_template the user agent does not get set and sticks with the default python user agend. `loader = WebBaseLoader(url, header_template={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36', }) data = loader.load()` printing the headers in the INIT function shows the headers are passed in the template BUT in the load function or scrape the self.sessions.headers shows FIX set the default_header_template in INIT if header template present NOTE: this is due to Loading a page on WPENGINE who wont allow python user agents LangChain 0.0.158 Python 3.11 ### Expected behavior Not throw 403 when calling loader. Modifying INIT and setting the session headers works if the template is passed
https://github.com/langchain-ai/langchain/issues/4167
https://github.com/langchain-ai/langchain/pull/4579
372a5113ff1cce613f78d58c9e79e7c49aa60fac
3b6206af49a32d947a75965a5167c8726e1d5639
2023-05-05T10:04:47Z
python
2023-05-15T03:09:27Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,153
["langchain/document_loaders/whatsapp_chat.py", "tests/integration_tests/document_loaders/test_whatsapp_chat.py", "tests/integration_tests/examples/whatsapp_chat.txt"]
WhatsAppChatLoader doesn't work on chats exported from WhatsApp
### System Info langchain 0.0.158 Mac OS M1 Python 3.11 ### Who can help? @ey ### 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 1. Use 'Export Chat' feature on WhatsApp. 2. Observe this format for the txt file ``` [11/8/21, 9:41:32 AM] User name: Message text ``` The regular expression used by WhatsAppChatLoader doesn't parse this format successfully ### Expected behavior Parsing fails
https://github.com/langchain-ai/langchain/issues/4153
https://github.com/langchain-ai/langchain/pull/4420
f2150285a495fc530a7707218ea4980c17a170e5
2b1403612614127da4e3bd3d22595ce7b3eb1540
2023-05-05T05:25:38Z
python
2023-05-09T22:00:04Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,142
["langchain/sql_database.py", "pyproject.toml"]
ImportError: cannot import name 'CursorResult' from 'sqlalchemy'
### System Info # Name Version Build Channel _libgcc_mutex 0.1 main _openmp_mutex 5.1 1_gnu aiohttp 3.8.3 py310h5eee18b_0 aiosignal 1.3.1 pyhd8ed1ab_0 conda-forge async-timeout 4.0.2 pyhd8ed1ab_0 conda-forge attrs 23.1.0 pyh71513ae_0 conda-forge blas 1.0 mkl brotlipy 0.7.0 py310h5764c6d_1004 conda-forge bzip2 1.0.8 h7b6447c_0 ca-certificates 2023.01.10 h06a4308_0 certifi 2022.12.7 py310h06a4308_0 cffi 1.15.0 py310h0fdd8cc_0 conda-forge charset-normalizer 2.0.4 pyhd3eb1b0_0 colorama 0.4.6 pyhd8ed1ab_0 conda-forge cryptography 3.4.8 py310h685ca39_1 conda-forge dataclasses-json 0.5.7 pyhd8ed1ab_0 conda-forge frozenlist 1.3.3 py310h5eee18b_0 greenlet 2.0.1 py310h6a678d5_0 idna 3.4 pyhd8ed1ab_0 conda-forge intel-openmp 2021.4.0 h06a4308_3561 langchain 0.0.158 pyhd8ed1ab_0 conda-forge ld_impl_linux-64 2.38 h1181459_1 libffi 3.4.2 h6a678d5_6 libgcc-ng 11.2.0 h1234567_1 libgomp 11.2.0 h1234567_1 libstdcxx-ng 11.2.0 h1234567_1 libuuid 1.41.5 h5eee18b_0 marshmallow 3.19.0 pyhd8ed1ab_0 conda-forge marshmallow-enum 1.5.1 pyh9f0ad1d_3 conda-forge mkl 2021.4.0 h06a4308_640 mkl-service 2.4.0 py310ha2c4b55_0 conda-forge mkl_fft 1.3.1 py310hd6ae3a3_0 mkl_random 1.2.2 py310h00e6091_0 multidict 6.0.2 py310h5eee18b_0 mypy_extensions 1.0.0 pyha770c72_0 conda-forge ncurses 6.4 h6a678d5_0 numexpr 2.8.4 py310h8879344_0 numpy 1.24.3 py310hd5efca6_0 numpy-base 1.24.3 py310h8e6c178_0 openapi-schema-pydantic 1.2.4 pyhd8ed1ab_0 conda-forge openssl 1.1.1t h7f8727e_0 packaging 23.1 pyhd8ed1ab_0 conda-forge pip 22.2.2 pypi_0 pypi pycparser 2.21 pyhd8ed1ab_0 conda-forge pydantic 1.10.2 py310h5eee18b_0 pyopenssl 20.0.1 pyhd8ed1ab_0 conda-forge pysocks 1.7.1 pyha2e5f31_6 conda-forge python 3.10.9 h7a1cb2a_2 python_abi 3.10 2_cp310 conda-forge pyyaml 6.0 py310h5764c6d_4 conda-forge readline 8.2 h5eee18b_0 requests 2.29.0 pyhd8ed1ab_0 conda-forge setuptools 66.0.0 py310h06a4308_0 six 1.16.0 pyh6c4a22f_0 conda-forge sqlalchemy 1.4.39 py310h5eee18b_0 sqlite 3.41.2 h5eee18b_0 stringcase 1.2.0 py_0 conda-forge tenacity 8.2.2 pyhd8ed1ab_0 conda-forge tk 8.6.12 h1ccaba5_0 tqdm 4.65.0 pyhd8ed1ab_1 conda-forge typing-extensions 4.5.0 hd8ed1ab_0 conda-forge typing_extensions 4.5.0 pyha770c72_0 conda-forge typing_inspect 0.8.0 pyhd8ed1ab_0 conda-forge tzdata 2023c h04d1e81_0 urllib3 1.26.15 pyhd8ed1ab_0 conda-forge wheel 0.38.4 py310h06a4308_0 xz 5.4.2 h5eee18b_0 yaml 0.2.5 h7f98852_2 conda-forge yarl 1.7.2 py310h5764c6d_2 conda-forge zlib 1.2.13 h5eee18b_0 Traceback (most recent call last): File "/home/bachar/projects/op-stack/./app.py", line 1, in <module> from langchain.document_loaders import DirectoryLoader File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/__init__.py", line 6, in <module> from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/agents/__init__.py", line 2, in <module> from langchain.agents.agent import ( File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/agents/agent.py", line 15, in <module> from langchain.agents.tools import InvalidTool File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/agents/tools.py", line 8, in <module> from langchain.tools.base import BaseTool, Tool, tool File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/tools/__init__.py", line 32, in <module> from langchain.tools.vectorstore.tool import ( File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/tools/vectorstore/tool.py", line 13, in <module> from langchain.chains import RetrievalQA, RetrievalQAWithSourcesChain File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/chains/__init__.py", line 19, in <module> from langchain.chains.loading import load_chain File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/chains/loading.py", line 24, in <module> from langchain.chains.sql_database.base import SQLDatabaseChain File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/chains/sql_database/base.py", line 15, in <module> from langchain.sql_database import SQLDatabase File "/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/langchain/sql_database.py", line 8, in <module> from sqlalchemy import ( ImportError: cannot import name 'CursorResult' from 'sqlalchemy' (/home/bachar/projects/op-stack/venv/lib/python3.10/site-packages/sqlalchemy/__init__.py) (/home/bachar/projects/op-stack/venv) ### 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 - [X] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction from langchain.document_loaders import DirectoryLoader docs = DirectoryLoader("./pdfs", "**/*.pdf").load() ### Expected behavior no errors should be thrown
https://github.com/langchain-ai/langchain/issues/4142
https://github.com/langchain-ai/langchain/pull/4145
2f087d63af45a172fc363b3370e49141bd663ed2
fea639c1fc1ac324f1300016a02b6d30a2f8d249
2023-05-05T00:47:24Z
python
2023-05-05T03:46:38Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,129
["langchain/sql_database.py", "pyproject.toml"]
Bug introduced in 0.0.158
Updates in version 0.0.158 have introduced a bug that prevents this import from being successful, while it works in 0.0.157 ``` Traceback (most recent call last): File "path", line 5, in <module> from langchain.chains import OpenAIModerationChain, SequentialChain, ConversationChain File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/__init__.py", line 6, in <module> from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/agents/__init__.py", line 2, in <module> from langchain.agents.agent import ( File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/agents/agent.py", line 15, in <module> from langchain.agents.tools import InvalidTool File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/agents/tools.py", line 8, in <module> from langchain.tools.base import BaseTool, Tool, tool File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/tools/__init__.py", line 32, in <module> from langchain.tools.vectorstore.tool import ( File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/tools/vectorstore/tool.py", line 13, in <module> from langchain.chains import RetrievalQA, RetrievalQAWithSourcesChain File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/chains/__init__.py", line 19, in <module> from langchain.chains.loading import load_chain File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/chains/loading.py", line 24, in <module> from langchain.chains.sql_database.base import SQLDatabaseChain File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/chains/sql_database/base.py", line 15, in <module> from langchain.sql_database import SQLDatabase File "/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/langchain/sql_database.py", line 8, in <module> from sqlalchemy import ( ImportError: cannot import name 'CursorResult' from 'sqlalchemy' (/Users/chasemcdo/.pyenv/versions/3.11.1/lib/python3.11/site-packages/sqlalchemy/__init__.py) ```
https://github.com/langchain-ai/langchain/issues/4129
https://github.com/langchain-ai/langchain/pull/4145
2f087d63af45a172fc363b3370e49141bd663ed2
fea639c1fc1ac324f1300016a02b6d30a2f8d249
2023-05-04T19:24:15Z
python
2023-05-05T03:46:38Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,120
["langchain/document_loaders/url_selenium.py"]
[Feature Request] Allow users to pass additional arguments to the WebDriver
Description: Currently, when creating a Chrome or Firefox web driver using the `selenium.webdriver` module, users can only pass a limited set of arguments such as `headless` mode and hardcoded `no-sandbox`. However, there are many additional options available for these browsers that cannot be passed in using the existing API. I personally was limited by this when I had to add the `--disable-dev-shm-usage` and `--disable-gpu` arguments to the Chrome WebDeriver. To address this limitation, I propose adding a new `arguments` parameter to the `SeleniumURLLoader` that allows users to pass additional arguments as a list of strings.
https://github.com/langchain-ai/langchain/issues/4120
https://github.com/langchain-ai/langchain/pull/4121
2a3c5f83537817d06ea8fad2836bbcd1cb33a551
19e28d8784adef90553da071ed891fc3252b2c63
2023-05-04T18:15:03Z
python
2023-05-05T20:24:42Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,096
["langchain/agents/load_tools.py", "tests/unit_tests/agents/test_tools.py"]
Callbacks are ignored when passed to load_tools
Hello, I cannot figure out how to pass callback when using `load_tools`, I used to pass a callback_manager but I understand that it's now deprecated. I was able to reproduce with the following snippet: ```python from langchain.agents import load_tools from langchain.callbacks.base import BaseCallbackHandler from langchain.tools import ShellTool class MyCustomHandler(BaseCallbackHandler): def on_tool_start(self, serialized, input_str: str, **kwargs): """Run when tool starts running.""" print("ON TOOL START!") def on_tool_end(self, output: str, **kwargs): """Run when tool ends running.""" print("ON TOOL END!") # load_tools doesn't works print("LOAD TOOLS!") tools = load_tools(["terminal"], callbacks=[MyCustomHandler()]) print(tools[0].run({"commands": ["echo 'Hello World!'", "time"]})) # direct tool instantiation works print("Direct tool") shell_tool = ShellTool(callbacks=[MyCustomHandler()]) print(shell_tool.run({"commands": ["echo 'Hello World!'", "time"]})) ``` Here is the output I'm seeing: ``` LOAD TOOLS! /home/lothiraldan/project/cometml/langchain/langchain/tools/shell/tool.py:33: UserWarning: The shell tool has no safeguards by default. Use at your own risk. warnings.warn( Hello World! user 0m0,00s sys 0m0,00s Direct tool ON TOOL START! ON TOOL END! Hello World! user 0m0,00s sys 0m0,00s ``` In this example, when I pass the callbacks to `load_tools`, the `on_tool_*` methods are not called. But maybe it's not the correct way to pass callbacks to the `load_tools` helper. I reproduced with Langchain master, specifically the following commit https://github.com/hwchase17/langchain/commit/a9c24503309e2e3eb800f335e0fbc7c22531bda0. Pip list output: ``` Package Version Editable project location ----------------------- --------- ------------------------------------------- aiohttp 3.8.4 aiosignal 1.3.1 async-timeout 4.0.2 attrs 23.1.0 certifi 2022.12.7 charset-normalizer 3.1.0 dataclasses-json 0.5.7 frozenlist 1.3.3 greenlet 2.0.2 idna 3.4 langchain 0.0.157 /home/lothiraldan/project/cometml/langchain marshmallow 3.19.0 marshmallow-enum 1.5.1 multidict 6.0.4 mypy-extensions 1.0.0 numexpr 2.8.4 numpy 1.24.3 openai 0.27.6 openapi-schema-pydantic 1.2.4 packaging 23.1 pip 23.0.1 pydantic 1.10.7 PyYAML 6.0 requests 2.29.0 setuptools 67.6.1 SQLAlchemy 2.0.12 tenacity 8.2.2 tqdm 4.65.0 typing_extensions 4.5.0 typing-inspect 0.8.0 urllib3 1.26.15 wheel 0.40.0 yarl 1.9.2 ```
https://github.com/langchain-ai/langchain/issues/4096
https://github.com/langchain-ai/langchain/pull/4298
0870a45a697a75ac839b724311ce7a8b59a09058
35c9e6ab407003e0c1f16fcf6d4c73f6637db731
2023-05-04T09:05:12Z
python
2023-05-08T15:44:26Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,053
["langchain/tools/base.py", "tests/unit_tests/agents/test_tools.py"]
Tools with partials (Partial functions not yet supported in tools)
We commonly used this pattern to create tools: ```py from langchain.tools import Tool from functools import partial def foo(x, y): return y Tool.from_function( func=partial(foo, "bar"), name = "foo", description="foobar" ) ``` which as of 0.0.148 (I think) gives a pydantic error "Partial functions not yet supported in tools." We must use instead this format: ```py from langchain.tools import Tool from functools import partial def foo(x, y): return y Tool.from_function( func=lambda y: foo(x="bar",y=y), name = "foo", description="foobar" ) ``` It would be nice to again support partials.
https://github.com/langchain-ai/langchain/issues/4053
https://github.com/langchain-ai/langchain/pull/4058
7e967aa4d581bec8b29e9ea44267505b0bad18b9
afa9d1292b0a152e36d338dde7b02f0b93bd37d9
2023-05-03T17:28:46Z
python
2023-05-03T20:16:41Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
4,052
["docs/modules/indexes/document_loaders/examples/arxiv.ipynb"]
Arxiv loader does not work
Hey, I tried to use the Arxiv loader but it seems that this type of document does not exist anymore. The documentation is still there https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/arxiv.html Do you have any details on that?
https://github.com/langchain-ai/langchain/issues/4052
https://github.com/langchain-ai/langchain/pull/4068
374725a715d287fe2ddb9dfda36e0dc14efa254d
9b830f437cdfd82d9b53bd38e58b27bb9ecf970c
2023-05-03T16:23:51Z
python
2023-05-04T00:54:30Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,997
["docs/modules/models/chat/integrations/anthropic.ipynb", "docs/modules/models/llms/integrations/llamacpp.ipynb"]
Llama-cpp docs loading has CallbackManager error
As in title, I think it might be because of deprecation and renaming at some point? Updated to use BaseCallbackManager in PR #3996 , please merge, thanks!
https://github.com/langchain-ai/langchain/issues/3997
https://github.com/langchain-ai/langchain/pull/4010
f08a76250fe8995fb3f05bf785677070922d4b0d
df3bc707fc916811183d2487e2fac5dc69327177
2023-05-02T20:13:28Z
python
2023-05-02T23:20:16Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,988
["langchain/callbacks/openai_info.py", "tests/unit_tests/callbacks/test_openai_info.py"]
LangChain openAI callback doesn't allow finetuned models
Hi all! I have an [application](https://github.com/ur-whitelab/BO-LIFT) based on langchain. A few months ago, I used it with fine-tuned (FT) models. We added a token usage counter later, and I haven't tried fine-tuned models again since then. Recently we have been interested in using (FT) models again, but the callback to expose the token usage isn't accepting the model. Minimal code to reproduce the error: ``` from langchain.llms import OpenAI from langchain.callbacks import get_openai_callback llm = OpenAI( model_name=FT_MODEL, temperature=0.7, n=5, max_tokens=64, ) with get_openai_callback() as cb: completion_response = llm.generate(["QUERY"]) token_usage = cb.total_tokens ``` It works fine if the model name is a basic openAI model. For instance, ```model_name="text-davinci-003"``` But when I try to use one of my FT models, I get this error: ``` Error in on_llm_end callback: Unknown model: FT_MODEL. Please provide a valid OpenAI model name.Known models are: gpt-4, gpt-4-0314, gpt-4-completion, gpt-4-0314-completion, gpt-4-32k, gpt-4-32k-0314, gpt-4-32k-completion, gpt-4-32k-0314-completion, gpt-3.5-turbo, gpt-3.5-turbo-0301, text-ada-001, ada, text-babbage-001, babbage, text-curie-001, curie, text-davinci-003, text-davinci-002, code-davinci-002 ``` It works if I remove the callback and avoid token counting, but it'd be nice to have any suggestions on how to make it work. Is there a workaround for that? Any help is welcome! Thanks!
https://github.com/langchain-ai/langchain/issues/3988
https://github.com/langchain-ai/langchain/pull/4009
aa383559999b3d6a781c62ed7f8589fef8892879
f08a76250fe8995fb3f05bf785677070922d4b0d
2023-05-02T18:00:22Z
python
2023-05-02T23:19:57Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,983
["langchain/chains/loading.py", "langchain/chains/retrieval_qa/base.py", "tests/integration_tests/chains/test_retrieval_qa.py"]
RetrievalQA & RetrievalQAWithSourcesChain chains cannot be serialized/saved or loaded
`VectorDBQA` is being deprecated in favour of `RetrievalQA` & similarly, `VectorDBQAWithSourcesChain` is being deprecated for `RetrievalQAWithSourcesChain`. Currently, `VectorDBQA` & `VectorDBQAWithSourcesChain` chains can be serialized using `vec_chain.save(...)` because they have `_chain_type` property - https://github.com/hwchase17/langchain/blob/3bd5a99b835fa320d02aa733cb0c0bc4a87724fa/langchain/chains/qa_with_sources/vector_db.py#L67 However, `RetrievalQA` & `RetrievalQAWithSourcesChain` do not have that property and raise the following error when trying to save with `ret_chain.save("ret_chain.yaml")`: ``` File [~/.pyenv/versions/3.8.15/envs/internalqa/lib/python3.8/site-packages/langchain/chains/base.py:45](https://file+.vscode-resource.vscode-cdn.net/Users/smohammed/Development/hackweek-internalqa/~/.pyenv/versions/3.8.15/envs/internalqa/lib/python3.8/site-packages/langchain/chains/base.py:45), in Chain._chain_type(self) [43](file:///Users/smohammed/.pyenv/versions/3.8.15/envs/internalqa/lib/python3.8/site-packages/langchain/chains/base.py?line=42) @property [44](file:///Users/smohammed/.pyenv/versions/3.8.15/envs/internalqa/lib/python3.8/site-packages/langchain/chains/base.py?line=43) def _chain_type(self) -> str: ---> [45](file:///Users/smohammed/.pyenv/versions/3.8.15/envs/internalqa/lib/python3.8/site-packages/langchain/chains/base.py?line=44) raise NotImplementedError("Saving not supported for this chain type.") NotImplementedError: Saving not supported for this chain type. ``` There isn't any functions to support loading RetrievalQA either, unlike the VectorQA counterparts: https://github.com/hwchase17/langchain/blob/3bd5a99b835fa320d02aa733cb0c0bc4a87724fa/langchain/chains/loading.py#L313-L356
https://github.com/langchain-ai/langchain/issues/3983
https://github.com/langchain-ai/langchain/pull/5818
b93638ef1ef683dfbb46e8e7654e96325324a98c
5518f24ec38654510bada81025fe4e96c26556a7
2023-05-02T16:17:48Z
python
2023-06-08T04:07:13Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,896
["langchain/vectorstores/faiss.py"]
Remove duplication when creating and updating FAISS Vecstore
The `FAISS.add_texts` and `FAISS.merge_from` don't check duplicated document contents, and always add contents into Vecstore. ```ruby test_db = FAISS.from_texts(['text 2'], embeddings) test_db.add_texts(['text 1', 'text 2', 'text 1']) print(test_db.index_to_docstore_id) test_db.docstore._dict ``` Note that 'text 1' and 'text 2' are both added twice with different indices. ``` {0: '12a6a477-db74-4d90-b843-4cd872e070a0', 1: 'a3171e0e-f12a-418f-9994-5625550de73e', 2: '543f8fcf-bf84-4d9e-a6a9-f87fda0afcc3', 3: 'ed320a75-775f-4ec2-ae0b-fef8fa8d0bfe'} {'12a6a477-db74-4d90-b843-4cd872e070a0': Document(page_content='text 2', lookup_str='', metadata={}, lookup_index=0), 'a3171e0e-f12a-418f-9994-5625550de73e': Document(page_content='text 1', lookup_str='', metadata={}, lookup_index=0), '543f8fcf-bf84-4d9e-a6a9-f87fda0afcc3': Document(page_content='text 2', lookup_str='', metadata={}, lookup_index=0), 'ed320a75-775f-4ec2-ae0b-fef8fa8d0bfe': Document(page_content='text 1', lookup_str='', metadata={}, lookup_index=0)} ``` Also the embedding values are the same ```ruby np.dot(test_db.index.reconstruct(0), test_db.index.reconstruct(2)) ``` ``` 1.0000001 ``` **Expected Behavior:** Similar to database `upsert`, create new index if key (content or embedding) doesn't exist, otherwise update the value (document metadata in this case). I'm pretty new to LangChain, so if I'm missing something or doing it wrong, apologies and please suggest the best practice on dealing with LangChain FAISS duplication - otherwise, hope this is useful feedback, thanks!
https://github.com/langchain-ai/langchain/issues/3896
https://github.com/langchain-ai/langchain/pull/5190
f0ea093de867e5f099a4b5de2bfa24d788b79133
40b086d6e891a3cd1e678b1c8caac23b275d485c
2023-05-01T17:31:28Z
python
2023-05-25T05:26:46Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,893
["langchain/vectorstores/redis.py"]
AttributeError: 'Redis' object has no attribute 'module_list'
I'm trying to make a vectorstore using redis and store the embeddings in redis. When I write the code rds = Redis.from_documents(docs, embeddings, redis_url="redis://localhost:6379", index_name='test_link') I get the following error AttributeError: 'Redis' object has no attribute 'module_list'. Note: I'm trying to run redis locally on windows subsystem ubuntu. Please help.
https://github.com/langchain-ai/langchain/issues/3893
https://github.com/langchain-ai/langchain/pull/4932
a87a2524c7f8f55846712a682ffc80b5fc224b73
616e9a93e08f4f042c492b89545e85e80592ffbe
2023-05-01T17:02:43Z
python
2023-05-19T20:02:03Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,839
["docs/modules/models/llms/integrations/gpt4all.ipynb", "langchain/llms/gpt4all.py"]
Unable to use gpt4all model
Hi Team, I am getting below error while trying to use the gpt4all model, Can someone please advice ? Error: ``` File "/home/ubuntu/.local/share/virtualenvs/local-conversational-ai-chatbot-using-gpt4-6TvxabtR/lib/python3.10/site-packages/langchain/llms/gpt4all.py", line 181, in _call text = self.client.generate( TypeError: Model.generate() got an unexpected keyword argument 'new_text_callback' ``` Code: ``` from langchain import PromptTemplate, LLMChain from langchain.llms import GPT4All from langchain.callbacks.base import CallbackManager from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler template = """Question: {question} Answer: Let's think step by step.""" prompt = PromptTemplate(template=template, input_variables=["question"]) local_path = './models/ggjt-model.bin' # Callbacks support token-wise streaming callback_manager = CallbackManager([StreamingStdOutCallbackHandler()]) # Verbose is required to pass to the callback manager llm = GPT4All(model=local_path, callback_manager=callback_manager, verbose=True) llm_chain = LLMChain(prompt=prompt, llm=llm) question = "What NFL team won the Super Bowl in the year Justin Bieber was born?" llm_chain.run(question) ```
https://github.com/langchain-ai/langchain/issues/3839
https://github.com/langchain-ai/langchain/pull/4567
e2d7677526bd649461db38396c0c3b21f663f10e
c9e2a0187549f6fa2661b943c13af9d63d44eee1
2023-04-30T17:49:59Z
python
2023-05-18T16:38:54Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,685
["libs/langchain/langchain/retrievers/time_weighted_retriever.py"]
TimeWeightedVectorStoreRetriever (TWVSR) and ChromaDb vector store - base.py
Hi there. Realise there is a lot happening and this this looks to be something that has been missed. When trying to use TWVSR with ChromaDb it errors because of the lack of implementation of the following, namely __similarity_search_with_relevance_scores, inside of base.py `def _similarity_search_with_relevance_scores( self, query: str, k: int = 4, **kwargs: Any, ) -> List[Tuple[Document, float]]: """Return docs and relevance scores, normalized on a scale from 0 to 1. 0 is dissimilar, 1 is most similar. """ raise NotImplementedError` Trying to make a work-around now Many thanks Ian
https://github.com/langchain-ai/langchain/issues/3685
https://github.com/langchain-ai/langchain/pull/9906
bc8cceebf7b2d8e056b905926a6009367b6a8b14
4dc47bd3acc8928359773fc3fb80d289b9eae55e
2023-04-28T00:16:05Z
python
2023-09-03T22:05:30Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,664
["langchain/utilities/bash.py", "pyproject.toml"]
import error when importing `from langchain import OpenAI` on 0.0.151
got the following error when running today: ``` File "venv/lib/python3.11/site-packages/langchain/__init__.py", line 6, in <module> from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain File "venv/lib/python3.11/site-packages/langchain/agents/__init__.py", line 2, in <module> from langchain.agents.agent import ( File "venv/lib/python3.11/site-packages/langchain/agents/agent.py", line 17, in <module> from langchain.chains.base import Chain File "venv/lib/python3.11/site-packages/langchain/chains/__init__.py", line 2, in <module> from langchain.chains.api.base import APIChain File "venv/lib/python3.11/site-packages/langchain/chains/api/base.py", line 8, in <module> from langchain.chains.api.prompt import API_RESPONSE_PROMPT, API_URL_PROMPT File "venv/lib/python3.11/site-packages/langchain/chains/api/prompt.py", line 2, in <module> from langchain.prompts.prompt import PromptTemplate File "venv/lib/python3.11/site-packages/langchain/prompts/__init__.py", line 14, in <module> from langchain.prompts.loading import load_prompt File "venv/lib/python3.11/site-packages/langchain/prompts/loading.py", line 14, in <module> from langchain.utilities.loading import try_load_from_hub File "venv/lib/python3.11/site-packages/langchain/utilities/__init__.py", line 5, in <module> from langchain.utilities.bash import BashProcess File "venv/lib/python3.11/site-packages/langchain/utilities/bash.py", line 7, in <module> import pexpect ModuleNotFoundError: No module named 'pexpect' ``` does this need to be added to project dependencies?
https://github.com/langchain-ai/langchain/issues/3664
https://github.com/langchain-ai/langchain/pull/3667
708787dddb2fa3cdb2d1dabefa00c01ffec572f6
1b5721c999c9fc310cefec383666f43c80ec9620
2023-04-27T16:24:30Z
python
2023-04-27T18:39:01Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,628
["langchain/vectorstores/chroma.py", "tests/integration_tests/vectorstores/test_chroma.py"]
Chroma.py max_marginal_relevance_search_by_vector method currently broken
Using MMR with Chroma currently does not work because the max_marginal_relevance_search_by_vector method calls self.__query_collection with the parameter "include:", but "include" is not an accepted parameter for __query_collection. This appears to be a regression introduced with #3372 Excerpt from max_marginal_relevance_search_by_vector method: ``` results = self.__query_collection( query_embeddings=embedding, n_results=fetch_k, where=filter, include=["metadatas", "documents", "distances", "embeddings"], ) ``` __query_collection does not accept include: ``` def __query_collection( self, query_texts: Optional[List[str]] = None, query_embeddings: Optional[List[List[float]]] = None, n_results: int = 4, where: Optional[Dict[str, str]] = None, ) -> List[Document]: ``` This results in an unexpected keyword error. The short term fix is to use self._collection.query instead of self.__query_collection in max_marginal_relevance_search_by_vector, although that loses the protection when the user requests more records than exist in the store. ``` results = self._collection.query( query_embeddings=embedding, n_results=fetch_k, where=filter, include=["metadatas", "documents", "distances", "embeddings"], ) ```
https://github.com/langchain-ai/langchain/issues/3628
https://github.com/langchain-ai/langchain/pull/3897
3e1cb31f63b5c7147939feca7f8095377f64e145
245131097557b73774197b01e326206fa2a1b83a
2023-04-27T00:21:42Z
python
2023-05-01T17:47:15Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,605
["langchain/embeddings/huggingface.py", "tests/integration_tests/embeddings/test_huggingface.py"]
Embeddings normalization and similarity metric
I am new to using Langchain and attempting to make it work with a locally running LLM (Alpaca) and Embeddings model (Sentence Transformer). When configuring the sentence transformer model with `HuggingFaceEmbeddings` no arguments can be passed to the encode method of the model, specifically `normalize_embeddings=True`. Neither can I specify the distance metric that I want to use in the `similarity_search` method irrespective of what vector store I am using. So it seems to me I can only create unnormalized embeddings with huggingface models and only use L2 distance as the similarity metric by default. Whereas I want to use the cosine similarity metric or have normalized embeddings and then use the dot product/L2 distance. If I am wrong here can someone point me in the right direction. If not are there any plans to implement this?
https://github.com/langchain-ai/langchain/issues/3605
https://github.com/langchain-ai/langchain/pull/5450
e09afb4b4445c99bebabca4b2beb150ba3a37c5c
c1807d84086c92d1aea2eb7be181204e72ae10d0
2023-04-26T18:02:20Z
python
2023-05-30T18:57:04Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,404
["docs/use_cases/autonomous_agents/marathon_times.ipynb", "langchain/tools/ddg_search/__init__.py"]
marathon_times.ipynb: mismatched text and code
Text mentions inflation and tuition: Here is the prompt comparing inflation and college tuition. Code is about marathon times: agent.run(["What were the winning boston marathon times for the past 5 years? Generate a table of the names, countries of origin, and times."])
https://github.com/langchain-ai/langchain/issues/3404
https://github.com/langchain-ai/langchain/pull/3408
b4de839ed8a1bea7425a6923b2cd635068b6015a
73bc70b4fa7bb69647d9dbe81943b88ce6ccc180
2023-04-23T21:06:49Z
python
2023-04-24T01:14:11Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,384
["langchain/math_utils.py", "langchain/vectorstores/utils.py", "tests/unit_tests/vectorstores/__init__.py", "tests/unit_tests/vectorstores/test_utils.py"]
ValueError in cosine_similarity when using FAISS index as vector store
Getting the below error ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "...\langchain\vectorstores\faiss.py", line 285, in max_marginal_relevance_search docs = self.max_marginal_relevance_search_by_vector(embedding, k, fetch_k) File "...\langchain\vectorstores\faiss.py", line 248, in max_marginal_relevance_search_by_vector mmr_selected = maximal_marginal_relevance( File "...\langchain\langchain\vectorstores\utils.py", line 19, in maximal_marginal_relevance similarity_to_query = cosine_similarity([query_embedding], embedding_list)[0] File "...\langchain\langchain\math_utils.py", line 16, in cosine_similarity raise ValueError("Number of columns in X and Y must be the same.") ValueError: Number of columns in X and Y must be the same. ``` Code to reproduce this error ``` >>> model_name = "sentence-transformers/all-mpnet-base-v2" >>> model_kwargs = {'device': 'cpu'} >>> from langchain.embeddings import HuggingFaceEmbeddings >>> embeddings = HuggingFaceEmbeddings(model_name=model_name, model_kwargs=model_kwargs) >>> from langchain.vectorstores import FAISS >>> FAISS_INDEX_PATH = 'faiss_index' >>> db = FAISS.load_local(FAISS_INDEX_PATH, embeddings) >>> query = 'query' >>> results = db.max_marginal_relevance_search(query) ``` While going through the error it seems that in this case `query_embedding` is 1 x model_dimension while embedding_list is no_docs x model dimension vectors. Hence we should probably change the code to `similarity_to_query = cosine_similarity(query_embedding, embedding_list)[0]` i.e. remove the list from the query_embedding. Since this is a common function not sure if this change would affect other embedding classes as well.
https://github.com/langchain-ai/langchain/issues/3384
https://github.com/langchain-ai/langchain/pull/3475
53b14de636080e09e128d829aafa9ea34ac34a94
b2564a63911f8a77272ac9e93e5558384f00155c
2023-04-23T07:51:56Z
python
2023-04-25T02:54:15Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,301
["langchain/llms/llamacpp.py"]
Output using llamacpp is garbage
Hi there, Trying to setup a langchain with llamacpp as a first step to use langchain offline: `from langchain.llms import LlamaCpp llm = LlamaCpp(model_path="../llama/models/ggml-vicuna-13b-4bit-rev1.bin") text = "Question: What NFL team won the Super Bowl in the year Justin Bieber was born? Answer: Let's think step by step." print(llm(text))` The result is: `Plenement that whciation - if a praged and as Work 1 -- but a nice bagingrading per 1, In Homewooded ETenscent is the 0sm toth, ECORO Efph at as an outs! ce, found unprint this a PC, Thom. The RxR-1 dot emD In Not OslKNOT The Home On-a-a-a-aEOEfa-a-aP E. NOT, hotness of-aEF and Life in better-A (resondri Euler, rsa! Home WI Retection and O no-aL25 1 fate to Hosp doubate, p. T, this guiltEisenR-getus WEFI, duro as these disksada Tl.Eis-aRDA* plantly-aRing the Prospecttypen` Running the same question using llama_cpp_python with the same model bin file, the result is (allthough wrong, correctly formatted): `{ "id": "cmpl-d64b69f6-cd50-41e9-8d1c-25b1a5859fac", "object": "text_completion", "created": 1682085552, "model": "./models/ggml-alpaca-7b-native-q4.bin", "choices": [ { "text": "Question: What NFL team won the Super Bowl in the year Justin Bieber was born? Answer: Let's think step by step. Justin was born in 1985, so he was born in the same year as the Super Bowl victory of the Chicago Bears in 1986. So, the answer is the Chicago Bears!", "index": 0, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 32, "completion_tokens": 45, "total_tokens": 77 } }` What could be the issue, encoding/decoding?
https://github.com/langchain-ai/langchain/issues/3301
https://github.com/langchain-ai/langchain/pull/3320
3a1bdce3f51e302d468807e980455d676c0f5fd6
77bb6c99f7ee189ce3734c47b27e70dc237bbce7
2023-04-21T14:01:59Z
python
2023-04-23T01:46:55Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,241
["langchain/llms/llamacpp.py"]
llama.cpp => model runs fine but bad output
Hi, Windows 11 environement Python: 3.10.11 I installed - llama-cpp-python and it works fine and provides output - transformers - pytorch Code run: ``` from langchain.llms import LlamaCpp from langchain import PromptTemplate, LLMChain template = """Question: {question} Answer: Let's think step by step.""" prompt = PromptTemplate(template=template, input_variables=["question"]) llm = LlamaCpp(model_path=r"D:\Win10User\Downloads\AI\Model\vicuna-13B-1.1-GPTQ-4bit-128g.GGML.bin") llm_chain = LLMChain(prompt=prompt, llm=llm) question = "What is the capital of Belgium?" llm_chain.run(question) ``` Output: ``` llama.cpp: loading model from D:\Win10User\Downloads\AI\Model\vicuna-13B-1.1-GPTQ-4bit-128g.GGML.bin llama_model_load_internal: format = ggjt v1 (latest) llama_model_load_internal: n_vocab = 32000 llama_model_load_internal: n_ctx = 512 llama_model_load_internal: n_embd = 5120 llama_model_load_internal: n_mult = 256 llama_model_load_internal: n_head = 40 llama_model_load_internal: n_layer = 40 llama_model_load_internal: n_rot = 128 llama_model_load_internal: ftype = 4 (mostly Q4_1, some F16) llama_model_load_internal: n_ff = 13824 llama_model_load_internal: n_parts = 1 llama_model_load_internal: model size = 13B llama_model_load_internal: ggml ctx size = 73.73 KB llama_model_load_internal: mem required = 11749.65 MB (+ 3216.00 MB per state) llama_init_from_file: kv self size = 800.00 MB AVX = 1 | AVX2 = 1 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | VSX = 0 | llama_print_timings: load time = 2154.68 ms llama_print_timings: sample time = 75.88 ms / 256 runs ( 0.30 ms per run) llama_print_timings: prompt eval time = 5060.58 ms / 23 tokens ( 220.03 ms per token) llama_print_timings: eval time = 72461.40 ms / 255 runs ( 284.16 ms per run) llama_print_timings: total time = 77664.50 ms ``` But there is no answer to the question.... Am I supposed to Print() something?
https://github.com/langchain-ai/langchain/issues/3241
https://github.com/langchain-ai/langchain/pull/3320
3a1bdce3f51e302d468807e980455d676c0f5fd6
77bb6c99f7ee189ce3734c47b27e70dc237bbce7
2023-04-20T20:36:45Z
python
2023-04-23T01:46:55Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,157
["langchain/tools/base.py"]
Missing Observation and Thought prefix in output
The console output when running a tool is missing the "Observation" and "Thought" prefixes. I noticed this when using the SQL Toolkit, but other tools are likely affected. Here is the current INCORRECT output format: ``` > Entering new AgentExecutor chain... Action: list_tables_sql_db Action Input: ""invoice_items, invoices, tracks, sqlite_sequence, employees, media_types, sqlite_stat1, customers, playlists, playlist_track, albums, genres, artistsThere is a table called "employees" that I can query. Action: schema_sql_db Action Input: "employees" ``` Here is the expected output format: ``` > Entering new AgentExecutor chain... Action: list_tables_sql_db Action Input: "" Observation: invoice_items, invoices, tracks, sqlite_sequence, employees, media_types, sqlite_stat1, customers, playlists, playlist_track, albums, genres, artists Thought:There is a table called "employees" that I can query. Action: schema_sql_db Action Input: "employees" ``` Note: this appears to only affect the console output. The `agent_scratchpad` is updated correctly with the "Observation" and "Thought" prefixes.
https://github.com/langchain-ai/langchain/issues/3157
https://github.com/langchain-ai/langchain/pull/3158
126d7f11dd17a8ea71a4427951f10cefc862ba3a
0b542661b46d42ee501c6681a4519f2c4e76de23
2023-04-19T15:15:26Z
python
2023-04-19T16:00:10Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,117
["libs/langchain/langchain/chains/question_answering/refine_prompts.py", "libs/langchain/langchain/chains/summarize/refine_prompts.py"]
Missing new lines or empty spaces in refine default prompt.
I'm not sure if it's a typo or not but the default prompt in [langchain](https://github.com/hwchase17/langchain/tree/master/langchain)/[langchain](https://github.com/hwchase17/langchain/tree/master/langchain)/[chains](https://github.com/hwchase17/langchain/tree/master/langchain/chains)/[summarize](https://github.com/hwchase17/langchain/tree/master/langchain/chains/summarize)/[refine_prompts.py](https://github.com/hwchase17/langchain/tree/master/langchain/chains/summarize/refine_prompts.py) seems to miss a empty string or a `\n ` ``` REFINE_PROMPT_TMPL = ( "Your job is to produce a final summary\n" "We have provided an existing summary up to a certain point: {existing_answer}\n" "We have the opportunity to refine the existing summary" "(only if needed) with some more context below.\n" "------------\n" "{text}\n" "------------\n" "Given the new context, refine the original summary" "If the context isn't useful, return the original summary." ) ``` It will produce `refine the original summaryIf the context isn't useful` and `existing summary(only if needed)` I could proabbly fix it with a PR ( if it's unintentionnal), but I prefer to let someone more competent to do it as i'm not used to create PR's in large projects like this.
https://github.com/langchain-ai/langchain/issues/3117
https://github.com/langchain-ai/langchain/pull/9957
4b1532876710e08aa70cdd0d52b18084f85eaed3
29270e0378661fe3d5a77cbe95311f9d4b5d33e8
2023-04-18T22:32:58Z
python
2023-08-31T14:29:49Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,077
["docs/modules/models/llms/integrations/huggingface_hub.ipynb", "docs/modules/models/llms/integrations/huggingface_pipelines.ipynb"]
Error `can only concatenate str (not "tuple") to str` when using `ConversationBufferWindowMemory`
I'm facing a weird issue with the `ConversationBufferWindowMemory` Running `memory.load_memory_variables({})` prints: ``` {'chat_history': [HumanMessage(content='Hi my name is Ismail', additional_kwargs={}), AIMessage(content='Hello Ismail! How can I assist you today?', additional_kwargs={})]} ``` The error I get after sending a second message to the chain is: ``` > Entering new ConversationalRetrievalChain chain... [2023-04-18 10:34:52,512] ERROR in app: Exception on /api/v1/chat [POST] Traceback (most recent call last): File "/Users/homanp/Projects/ADGPT_ENV/lib/python3.9/site-packages/flask/app.py", line 2528, in wsgi_app response = self.full_dispatch_request() File "/Users/homanp/Projects/ADGPT_ENV/lib/python3.9/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/homanp/Projects/ADGPT_ENV/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/Users/homanp/Projects/ADGPT_ENV/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "/Users/homanp/Projects/ad-gpt/app.py", line 46, in chat result = chain({"question": message, "chat_history": []}) File "/Users/homanp/Projects/ADGPT_ENV/lib/python3.9/site-packages/langchain/chains/base.py", line 116, in __call__ raise e File "/Users/homanp/Projects/ADGPT_ENV/lib/python3.9/site-packages/langchain/chains/base.py", line 113, in __call__ outputs = self._call(inputs) File "/Users/homanp/Projects/ADGPT_ENV/lib/python3.9/site-packages/langchain/chains/conversational_retrieval/base.py", line 71, in _call chat_history_str = get_chat_history(inputs["chat_history"]) File "/Users/homanp/Projects/ADGPT_ENV/lib/python3.9/site-packages/langchain/chains/conversational_retrieval/base.py", line 25, in _get_chat_history human = "Human: " + human_s TypeError: can only concatenate str (not "tuple") to str ``` Current implementaion: ``` memory = ConversationBufferWindowMemory(memory_key='chat_history', k=2, return_messages=True) chain = ConversationalRetrievalChain.from_llm(model, memory=memory, verbose=True, retriever=retriever, qa_prompt=QA_PROMPT, condense_question_prompt=CONDENSE_QUESTION_PROMPT,) ```
https://github.com/langchain-ai/langchain/issues/3077
https://github.com/langchain-ai/langchain/pull/3187
6adf2d1c39ca4e157377f20d3029d062342093e6
c757c3cde45a24e0cd6a3ebe6bb0f8176cae4726
2023-04-18T08:38:57Z
python
2023-04-20T00:08:10Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
3,057
["langchain/agents/chat/output_parser.py"]
Error when parsing code from LLM response ValueError: Could not parse LLM output:
Sometimes the LLM response (generated code) tends to miss the ending ticks "```". Therefore causing the text parsing to fail due to `not enough values to unpack`. Suggest to simply the `_, action, _' to just `action` then with index Error message below ``` > Entering new AgentExecutor chain... Traceback (most recent call last): File "E:\open_source_contrib\langchain-venv\lib\site-packages\langchain\agents\chat\output_parser.py", line 17, in parse _, action, _ = text.split("```") ValueError: not enough values to unpack (expected 3, got 2) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "E:\open_source_contrib\test.py", line 67, in <module> agent_msg = agent.run(prompt_template) File "E:\open_source_contrib\langchain-venv\lib\site-packages\langchain\chains\base.py", line 213, in run return self(args[0])[self.output_keys[0]] File "E:\open_source_contrib\langchain-venv\lib\site-packages\langchain\chains\base.py", line 116, in __call__ raise e File "E:\open_source_contrib\langchain-venv\lib\site-packages\langchain\chains\base.py", line 113, in __call__ outputs = self._call(inputs) File "E:\open_source_contrib\langchain-venv\lib\site-packages\langchain\agents\agent.py", line 792, in _call next_step_output = self._take_next_step( File "E:\open_source_contrib\langchain-venv\lib\site-packages\langchain\agents\agent.py", line 672, in _take_next_step output = self.agent.plan(intermediate_steps, **inputs) File "E:\open_source_contrib\langchain-venv\lib\site-packages\langchain\agents\agent.py", line 385, in plan return self.output_parser.parse(full_output) File "E:\open_source_contrib\langchain-venv\lib\site-packages\langchain\agents\chat\output_parser.py", line 23, in parse raise ValueError(f"Could not parse LLM output: {text}") ValueError: Could not parse LLM output: Question: How do I put the given data into a pandas dataframe and save it into a csv file at the specified path? Thought: I need to use the Python REPL tool to import pandas, create a dataframe with the given data, and then use the to_csv method to save it to the specified file path. Action: ``` { "action": "Python REPL", "action_input": "import pandas as pd\n\n# create dataframe\ndata = {\n 'Quarter': ['Q4-2021', 'Q1-2022', 'Q2-2022', 'Q3-2022', 'Q4-2022'],\n 'EPS attributable to common stockholders, diluted (GAAP)': [1.07, 0.95, 0.76, 0.95, 1.07],\n 'EPS attributable to common stockholders, diluted (non-GAAP)': [1.19, 1.05, 0.85, 1.05, 1.19]\n}\ndf = pd.DataFrame(data)\n\n# save to csv\ndf.to_csv('E:\\\\open_source_contrib\\\\output\\\\agent_output.xlsx', index=False)" } (langchain-venv) PS E:\open_source_contrib> ```
https://github.com/langchain-ai/langchain/issues/3057
https://github.com/langchain-ai/langchain/pull/3058
db968284f8f3964630f119c95cca923f112ad47b
2984ad39645c80411cee5e7f77a3c116b88d008e
2023-04-18T04:13:20Z
python
2023-04-18T04:42:13Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,944
["langchain/chains/combine_documents/base.py", "langchain/chains/combine_documents/refine.py", "langchain/chains/combine_documents/stuff.py", "tests/unit_tests/chains/test_combine_documents.py"]
Question Answering over Docs giving cryptic error upon query
After ingesting some markdown files using a slightly modified version of the question-answering over docs example, I ran the qa.py script as it was in the example ``` # qa.py import faiss from langchain import OpenAI, HuggingFaceHub, LLMChain from langchain.chains import VectorDBQAWithSourcesChain import pickle import argparse parser = argparse.ArgumentParser(description='Ask a question to the notion DB.') parser.add_argument('question', type=str, help='The question to ask the notion DB') args = parser.parse_args() # Load the LangChain. index = faiss.read_index("docs.index") with open("faiss_store.pkl", "rb") as f: store = pickle.load(f) store.index = index chain = VectorDBQAWithSourcesChain.from_llm(llm=OpenAI(temperature=0), vectorstore=store) result = chain({"question": args.question}) print(f"Answer: {result['answer']}") ``` Only to get this cryptic error ``` Traceback (most recent call last): File "C:\Users\ahmad\OneDrive\Desktop\Coding\LANGCHAINSSSSSS\notion-qa\qa.py", line 22, in <module> result = chain({"question": args.question}) File "C:\Users\ahmad\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\langchain\chains\base.py", line 146, in __call__ raise e File "C:\Users\ahmad\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\langchain\chains\base.py", line 142, in __call__ outputs = self._call(inputs) File "C:\Users\ahmad\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\langchain\chains\qa_with_sources\base.py", line 97, in _call answer, _ = self.combine_document_chain.combine_docs(docs, **inputs) File "C:\Users\ahmad\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\langchain\chains\combine_documents\map_reduce.py", line 150, in combine_docs num_tokens = length_func(result_docs, **kwargs) File "C:\Users\ahmad\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\langchain\chains\combine_documents\stuff.py", line 77, in prompt_length inputs = self._get_inputs(docs, **kwargs) File "C:\Users\ahmad\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\langchain\chains\combine_documents\stuff.py", line 64, in _get_inputs document_info = { File "C:\Users\ahmad\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\langchain\chains\combine_documents\stuff.py", line 65, in <dictcomp> k: base_info[k] for k in self.document_prompt.input_variables KeyError: 'source' ``` Here is the code I used for ingesting | ``` """This is the logic for ingesting Notion data into LangChain.""" from pathlib import Path from langchain.text_splitter import CharacterTextSplitter import faiss from langchain.vectorstores import FAISS from langchain.embeddings import OpenAIEmbeddings import pickle import time from tqdm import tqdm # Here we load in the data in the format that Notion exports it in. folder = list(Path("Notion_DB/").glob("**/*.md")) files = [] sources = [] for myFile in folder: with open(myFile, 'r', encoding='utf-8') as f: print(myFile.name) files.append(f.read()) sources.append(myFile) # Here we split the documents, as needed, into smaller chunks. # We do this due to the context limits of the LLMs. text_splitter = CharacterTextSplitter(chunk_size=800, separator="\n") docs = [] metadatas = [] for i, f in enumerate(files): splits = text_splitter.split_text(f) docs.extend(splits) metadatas.extend([{"source": sources[i]}] * len(splits)) # Add each element in docs into FAISS store, keeping a delay between inserting elements so we don't exceed rate limit store = None for (index, chunk) in tqdm(enumerate(docs)): if index == 0: store = FAISS.from_texts([chunk], OpenAIEmbeddings()) else: time.sleep(1) # wait for a second to not exceed any rate limits store.add_texts([chunk]) # print('finished with index '+index.__str__()) print('Done yayy!') # # Here we create a vector store from the documents and save it to disk. faiss.write_index(store.index, "docs.index") store.index = None with open("faiss_store.pkl", "wb") as f: pickle.dump(store, f) ```
https://github.com/langchain-ai/langchain/issues/2944
https://github.com/langchain-ai/langchain/pull/3026
3453b7457ca60227430d85e6f6f58a2aafae559d
19c85aa9907765c0a2dbe7c46e9d5dd2d6df0f30
2023-04-15T15:38:36Z
python
2023-04-18T03:28:01Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,938
["libs/langchain/langchain/agents/agent_toolkits/openapi/planner.py"]
Allow OpenAPI planner to respect URLs with placeholders
In OpenAPI documentation, an endpoint might include a placeholder for a parameter: ``` GET /states/{abbr} ``` Currently, exact matches are needed with OpenAPI Planner to retrieve documentation. In the example above, `GET /states/FL` would receive a `ValueError(f"{endpoint_name} endpoint does not exist.")`.
https://github.com/langchain-ai/langchain/issues/2938
https://github.com/langchain-ai/langchain/pull/2940
e42a576cb2973e36f310e1db45d75b8fa5ba9cf6
48cf9783913077fdad7c26752c7a70b20b57fb30
2023-04-15T13:54:15Z
python
2023-10-12T23:20:32Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,905
["langchain/document_loaders/git.py"]
Ignore files from `.gitignore` in Git loader
those files may be `node_modules` or `.pycache` files or sensitive env files, all of which should be ignored by default
https://github.com/langchain-ai/langchain/issues/2905
https://github.com/langchain-ai/langchain/pull/2909
7ee87eb0c8df10315b45ebbddcad36a72b7fe7b9
66bef1d7ed17f00e7b554ca5413e336970489253
2023-04-14T17:08:38Z
python
2023-04-14T22:02:21Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,887
["langchain/callbacks/openai_info.py", "langchain/llms/openai.py"]
About fine tune model
I have fine tuned curie model of OPEN AI on sample text data and i used that model in llm = OpenAI( temperature=0.7, openai_api_key='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', model_name="curie:ft-personal-2023-03-31-05-59-15"#"text-davinci-003"#""#'' # can be used with llms like 'gpt-3.5-turbo' ) after run the script i am getting an error ValueError: Unknown model: curie:ft-personal-2023-03-31-05-59-15. Please provide a valid OpenAI model name.Known models are: gpt-4, gpt-4-0314, gpt-4-completion, gpt-4-0314-completion, gpt-4-32k, gpt-4-32k-0314, gpt-4-32k-completion, gpt-4-32k-0314-completion, gpt-3.5-turbo, gpt-3.5-turbo-0301, text-ada-001, ada, text-babbage-001, babbage, text-curie-001, curie, text-davinci-003, text-davinci-002, code-davinci-002 i have give a correct name of fine tune model. what is the issue. can anyone help me to solve this?
https://github.com/langchain-ai/langchain/issues/2887
https://github.com/langchain-ai/langchain/pull/5127
7a75bb21219b605cfd3cad30cc978eb9fb53c479
5002f3ae35070f2ba903bccb7b1028595e3c626a
2023-04-14T10:54:55Z
python
2023-05-23T18:18:03Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,874
["langchain/agents/loading.py"]
Redundunt piece of code
In Agents -> loading.py on line 40 there is a redundant piece of code. ``` if config_type not in AGENT_TO_CLASS: raise ValueError(f"Loading {config_type} agent not supported") ```
https://github.com/langchain-ai/langchain/issues/2874
https://github.com/langchain-ai/langchain/pull/2934
b40f90ea042b20440cb7c1a9e70a6e4cd4a0089c
ae7ed31386c10cee1683419a4ab45562830bf8eb
2023-04-14T05:28:42Z
python
2023-04-18T04:05:48Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,842
["docs/modules/indexes/vectorstores/examples/annoy.ipynb", "langchain/vectorstores/__init__.py", "langchain/vectorstores/annoy.py", "tests/integration_tests/vectorstores/test_annoy.py"]
Add Annoy as VectorStore
Adds Annoy index as VectorStore: https://github.com/spotify/annoy Annoy might be useful in situations where a "read only" vector store is required/sufficient. context: https://discord.com/channels/1038097195422978059/1051632794427723827/1096089994168377354
https://github.com/langchain-ai/langchain/issues/2842
https://github.com/langchain-ai/langchain/pull/2939
e12e00df12c6830cd267df18e96fda1ef8df6c7a
a9310a3e8b6781bdc8f64a379eb844f8c8154584
2023-04-13T17:10:45Z
python
2023-04-16T20:44:04Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,715
["langchain/output_parsers/fix.py", "langchain/output_parsers/pydantic.py", "langchain/output_parsers/retry.py", "langchain/output_parsers/structured.py", "langchain/schema.py", "tests/unit_tests/output_parsers/test_pydantic_parser.py"]
Better type hints for OutputParser
I'm proposing modifying the PydanticOutputParsers such that they are generic on the pydantic object passed in to the constructor, so we can get type hints on the resulting pydantic objects that are returned by `parse`. E.g ``` class TestOutput(BaseModel): output: str = ... output_parser = PydanticOutputParser(TestOutput) parsed = output_parser.parse(...) # right now this is typed as BaseModel, but it'd be better if it was TestOutput ``` I haven't looked in-depth but I think it's likely we can type the other parsers with similar fidelity. I'm happy to take this one if it's agreed that this is a useful change.
https://github.com/langchain-ai/langchain/issues/2715
https://github.com/langchain-ai/langchain/pull/2769
789cc314c5987a4d3ba5a5e8819d889036974966
59d054308c850da1a61fc9621385182c7459120d
2023-04-11T14:20:29Z
python
2023-04-12T16:12:20Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,699
["langchain/vectorstores/faiss.py"]
How to delete or update a document within a FAISS index?
Hi, I have a usecase where i have to fetch Edited posts weekly from community and update the docs within FAISS index. is that possible? or do i have to keep deleting and create new index everytime? Also i use RecursiveCharacterTextSplitter to split docs. ``` loader = DirectoryLoader('./recent_data') raw_documents = loader.load() #Splitting documents into chunks text_splitter = RecursiveCharacterTextSplitter( chunk_size=1000, chunk_overlap=200, ) documents = text_splitter.split_documents(raw_documents) print(len(documents)) # Changing source to point to the original document for x in documents: print(x.metadata["source"]) # Creating index and saving it to disk print("Creating index") db_new = FAISS.from_documents(documents, embeddings ) ``` this is output if i use ` print(db_new .docstore._dict)` `{'2d9b6fbf-a44d-46b5-bcdf-b45cd9438a4c': Document(page_content='<p dir="auto">This is a test topic.</p>', metadata={'source': 'recent/https://community.tpsonline.com/topic/587/ignore-test-topic'}), '706dcaf8-f9d9-45b9-bdf4-8a8ac7618229': Document(page_content='What is an SDD?\n\n<p dir="auto">A software design description (a.k.a. software design document or SDD; just design document; also Software Design Specification) is a representation of a software design that is to be used for recording design information, addressing various design concerns, and communicating that information to the different stakeholders.</p>\n\n<p dir="auto">This SDD template represent design w.r.t various software viewpoints, where each viewpoint will handle specific concerns of Design. This is based on <strong>ISO 42010 standard</strong>.</p>\n\nIntroduction\n\n<p dir="auto">[Name/brief description of feature for which SDD is being Produced]</p>\n\n1. Context Viewpoint\n\n<p dir="auto">[Describes the relationships, dependencies, and interactions between the system and its environment ]</p>\n\n1.1 Use Cases\n\n1.1.1 AS IS (Pre Condition)\n\n1.1.2 TO - BE (Post Condition)\n\n1.2 System Context View\n\n1.2.1 - AS IS (Pre Condition)\n\n1.2.2 TO - BE (Post Condition)\n\n2. Logical Viewpoint', metadata={'source': 'recent/https://community.tpsonline.com/topic/586/software-design-description-sdd-template'}), '4d6d4e6b-01ee-46bb-ae06-84514a51baf2': Document(page_content='1.1 Use Cases\n\n1.1.1 AS IS (Pre Condition)\n\n1.1.2 TO - BE (Post Condition)\n\n1.2 System Context View\n\n1.2.1 - AS IS (Pre Condition)\n\n1.2.2 TO - BE (Post Condition)\n\n2. Logical Viewpoint\n\n<p dir="auto">[The purpose of the Logical viewpoint is to elaborate existing and designed types and their implementations as classes and interfaces with their structural static relationships]</p>\n\n2.1 Class Diagram\n\n2.1.1 AS - IS (Pre Condition)\n\n2.1.2 TO - BE (Post Condition)\n\n2.1.2.1 Class Interfaces and description\n\n<p dir="auto">[Below is being presented as an example]<br />\n\n[This section should tell about the responsibility of each class method and their parameters too if required]</p>\n\n2.1.2.1.1 IRenewProcess\n\nMethod\n\nDescription\n\nprocessRenewal\n\nMethod to process renewal of a given cardEntity. Each concrete class that will implement the interface will implement its own version of renewal steps\n\n2.1.2.1.1 RenewStrategyContext (static class)\n\nMethod\n\nDescription\n\n(private)getRenewalMethod', metadata={'source': 'recent/https://community.tpsonline.com/topic/586/software-design-description-sdd-template'})}` so will i be able to update docs within index or is it just not possible?
https://github.com/langchain-ai/langchain/issues/2699
https://github.com/langchain-ai/langchain/pull/5190
f0ea093de867e5f099a4b5de2bfa24d788b79133
40b086d6e891a3cd1e678b1c8caac23b275d485c
2023-04-11T06:33:19Z
python
2023-05-25T05:26:46Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,698
["langchain/document_loaders/pdf.py"]
Permission Error with PDF loader
I was testing OnlinePDFLoader yesterday iirc and it was working fine. Today I tried experimenting and I keep getting this error `PermissionError: [Errno 13] Permission denied: 'C:\\Users\\REALGL~1\\AppData\\Local\\Temp\\tmp3chr08y0` it may be occurring because the `tempfile.NamedTemporaryFile()` in `pdf.py` is still open when the PDF partitioning function is trying to access it
https://github.com/langchain-ai/langchain/issues/2698
https://github.com/langchain-ai/langchain/pull/6170
4fc7939848a600064dc20b44e86c19e2cfa01491
5be465bd86f940cf831e3a4d2841d92ce8699ffb
2023-04-11T06:17:16Z
python
2023-06-18T23:39:57Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,695
["langchain/vectorstores/weaviate.py", "tests/integration_tests/vectorstores/cassettes/test_weaviate/TestWeaviate.test_max_marginal_relevance_search.yaml", "tests/integration_tests/vectorstores/cassettes/test_weaviate/TestWeaviate.test_max_marginal_relevance_search_by_vector.yaml", "tests/integration_tests/vectorstores/cassettes/test_weaviate/TestWeaviate.test_max_marginal_relevance_search_with_filter.yaml", "tests/integration_tests/vectorstores/cassettes/test_weaviate/TestWeaviate.test_similarity_search_with_metadata.yaml", "tests/integration_tests/vectorstores/cassettes/test_weaviate/TestWeaviate.test_similarity_search_with_metadata_and_filter.yaml", "tests/integration_tests/vectorstores/cassettes/test_weaviate/TestWeaviate.test_similarity_search_without_metadata.yaml", "tests/integration_tests/vectorstores/test_weaviate.py"]
Allow Weaviate initialization with alternative embedding implementation
I would like to provide an 'embeddings' parameter for the initialization of the Weaviate vector store, as I do not want to start the Weaviate server with the OpenAI key in order to make use of embeddings through the Azure OpenAI Service. The addition of the embeddings parameter affects the __init__ method, as shown in the code snippet above. To accommodate this change, you'll also need to modify the add_texts method. ```python def __init__( self, client: Any, index_name: str, text_key: str, embedding_function: Optional[Embeddings] = None, attributes: Optional[List[str]] = None, ): """Initialize with Weaviate client.""" try: import weaviate except ImportError: raise ValueError( "Could not import weaviate python package. " "Please install it with `pip install weaviate-client`." ) if not isinstance(client, weaviate.Client): raise ValueError( f"client should be an instance of weaviate.Client, got {type(client)}" ) self._client = client self._index_name = index_name self._text_key = text_key self._embedding_function = embedding_function self._query_attrs = [self._text_key] if attributes is not None: self._query_attrs.extend(attributes) ``` To check if the embeddings parameter was provided during initialization and perform the necessary actions, you can modify the add_texts method in the following way: ```python def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any, ) -> List[str]: """Upload texts with metadata (properties) to Weaviate.""" from weaviate.util import get_valid_uuid with self._client.batch as batch: ids = [] for i, doc in enumerate(texts): data_properties = { self._text_key: doc, } if metadatas is not None: for key in metadatas[i].keys(): data_properties[key] = metadatas[i][key] _id = get_valid_uuid(uuid4()) if self._embedding_function is not None: embeddings = self._embedding_function.embed_documents(list(doc)) batch.add_data_object(data_properties, self._index_name, _id, vector=embeddings[0]) else: batch.add_data_object(data_properties, self._index_name, _id) ids.append(_id) return ids ```
https://github.com/langchain-ai/langchain/issues/2695
https://github.com/langchain-ai/langchain/pull/3608
615812581ea3175b3ae9ec59036008d013052396
440c98e24bf3f18c132694309872592ef550e1bc
2023-04-11T05:19:00Z
python
2023-04-27T04:45:03Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,677
["langchain/chat_models/openai.py"]
Langchain should use tiktoken tokenizer for python 3.8
I noticed that `langchain` will not try to use the `tiktoken` tokenizer if python version is 3.8 and will switch to Hugging Face tokenizer instead ([see line 331 here](https://github.com/hwchase17/langchain/blob/master/langchain/chat_models/openai.py)). It assumes that `tiktoken` does not support python 3.8. However this does not seem to be the case (see [line 10 here](https://github.com/openai/tiktoken/blob/main/pyproject.toml)).
https://github.com/langchain-ai/langchain/issues/2677
https://github.com/langchain-ai/langchain/pull/2709
186ca9d3e485f3209aa6b465377a46c23fb98c87
f435f2267c015ffd97ff5eea9ad8c8051ea0dc0f
2023-04-10T18:40:46Z
python
2023-04-11T18:02:28Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,624
["docs/modules/models/text_embedding/examples/azureopenai.ipynb"]
Missing import in AzureOpenAI embedding example
## What's the issue? Missing import statement (for `OpenAIEmbeddings`) in AzureOpenAI embeddings example. <img width="1027" alt="Screenshot 2023-04-09 at 8 06 04 PM" src="https://user-images.githubusercontent.com/19938474/230779010-e7935543-6ae7-477c-872d-8a5220fc60c9.png"> https://github.com/hwchase17/langchain/blob/5376799a2307f03c9fdac7fc5f702749d040a360/docs/modules/models/text_embedding/examples/azureopenai.ipynb ## Expected behaviour Import `from langchain.embeddings import OpenAIEmbeddings` before using creating an embedding object.
https://github.com/langchain-ai/langchain/issues/2624
https://github.com/langchain-ai/langchain/pull/2625
0f5d3b339009f0bc0d5a59356e82870d9f0f15d6
9aed565f130b44a6e6287ac572be6be26f064f71
2023-04-09T14:38:44Z
python
2023-04-09T19:25:31Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,500
["docs/modules/indexes/vectorstores/examples/opensearch.ipynb", "langchain/vectorstores/opensearch_vector_search.py"]
OpenSearchVectorSearch doesn't permit the user to specify a field name
Currently the `OpenSearchVectorSearch` class [defaults to `vector_field`](https://github.com/hwchase17/langchain/blob/26314d7004f36ca01f2c843a3ac38b166c9d2c44/langchain/vectorstores/opensearch_vector_search.py#L189) as the field name of the vector field in all vector similarity searches. This works fine if you're populating your OpenSearch instance with data via LangChain, but doesn't work well if you're attempting to query a vector field with a different name that's been populated by some other process. For maximum utility, users should be able to customize which field is being queried.
https://github.com/langchain-ai/langchain/issues/2500
https://github.com/langchain-ai/langchain/pull/2509
ad87584c35f78551b3b02b2322c720b173584860
2ffb90b1613b01f238a084b5848bed80882f4720
2023-04-06T15:46:29Z
python
2023-04-06T19:45:56Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,483
["docs/modules/agents/streaming_stdout_final_only.ipynb", "langchain/callbacks/streaming_stdout_final_only.py"]
using a Agent and wanted to stream just the final response
I am using a Agent and wanted to stream just the final response, do you know if that is supported already? and how to do it?
https://github.com/langchain-ai/langchain/issues/2483
https://github.com/langchain-ai/langchain/pull/4630
3bc0bf007995936e4964bbf26696a71415724fde
7388248b3eeb6966e9139d60d786416c6cb73d66
2023-04-06T09:58:04Z
python
2023-05-20T16:20:17Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,245
["docs/modules/models/llms/integrations/promptlayer_openai.ipynb"]
Wrong PromptLayer Dashboard hyperlink
In the docs, in https://python.langchain.com/en/latest/modules/models/llms/integrations/promptlayer_openai.html there is a hyperlink to the PromptLayer dashboard that links to "https://ww.promptlayer.com", which is incorrect.
https://github.com/langchain-ai/langchain/issues/2245
https://github.com/langchain-ai/langchain/pull/2246
e57b045402b52c2a602f4895c5b06fa2c22b745a
632c2b49dabbccab92e37d01e4d1d86b6fa68457
2023-03-31T20:33:41Z
python
2023-03-31T23:16:23Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
2,174
["tests/unit_tests/chains/test_llm_bash.py", "tests/unit_tests/test_bash.py"]
failed tests on Windows platform
NOTE: fixed in #2238 PR. I'm running `tests/unit_tests` on the Windows platform and several tests related to `bash` failed. >test_llm_bash/ test_simple_question and >test_bash/ test_pwd_command test_incorrect_command test_incorrect_command_return_err_output test_create_directory_and_files If it is because these tests should run only on Linux, we can add >if not sys.platform.startswith("win"): pytest.skip("skipping windows-only tests", allow_module_level=True) to the `test_bash.py` and >@pytest.mark.skipif(sys.platform.startswith("win", reason="skipping windows-only tests") to `test_llm_bash/test_simple_question` regarding [this](https://docs.pytest.org/en/7.1.x/how-to/skipping.html). If you want you can assign this issue to me :) UPDATE: Probably` tests/unit_test/utilities/test_loading/[test_success, test_failed_request]` (tests with correspondent `_teardown`) are also failing because of the Windows environment.
https://github.com/langchain-ai/langchain/issues/2174
https://github.com/langchain-ai/langchain/pull/2238
609b14a57004b4679341a05729577ec5dbcaff7d
579ad85785a4011bdcb9fc316d2c1bcddfb9d427
2023-03-30T03:43:17Z
python
2023-04-01T19:52:21Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,962
["langchain/document_loaders/youtube.py"]
AttributeError: type object 'YoutubeLoader' has no attribute 'from_youtube_url'
I am trying to load load video and came across below issue. I am using langchain version 0.0.121 ![image](https://user-images.githubusercontent.com/99241695/227492256-c22f93e2-9666-4971-b0a9-0eba7b3dfc8e.png)
https://github.com/langchain-ai/langchain/issues/1962
https://github.com/langchain-ai/langchain/pull/2734
0ab364404ecfcda96a67c0fe81b24fc870617976
744c25cd0ac74c5608a564312c6e5b48c6276359
2023-03-24T10:08:17Z
python
2023-04-12T04:12:58Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,958
["docs/modules/agents/toolkits/examples/csv.ipynb", "docs/modules/agents/toolkits/examples/pandas.ipynb", "docs/modules/agents/toolkits/examples/titanic_age_fillna.csv", "langchain/agents/agent_toolkits/csv/base.py", "langchain/agents/agent_toolkits/pandas/base.py", "langchain/agents/agent_toolkits/pandas/prompt.py", "tests/integration_tests/agent/test_csv_agent.py", "tests/integration_tests/agent/test_pandas_agent.py"]
How to work with multiple csv files in the same agent session ? is there any option to call agent with multiple csv files, so that the model can interact multiple files and answer us.
null
https://github.com/langchain-ai/langchain/issues/1958
https://github.com/langchain-ai/langchain/pull/5009
3223a97dc61366f7cbda815242c9354bff25ae9d
7652d2abb01208fd51115e34e18b066824e7d921
2023-03-24T07:46:39Z
python
2023-05-25T21:23:11Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,838
["langchain/vectorstores/chroma.py"]
How metadata is being used during similarity search and query?
I have 3 pdf files in my directory and I "documentized", added metadata, split, embed and store them in pinecone, like this: ``` loader = DirectoryLoader('data/dir', glob="**/*.pdf", loader_cls=UnstructuredPDFLoader) data = loader.load() #I added company names explicitly for now data[0].metadata["company"]="Apple" data[1].metadata["company"]="Miscrosoft" data[2].metadata["company"]="Tesla" text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=200) texts = text_splitter.split_documents(data) embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY) pinecone.init( api_key=PINECONE_API_KEY, environment=PINECONE_API_ENV ) metadatas = [] for text in texts: metadatas.append({ "company": text.metadata["company"] }) Pinecone.from_texts([t.page_content for t in texts], embeddings, index_name=index_name, metadatas=metadatas) ``` I want to build a Q&A system, so that I will mention a company name in my query and pinecon should look for the documents having company `A` in the metadata. Here what I have: ``` pinecone.init( api_key=PINECONE_API_KEY, environment=PINECONE_API_ENV ) index_name = "index" embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY) docsearch = Pinecone.from_existing_index(index_name=index_name, embedding=embeddings) llm = ChatOpenAI(temperature=0, openai_api_key=OPENAI_API_KEY) chain = load_qa_chain(llm, chain_type="stuff") query = "What is the total revenue of Apple?" docs = docsearch.similarity_search(query, include_metadata=True) res = chain.run(input_documents=docs, question=query) print(res) ``` However, there are still document chunks from non-Apple documents in the output of `docs`. What am I doing wrong here and how do I utilize the information in metadata both on doc_search and chat-gpt query (If possible)? Thanks
https://github.com/langchain-ai/langchain/issues/1838
https://github.com/langchain-ai/langchain/pull/1964
f257b08406563af9ffb044da45b829d0707d755b
953e58d0040773c76f68e633c3db3cd371c9c350
2023-03-21T01:32:20Z
python
2023-03-27T22:04:53Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,834
["langchain/chains/llm_math/base.py"]
LLMMathChain to allow ChatOpenAI as an llm
1. Cannot initialize match chain with ChatOpenAI LLM llm_math = LLMMathChain(llm=ChatOpenAI(temperature=0)) --------------------------------------------------------------------------- ValidationError Traceback (most recent call last) Cell In[33], line 1 ----> 1 llm_math = LLMMathChain(llm=ChatOpenAI(temperature=0)) File ~/anaconda3/envs/gpt_index/lib/python3.8/site-packages/pydantic/main.py:341, in pydantic.main.BaseModel.__init__() ValidationError: 1 validation error for LLMMathChain llm Can't instantiate abstract class BaseLLM with abstract methods _agenerate, _generate, _llm_type (type=type_error) 2. Works ok with OpenAI LLM llm_math = LLMMathChain(llm=OpenAI(temperature=0))
https://github.com/langchain-ai/langchain/issues/1834
https://github.com/langchain-ai/langchain/pull/2183
3207a7482915a658cf8f473ae0a81ba9998c8531
fd1fcb5a7d48cbe18b480b1493b66540e4709745
2023-03-20T23:12:24Z
python
2023-03-30T14:52:58Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,829
["docs/extras/modules/data_connection/document_loaders/integrations/url.ipynb"]
UnstructuredURLLoader Error 403
**Issue:** When trying to read data from some URLs, I get a 403 error during load. I assume this is due to the web-server not allowing all user agents. **Expected behavior:** It would be great if I could specify a user agent (e.g. standard browsers like Mozilla, maybe also Google bots) for making the URL requests. **My code** ``` from langchain.document_loaders import UnstructuredURLLoader urls = ["https://dsgvo-gesetz.de/art-1"] loader = UnstructuredURLLoader(urls=urls) data = loader.load() ``` **Error message** ``` ValueError Traceback (most recent call last) Cell In[62], line 1 ----> 1 data = loader.load() File /opt/conda/lib/python3.10/site-packages/langchain/document_loaders/url.py:28, in UnstructuredURLLoader.load(self) 26 docs: List[Document] = list() 27 for url in self.urls: ---> 28 elements = partition_html(url=url) 29 text = "\n\n".join([str(el) for el in elements]) 30 metadata = {"source": url} File /opt/conda/lib/python3.10/site-packages/unstructured/partition/html.py:72, in partition_html(filename, file, text, url, encoding, include_page_breaks, include_metadata, parser) 70 response = requests.get(url) 71 if not response.ok: ---> 72 raise ValueError(f"URL return an error: {response.status_code}") 74 content_type = response.headers.get("Content-Type", "") 75 if not content_type.startswith("text/html"): ValueError: URL return an error: 403 ``` **for reference: URL that works without the 403 error** ```https://www.heise.de/newsticker/```
https://github.com/langchain-ai/langchain/issues/1829
https://github.com/langchain-ai/langchain/pull/6246
ca7a44d0242f2de4bbbb3b78942dcb6309487662
92f05a67a44c5d2a7a60280d7083cb96f3685371
2023-03-20T21:26:40Z
python
2023-06-19T00:47:00Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,805
["docs/modules/document_loaders/examples/azure_blob_storage_container.ipynb", "docs/modules/document_loaders/examples/azure_blob_storage_file.ipynb", "langchain/document_loaders/__init__.py", "langchain/document_loaders/azure_blob_storage_container.py", "langchain/document_loaders/azure_blob_storage_file.py"]
Document loader for Azure Blob storage
Lots of customers is asking if langchain have a document loader like AWS S3 or GCS for Azure Blob Storage as well. As you know Microsoft is a big partner for OpenAI , so there is a real need to have native document loader for Azure Blob storage as well. We will be very happy to see this feature ASAP.
https://github.com/langchain-ai/langchain/issues/1805
https://github.com/langchain-ai/langchain/pull/1890
42d725223ea3765a7699e19d46a6e0c70b4baa79
c1a9d83b34441592d063c4d0753029c187b1c16a
2023-03-20T02:39:16Z
python
2023-03-27T15:17:14Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,801
["poetry.toml"]
Poetry 1.4.0 installation fails
`poetry install -E all` fails with Poetry >=1.4.0 due to upstream incompatibility between `poetry>=1.4.0` and `pydata_sphinx_theme`. This is a tracking issue. I've already created an issue upstream here: https://github.com/pydata/pydata-sphinx-theme/issues/1253
https://github.com/langchain-ai/langchain/issues/1801
https://github.com/langchain-ai/langchain/pull/1935
3d3e52352005aef549f9e19ad6ab18428887865c
c50fafb35d22f0f2b4e39ebb24a5ee6177c8f44e
2023-03-19T23:42:55Z
python
2023-03-27T15:27:54Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,766
["langchain/sql_database.py", "pyproject.toml"]
Update poetry lock to allow SQLAlchemy v2
It seems that #1578 adds support for SQLAlchemy v2 but the [poetry lock file](https://github.com/hwchase17/langchain/blob/8685d53adcdd0310e76349ecb4e2b87f980c4673/poetry.lock#L6211) is still at 1.4.46.
https://github.com/langchain-ai/langchain/issues/1766
https://github.com/langchain-ai/langchain/pull/3310
7c2c73af5f15799c9326e99ed15c4a30fd19ad11
b7658059643cd2f8fa58a2132b7d723638445ebc
2023-03-19T01:48:23Z
python
2023-04-25T04:10:56Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,756
["langchain/vectorstores/pinecone.py", "tests/integration_tests/vectorstores/test_pinecone.py"]
namespace argument not taken into account when creating Pinecone index
# Quick summary Using the `namespace` argument in the function `Pinecone.from_existing_index` has no effect. Indeed, it is passed to `pinecone.Index`, which has no `namespace` argument. # Steps to reproduce a relevant bug ``` import pinecone from langchain.docstore.document import Document from langchain.vectorstores.pinecone import Pinecone from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings index = pinecone.Index("langchain-demo") # this should be a new index texts = ["foo", "bar", "baz"] metadatas = [{"page": i} for i in range(len(texts))] Pinecone.from_texts( texts, FakeEmbeddings(), index_name="langchain-demo", metadatas=metadatas, namespace="test-namespace", ) texts = ["foo2", "bar2", "baz2"] metadatas = [{"page": i} for i in range(len(texts))] Pinecone.from_texts( texts, FakeEmbeddings(), index_name="langchain-demo", metadatas=metadatas, namespace="test-namespace2", ) # Search with namespace docsearch = Pinecone.from_existing_index("langchain-demo", embedding=FakeEmbeddings(), namespace="test-namespace") output = docsearch.similarity_search("foo", k=6) # check that we don't get results from the other namespace page_contents = [o.page_content for o in output] assert set(page_contents) == set(["foo", "bar", "baz"]) ``` # Fix The `namespace` argument used in `Pinecone.from_existing_index` and `Pinecone.from_texts` should be stored as an attribute and used by default by every method.
https://github.com/langchain-ai/langchain/issues/1756
https://github.com/langchain-ai/langchain/pull/1757
280cb4160d9bd6cdb80edb5f766a06216610002c
3701b2901e76f2f97239c2152a6a7d01754fb666
2023-03-18T12:26:39Z
python
2023-03-19T02:55:38Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,733
["libs/langchain/langchain/chains/llm.py"]
list index out of range error if similarity search gives 0 docs
https://github.com/hwchase17/langchain/blob/276940fd9babf8aec570dd869cc84fbca1c766bf/langchain/vectorstores/milvus.py#L319 I'm using milvus where for my question I'm getting 0 documents and so index out of range error occurs Error line: https://github.com/hwchase17/langchain/blob/276940fd9babf8aec570dd869cc84fbca1c766bf/langchain/chains/llm.py#L95
https://github.com/langchain-ai/langchain/issues/1733
https://github.com/langchain-ai/langchain/pull/5769
c0acbdca1b5884ac90d17908fb2bb555a9ed9909
2184e3a4005f5c48126523cce92930fca6a31760
2023-03-17T11:14:48Z
python
2023-08-11T05:50:39Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,712
["langchain/chains/qa_with_sources/base.py"]
bug(QA with Sources): source parsing is not reliable
I was going through [Vectorstore Agent](https://langchain.readthedocs.io/en/latest/modules/agents/agent_toolkits/vectorstore.html?highlight=vectorstore%20agent#vectorstore-agent) tutorial and I am facing issues with the `VectorStoreQAWithSourcesTool`. Looking closely at the code https://github.com/hwchase17/langchain/blob/3c2468452284ee37b8a88a20b864255fa4385b65/langchain/chains/qa_with_sources/base.py#L119-L120 it appears, the parsing rule might be too strict for extract the list of sources. Often, when the agent is fetching information from the vectorstore, the `VectorStoreQAWithSourcesTool` output is something like `....SOURCES:\n<source1>\n<source2>...` instead of `...SOURCES: <source1>,<source2>...`. Due to this, the `VectorStoreQAWithSourcesTool` output is broken and the agent response is impacted. P.S. I used `Chroma` as the vectorstore db and `OpenAI(temperature=0)` as the LLM.
https://github.com/langchain-ai/langchain/issues/1712
https://github.com/langchain-ai/langchain/pull/2118
c33e055f17d59e225cc009c49b28d4400d56e709
859502b16c132e6d2f02d5233233f20f78847bdb
2023-03-16T15:47:53Z
python
2023-03-28T22:28:20Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,634
["langchain/document_loaders/googledrive.py"]
GoogleDriveLoader not loading docs from Share Drives
https://github.com/hwchase17/langchain/blob/cb646082baa173fdee7f2b1e361be368acef4e7e/langchain/document_loaders/googledrive.py#L120 Suggestion: Include optional param `includeItemsFromAllDrives` when calling `service.files().list()` Reference: https://stackoverflow.com/questions/65388539/using-python-i-cant-access-shared-drive-folders-from-google-drive-api-v3
https://github.com/langchain-ai/langchain/issues/1634
https://github.com/langchain-ai/langchain/pull/2562
7bf5b0ccd36a72395ac16ebafdfb3453d57c6e9d
125afb51d791577ef078554f0ceec817a7ca4e22
2023-03-13T15:03:55Z
python
2023-04-08T15:46:55Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,619
["langchain/vectorstores/chroma.py"]
ChromaDB does not support filtering when using ```similarity_search``` or ```similarity_search_by_vector```
Whereas it should be possible to filter by metadata : - ```langchain.vectorstores.chroma.similarity_search``` takes a ```filter``` input parameter but do not forward it to ```langchain.vectorstores.chroma.similarity_search_with_score``` - ```langchain.vectorstores.chroma.similarity_search_by_vector``` don't take this parameter in input, although it could be very useful, without any additional complexity - and it would thus be coherent with the syntax of the two other functions
https://github.com/langchain-ai/langchain/issues/1619
https://github.com/langchain-ai/langchain/pull/1621
28091c21018677355a124dd9c46213db3a229183
d383c0cb435273de83595160c14a2cb45dcecf2a
2023-03-12T23:58:13Z
python
2023-05-09T23:43:00Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,489
["langchain/agents/agent.py"]
LLM making its own observation when a tool should be used
I'm playing with the [CSV agent example](https://langchain.readthedocs.io/en/latest/modules/agents/agent_toolkits/csv.html) and notice something strange. For some prompts, the LLM makes up its own observations for actions that require tool execution. For example: ``` agent.run("Summarize the data in one sentence") > Entering new LLMChain chain... Prompt after formatting: You are working with a pandas dataframe in Python. The name of the dataframe is `df`. You should use the tools below to answer the question posed of you. python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer. Use the following format: Question: the input question you must answer Thought: you should always think about what to do Action: the action to take, should be one of [python_repl_ast] Action Input: the input to the action Observation: the result of the action ... (this Thought/Action/Action Input/Observation can repeat N times) Thought: I now know the final answer Final Answer: the final answer to the original input question This is the result of `print(df.head())`: PassengerId Survived Pclass \ 0 1 0 3 1 2 1 1 2 3 1 3 3 4 1 1 4 5 0 3 Name Sex Age SibSp \ 0 Braund, Mr. Owen Harris male 22.0 1 1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 2 Heikkinen, Miss. Laina female 26.0 0 3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 4 Allen, Mr. William Henry male 35.0 0 Parch Ticket Fare Cabin Embarked 0 0 A/5 21171 7.2500 NaN S 1 0 PC 17599 71.2833 C85 C 2 0 STON/O2. 3101282 7.9250 NaN S 3 0 113803 53.1000 C123 S 4 0 373450 8.0500 NaN S Begin! Question: Summarize the data in one sentence > Finished chain. Thought: I should look at the data and see what I can tell Action: python_repl_ast Action Input: df.describe() Observation: <-------------- LLM makes this up. Possibly from pre-trained data? PassengerId Survived Pclass Age SibSp \ count 891.000000 891.000000 891.000000 714.000000 891.000000 mean 446.000000 0.383838 2.308642 29.699118 0.523008 std 257.353842 0.486592 0.836071 14.526497 1.102743 min 1.000000 0.000000 1.000000 0.420000 0.000000 25% 223.500000 0.000000 2.000000 20.125000 0.000000 50% 446.000000 0.000000 3.000000 28.000000 0.000000 75% 668.500000 1.000000 3.000000 38.000000 1.000000 max 891.000000 1.000000 ``` The `python_repl_ast` tool is then run and mistakes the LLM's observation as python code, resulting in a syntax error. Any idea how to fix this?
https://github.com/langchain-ai/langchain/issues/1489
https://github.com/langchain-ai/langchain/pull/1566
30383abb127d7687a82df6593dd74329d00db730
a9502872069409039c69b41d4857b2c7791c3752
2023-03-07T06:41:07Z
python
2023-03-10T00:36:15Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,383
["langchain/sql_database.py"]
ValueError: unsupported format character 'b' (0x62) at index 52
python version 3.9.12, langchain version 0.0.98 Using this code ``` db = SQLDatabase.from_uri(DATABSE_URI, include_tables=['tbl_abc']) toolkit = SQLDatabaseToolkit(db=db) agent_executor = create_sql_agent( llm=OpenAI(temperature=0), toolkit=toolkit, verbose=True ) agent_executor.run("search for the best food at ABC") ``` Facing below error ``` > Entering new AgentExecutor chain... Action: list_tables_sql_db Action Input: "" Observation: tbl_abc Thought: I should check the schema of the table to see what columns I can query. Action: schema_sql_db Action Input: "tbl_abc" Observation: CREATE TABLE tbl_chat ( chat_id BIGINT(20) NOT NULL AUTO_INCREMENT, user_id INTEGER(11), chat_msg TEXT, last_taged_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', ............ ........... no_of_likes INTEGER(11) NOT NULL DEFAULT '0', PRIMARY KEY (chat_id) )DEFAULT CHARSET=latin1 ENGINE=InnoDB SELECT * FROM 'tbl_chat' LIMIT 3; chat_id user_id chat_msg ................ last_taged_on no_of_likes 66 17 Hello 2009-11-06 06:11:39 2010-05-19 03:56:34 0 None 0 None 0 0000-00-00 00:00:00 1 0 1 1 0 0 0000-00-00 0 66/Hello 0 67 18 Welcome to MouseWait Live Chat! 2009-11-06 06:27:03 2021-08-11 05:27:51 0 None 0 None 0 0000-00-00 00:00:00 7 4 1 1 0 0 0000-00-00 0 67/Welcome-to-MouseWait-Live-Chat 0 74 20 Hello 2009-11-06 07:56:53 2014-06-03 14:08:03 0 None 0 None 0 0000-00-00 00:00:00 3 2 1 1 0 0 0000-00-00 0 74/Hello 0 Thought: I can query the tbl_chat table for the best food at ABC. Action: query_sql_db Action Input: SELECT chat_msg FROM tbl_chat WHERE chat_msg LIKE '%best food%' ORDER BY no_of_likes DESC LIMIT 10Traceback (most recent call last): File "testing_SQL\test2.py", line 28, in <module> agent_executor.run("search for the best food at MouseWait") File "testing_SQL\venv\lib\site-packages\langchain\chains\base.py", line 239, in run return self(args[0])[self.output_keys[0]] File "testing_SQL\venv\lib\site-packages\langchain\chains\base.py", line 142, in __call__ raise e File "testing_SQL\venv\lib\site-packages\langchain\chains\base.py", line 139, in __call__ outputs = self._call(inputs) File "testing_SQL\venv\lib\site-packages\langchain\agents\agent.py", line 503, in _call next_step_output = self._take_next_step( File "testing_SQL\venv\lib\site-packages\langchain\agents\agent.py", line 420, in _take_next_step observation = tool.run( File "testing_SQL\venv\lib\site-packages\langchain\tools\base.py", line 71, in run raise e File "testing_SQL\venv\lib\site-packages\langchain\tools\base.py", line 68, in run observation = self._run(tool_input) File "testing_SQL\venv\lib\site-packages\langchain\tools\sql_database\tool.py", line 39, in _run return self.db.run_no_throw(query) File "testing_SQL\venv\lib\site-packages\langchain\sql_database.py", line 216, in run_no_throw return self.run(command, fetch) File "testing_SQL\venv\lib\site-packages\langchain\sql_database.py", line 180, in run cursor = connection.exec_driver_sql(command) File "testing_SQL\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1760, in exec_driver_sql return self._exec_driver_sql( File "testing_SQL\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1669, in _exec_driver_sql ret = self._execute_context( File "testing_SQL\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1943, in _execute_context self._handle_dbapi_exception( File "testing_SQL\venv\lib\site-packages\sqlalchemy\engine\base.py", line 2128, in _handle_dbapi_exception util.raise_(exc_info[1], with_traceback=exc_info[2]) File "testing_SQL\venv\lib\site-packages\sqlalchemy\util\compat.py", line 211, in raise_ raise exception File "testing_SQL\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1900, in _execute_context self.dialect.do_execute( File "testing_SQL\venv\lib\site-packages\sqlalchemy\engine\default.py", line 736, in do_execute cursor.execute(statement, parameters) File "testing_SQL\venv\lib\site-packages\pymysql\cursors.py", line 146, in execute query = self.mogrify(query, args) File "testing_SQL\venv\lib\site-packages\pymysql\cursors.py", line 125, in mogrify query = query % self._escape_args(args, conn) ValueError: unsupported format character 'b' (0x62) at index 52 Process finished with exit code 1```
https://github.com/langchain-ai/langchain/issues/1383
https://github.com/langchain-ai/langchain/pull/1408
443992c4d58dcb168a21c0f45afb36b84fbdd46a
882f7964fb0c5364bce0dcfb73abacd8ece525e4
2023-03-02T07:22:39Z
python
2023-03-03T00:03:16Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,339
["tests/unit_tests/test_bash.py"]
UT test_bash.py broken on MacOS dev environment
I forked & cloned the project to my dev env on MacOS, then ran 'make test', the test case 'test_incorrect_command_return_err_output' from test_bash.py failed with the following output: <img width="1139" alt="image" src="https://user-images.githubusercontent.com/64731944/221828313-4c3f6284-9fd4-4bb5-b489-8d7e911ada03.png"> I then tried the test in my Linux dev env, the test case passed successfully. this line of code in the test case: `output = session.run(["invalid_command"])` its output on MacOS is: `/bin/sh: invalid_command: command not found\n` and on Linux it is `/bin/sh: 1: invalid_command: not found\n` The difference is from the underlying "subprocess" library, and as lots of developers use MacOS as their dev env, I think it makes sense to make the test case support both MacOS and Linux, so I would suggest using a regex to do the assertion: `assert re.match(r'^/bin/sh:.*invalid_command.*not found.*$', output)`
https://github.com/langchain-ai/langchain/issues/1339
https://github.com/langchain-ai/langchain/pull/1837
b706966ebc7e17cef3ced81c8e59c8f2d648a8c8
a92344f476fc3f18599442790a1423505eec9eb4
2023-02-28T10:51:39Z
python
2023-03-21T16:06:52Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,186
["langchain/vectorstores/faiss.py", "tests/integration_tests/vectorstores/test_faiss.py"]
max_marginal_relevance_search_by_vector with k > doc size
#1117 didn't seem to fix it? I still get an error `KeyError: -1` Code to reproduce: ```py output = docsearch.max_marginal_relevance_search_by_vector(query_vec, k=10) ``` where `k > len(docsearch)`. Pushing PR with unittest/fix shortly.
https://github.com/langchain-ai/langchain/issues/1186
https://github.com/langchain-ai/langchain/pull/1187
159c560c95ed9e11cc740040cc6ee07abb871ded
c5015d77e23b24b3b65d803271f1fa9018d53a05
2023-02-20T19:19:29Z
python
2023-02-21T00:39:13Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,103
["langchain/sql_database.py"]
SQLDatabase chain having issue running queries on the database after connecting
Langchain SQLDatabase and using SQL chain is giving me issues in the recent versions. My goal has been this: - Connect to a sql server (say, Azure SQL server) using mssql+pyodbc driver (also tried mssql+pymssql driver) `connection_url = URL.create( "mssql+pyodbc", query={"odbc_connect": conn} )` `sql_database = SQLDatabase.from_uri(connection_url)` - Use this sql_database to create a SQLSequentialChain (also tried SQLChain) `chain = SQLDatabaseSequentialChain.from_llm( llm=self.llm, database=sql_database, verbose=False, query_prompt=chain_prompt)` - Query this chain However, in the most recent version of langchain 0.0.88, I get this issue: <img width="663" alt="image" src="https://user-images.githubusercontent.com/25394373/219547335-4108f02e-4721-425a-a7a3-199a70cd97f1.png"> And in the previous version 0.0.86, I was getting this: <img width="646" alt="image" src="https://user-images.githubusercontent.com/25394373/219547750-f46f1ecb-2151-4700-8dae-e2c356f79aea.png"> A few days back, this worked - but I didn't track which version that was so I have been unable to make this work. Please help look into this.
https://github.com/langchain-ai/langchain/issues/1103
https://github.com/langchain-ai/langchain/pull/1129
1ed708391e80a4de83e859b8364a32cc222df9ef
c39ef70aa457dcfcf8ddcf61f89dd69d55307744
2023-02-17T04:18:02Z
python
2023-02-17T21:39:44Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
1,087
["langchain/vectorstores/qdrant.py"]
Qdrant Wrapper issue: _document_from_score_point exposes incorrect key for content
![Screenshot 2023-02-16 at 6 47 59 PM](https://user-images.githubusercontent.com/110235735/219375362-7990e980-d19f-4606-a4cc-37ee3a2e66a0.png) ``` pydantic.error_wrappers.ValidationError: 1 validation error for Document page_content none is not an allowed value (type=type_error.none.not_allowed) ```
https://github.com/langchain-ai/langchain/issues/1087
https://github.com/langchain-ai/langchain/pull/1088
774550548242f44df9b219595cd46d9e238351e5
5d11e5da4077ad123bfff9f153f577fb5885af53
2023-02-16T13:18:41Z
python
2023-02-16T15:06:02Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
983
["langchain/cache.py"]
SQLite Cache memory for async agent runs fails in concurrent calls
I have a slack bot using slack bolt for python to handle various request for certain topics. Using the SQLite Cache as described in here https://langchain.readthedocs.io/en/latest/modules/llms/examples/llm_caching.html Fails when asking the same question mutiple times for the first time with error > (sqlite3.IntegrityError) UNIQUE constraint failed: full_llm_cache.prompt, full_llm_cache.llm, full_llm_cache.idx As an example code: ```python3 from langchain.cache import SQLiteCache langchain.llm_cache = SQLiteCache(database_path=".langchain.db") import asyncio from slack_bolt.async_app import AsyncApp from slack_bolt.adapter.socket_mode.async_handler import AsyncSocketModeHandler # For simplicity lets imagine that here we # instanciate LLM , CHAINS and AGENT app = AsyncApp(token=SLACK_BOT_API_KEY) async def async_run(self, agent_class, llm, chains): @app.event('app_mention') async def handle_mention(event, say, ack): # Acknowlegde message to slack await ack() # Get response from agent response = await agent.arun(message) #Send response to slack await say(response) handler = AsyncSocketModeHandler(app, SLACK_BOT_TOKEN) await handler.start_async() asyncio.run(async_run(agent, llm, chains)) ``` I imagine that this has something to do with how the async calls interact with the cache, as it seems that the first async call creates the prompt in the sqlite mem cache but without the answer, the second one (and other) async calls tries to create the same record in the sqlite db, but fails because of the first entry.
https://github.com/langchain-ai/langchain/issues/983
https://github.com/langchain-ai/langchain/pull/1286
81abcae91a3bbd3c90ac9644d232509b3094b54d
42b892c21be7278689cabdb83101631f286ffc34
2023-02-10T19:30:13Z
python
2023-02-27T01:54:43Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
906
["langchain/vectorstores/pinecone.py"]
Error in Pinecone batch selection logic
Current implementation of pinecone vec db finds the batches using: ``` # set end position of batch i_end = min(i + batch_size, len(texts)) ``` [link](https://github.com/hwchase17/langchain/blob/master/langchain/vectorstores/pinecone.py#L199) But the following lines then go on to use a mix of `[i : i + batch_size]` and `[i:i_end]` to create batches: ```python # get batch of texts and ids lines_batch = texts[i : i + batch_size] # create ids if not provided if ids: ids_batch = ids[i : i + batch_size] else: ids_batch = [str(uuid.uuid4()) for n in range(i, i_end)] ``` Fortunately, there is a `zip` function a few lines down that cuts the potentially longer chunks, preventing an error from being raised — yet I don't think think `[i: i+batch_size]` should be maintained as it's confusing and not explicit Raised a PR here #907
https://github.com/langchain-ai/langchain/issues/906
https://github.com/langchain-ai/langchain/pull/907
82c080c6e617d4959fb4ee808deeba075f361702
3aa53b44dd5f013e35c316d110d340a630b0abd1
2023-02-06T07:52:59Z
python
2023-02-06T20:45:56Z
closed
langchain-ai/langchain
https://github.com/langchain-ai/langchain
897
["docs/modules/utils/combine_docs_examples/vectorstores.ipynb"]
Pinecone in docs is outdated
Pinecone default environment was recently changed from `us-west1-gcp` to `us-east1-gcp` ([see here](https://docs.pinecone.io/docs/projects#project-environment)), so new users following the [docs here](https://langchain.readthedocs.io/en/latest/modules/utils/combine_docs_examples/vectorstores.html#pinecone) will hit an error when initializing. Submitted #898
https://github.com/langchain-ai/langchain/issues/897
https://github.com/langchain-ai/langchain/pull/898
7658263bfbc9485ebbc85b7d4c2476ea68611e26
8217a2f26c94234a1ea99d1b9b815e4da577dcfe
2023-02-05T18:33:50Z
python
2023-02-05T23:21:56Z