issue_owner_repo
listlengths
2
2
issue_body
stringlengths
0
261k
โŒ€
issue_title
stringlengths
1
925
issue_comments_url
stringlengths
56
81
issue_comments_count
int64
0
2.5k
issue_created_at
stringlengths
20
20
issue_updated_at
stringlengths
20
20
issue_html_url
stringlengths
37
62
issue_github_id
int64
387k
2.46B
issue_number
int64
1
127k
[ "hwchase17", "langchain" ]
### System Info [email protected] I upgrade my langchain lib by execute pip install -U langchain, and the verion is 0.0.192ใ€‚But i found that openai.api_base not working. I use azure openai service as openai backend, the openai.api_base is very import for me. I hava compared tag/0.0.192 and tag/0.0.191, and figure out that: ![image](https://github.com/hwchase17/langchain/assets/6478745/cfa96128-da8a-4339-a92c-5e9031953763) openai params is moved inside _invocation_params function๏ผŒand used in some openai invoke: ![image](https://github.com/hwchase17/langchain/assets/6478745/e81e41e2-0ac0-4658-9d0d-57d2b347e026) ![image](https://github.com/hwchase17/langchain/assets/6478745/b5f4b9f5-5535-4026-9817-b1046751907a) but still some case not covered like: ![image](https://github.com/hwchase17/langchain/assets/6478745/2c907b5d-81f7-4bf2-9e46-8ab409f99e60) ### Who can help? @hwchase17 i have debug langchain and make a pr, plz review the pr:https://github.com/hwchase17/langchain/pull/5821, thanks ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [X] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction 1. pip install -U langchain 2. exeucte code next: ```python from langchain.embeddings import OpenAIEmbeddings def main(): embeddings = OpenAIEmbeddings( openai_api_key="OPENAI_API_KEY", openai_api_base="OPENAI_API_BASE", ) text = "This is a test document." query_result = embeddings.embed_query(text) print(query_result) if __name__ == "__main__": main() ``` ### Expected behavior same effect as [email protected]๏ผŒ
skip openai params when embedding
https://api.github.com/repos/langchain-ai/langchain/issues/5822/comments
0
2023-06-07T08:36:23Z
2023-06-07T14:32:59Z
https://github.com/langchain-ai/langchain/issues/5822
1,745,358,828
5,822
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. I have encountered the following error: `RateLimitError: The server had an error while processing your request. Sorry about that!` This is the call stack: ```--------------------------------------------------------------------------- RateLimitError Traceback (most recent call last) [<ipython-input-28-74b7a6f0668a>](https://localhost:8080/#) in <cell line: 55>() 54 55 for sku, docs in documents.items(): ---> 56 summaries[sku] = summary_chain(docs) 24 frames [/usr/local/lib/python3.10/dist-packages/langchain/chains/base.py](https://localhost:8080/#) in __call__(self, inputs, return_only_outputs, callbacks, include_run_info) 143 except (KeyboardInterrupt, Exception) as e: 144 run_manager.on_chain_error(e) --> 145 raise e 146 run_manager.on_chain_end(outputs) 147 final_outputs: Dict[str, Any] = self.prep_outputs( [/usr/local/lib/python3.10/dist-packages/langchain/chains/base.py](https://localhost:8080/#) in __call__(self, inputs, return_only_outputs, callbacks, include_run_info) 137 try: 138 outputs = ( --> 139 self._call(inputs, run_manager=run_manager) 140 if new_arg_supported 141 else self._call(inputs) [/usr/local/lib/python3.10/dist-packages/langchain/chains/combine_documents/base.py](https://localhost:8080/#) in _call(self, inputs, run_manager) 82 # Other keys are assumed to be needed for LLM prediction 83 other_keys = {k: v for k, v in inputs.items() if k != self.input_key} ---> 84 output, extra_return_dict = self.combine_docs( 85 docs, callbacks=_run_manager.get_child(), **other_keys 86 ) [/usr/local/lib/python3.10/dist-packages/langchain/chains/combine_documents/map_reduce.py](https://localhost:8080/#) in combine_docs(self, docs, token_max, callbacks, **kwargs) 142 This reducing can be done recursively if needed (if there are many documents). 143 """ --> 144 results = self.llm_chain.apply( 145 # FYI - this is parallelized and so it is fast. 146 [{self.document_variable_name: d.page_content, **kwargs} for d in docs], [/usr/local/lib/python3.10/dist-packages/langchain/chains/llm.py](https://localhost:8080/#) in apply(self, input_list, callbacks) 155 except (KeyboardInterrupt, Exception) as e: 156 run_manager.on_chain_error(e) --> 157 raise e 158 outputs = self.create_outputs(response) 159 run_manager.on_chain_end({"outputs": outputs}) [/usr/local/lib/python3.10/dist-packages/langchain/chains/llm.py](https://localhost:8080/#) in apply(self, input_list, callbacks) 152 ) 153 try: --> 154 response = self.generate(input_list, run_manager=run_manager) 155 except (KeyboardInterrupt, Exception) as e: 156 run_manager.on_chain_error(e) [/usr/local/lib/python3.10/dist-packages/langchain/chains/llm.py](https://localhost:8080/#) in generate(self, input_list, run_manager) 77 """Generate LLM result from inputs.""" 78 prompts, stop = self.prep_prompts(input_list, run_manager=run_manager) ---> 79 return self.llm.generate_prompt( 80 prompts, stop, callbacks=run_manager.get_child() if run_manager else None 81 ) [/usr/local/lib/python3.10/dist-packages/langchain/llms/base.py](https://localhost:8080/#) in generate_prompt(self, prompts, stop, callbacks) 133 ) -> LLMResult: 134 prompt_strings = [p.to_string() for p in prompts] --> 135 return self.generate(prompt_strings, stop=stop, callbacks=callbacks) 136 137 async def agenerate_prompt( [/usr/local/lib/python3.10/dist-packages/langchain/llms/base.py](https://localhost:8080/#) in generate(self, prompts, stop, callbacks) 190 except (KeyboardInterrupt, Exception) as e: 191 run_manager.on_llm_error(e) --> 192 raise e 193 run_manager.on_llm_end(output) 194 if run_manager: [/usr/local/lib/python3.10/dist-packages/langchain/llms/base.py](https://localhost:8080/#) in generate(self, prompts, stop, callbacks) 184 try: 185 output = ( --> 186 self._generate(prompts, stop=stop, run_manager=run_manager) 187 if new_arg_supported 188 else self._generate(prompts, stop=stop) [/usr/local/lib/python3.10/dist-packages/langchain/llms/openai.py](https://localhost:8080/#) in _generate(self, prompts, stop, run_manager) 315 choices.extend(response["choices"]) 316 else: --> 317 response = completion_with_retry(self, prompt=_prompts, **params) 318 choices.extend(response["choices"]) 319 if not self.streaming: [/usr/local/lib/python3.10/dist-packages/langchain/llms/openai.py](https://localhost:8080/#) in completion_with_retry(llm, **kwargs) 104 return llm.client.create(**kwargs) 105 --> 106 return _completion_with_retry(**kwargs) 107 108 [/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py](https://localhost:8080/#) in wrapped_f(*args, **kw) 287 @functools.wraps(f) 288 def wrapped_f(*args: t.Any, **kw: t.Any) -> t.Any: --> 289 return self(f, *args, **kw) 290 291 def retry_with(*args: t.Any, **kwargs: t.Any) -> WrappedFn: [/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py](https://localhost:8080/#) in __call__(self, fn, *args, **kwargs) 377 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs) 378 while True: --> 379 do = self.iter(retry_state=retry_state) 380 if isinstance(do, DoAttempt): 381 try: [/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py](https://localhost:8080/#) in iter(self, retry_state) 323 retry_exc = self.retry_error_cls(fut) 324 if self.reraise: --> 325 raise retry_exc.reraise() 326 raise retry_exc from fut.exception() 327 [/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py](https://localhost:8080/#) in reraise(self) 156 def reraise(self) -> t.NoReturn: 157 if self.last_attempt.failed: --> 158 raise self.last_attempt.result() 159 raise self 160 [/usr/lib/python3.10/concurrent/futures/_base.py](https://localhost:8080/#) in result(self, timeout) 449 raise CancelledError() 450 elif self._state == FINISHED: --> 451 return self.__get_result() 452 453 self._condition.wait(timeout) [/usr/lib/python3.10/concurrent/futures/_base.py](https://localhost:8080/#) in __get_result(self) 401 if self._exception: 402 try: --> 403 raise self._exception 404 finally: 405 # Break a reference cycle with the exception in self._exception [/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py](https://localhost:8080/#) in __call__(self, fn, *args, **kwargs) 380 if isinstance(do, DoAttempt): 381 try: --> 382 result = fn(*args, **kwargs) 383 except BaseException: # noqa: B902 384 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type] [/usr/local/lib/python3.10/dist-packages/langchain/llms/openai.py](https://localhost:8080/#) in _completion_with_retry(**kwargs) 102 @retry_decorator 103 def _completion_with_retry(**kwargs: Any) -> Any: --> 104 return llm.client.create(**kwargs) 105 106 return _completion_with_retry(**kwargs) [/usr/local/lib/python3.10/dist-packages/openai/api_resources/completion.py](https://localhost:8080/#) in create(cls, *args, **kwargs) 23 while True: 24 try: ---> 25 return super().create(*args, **kwargs) 26 except TryAgain as e: 27 if timeout is not None and time.time() > start + timeout: [/usr/local/lib/python3.10/dist-packages/openai/api_resources/abstract/engine_api_resource.py](https://localhost:8080/#) in create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params) 151 ) 152 --> 153 response, _, api_key = requestor.request( 154 "post", 155 url, [/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py](https://localhost:8080/#) in request(self, method, url, params, headers, files, stream, request_id, request_timeout) 296 request_timeout=request_timeout, 297 ) --> 298 resp, got_stream = self._interpret_response(result, stream) 299 return resp, got_stream, self.api_key 300 [/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py](https://localhost:8080/#) in _interpret_response(self, result, stream) 698 else: 699 return ( --> 700 self._interpret_response_line( 701 result.content.decode("utf-8"), 702 result.status_code, [/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py](https://localhost:8080/#) in _interpret_response_line(self, rbody, rcode, rheaders, stream) 761 stream_error = stream and "error" in resp.data 762 if stream_error or not 200 <= rcode < 300: --> 763 raise self.handle_error_response( 764 rbody, rcode, resp.data, rheaders, stream_error=stream_error 765 ) ``` ### Suggestion: LangChain should handle `RateLimitError` in any case.
Issue: RateLimitError: The server had an error while processing your request. Sorry about that!
https://api.github.com/repos/langchain-ai/langchain/issues/5820/comments
8
2023-06-07T07:51:10Z
2023-12-18T23:50:03Z
https://github.com/langchain-ai/langchain/issues/5820
1,745,282,711
5,820
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. so I am successfully use CPU version of LLama, However, when I want to use cuBLAS to accelerate, BLAS = 0 in model properties. My process is as following: 1. Since I am using HPC, I firstly load CUDA tookit by `module load`. 2. Set environment variable LLAMA_CUBLAS=1 3. Reinstall llama-cpp by `CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 pip install --upgrade --force-reinstall llama-cpp-python` 4. Run as what the documentation said. Here is what I got: ![image](https://github.com/hwchase17/langchain/assets/49300332/7a1c07a0-39f5-4603-ac0c-ec9215354126) ### Suggestion: _No response_
Issue: cannot using cuBLAS to accelerate
https://api.github.com/repos/langchain-ai/langchain/issues/5819/comments
1
2023-06-07T07:40:36Z
2023-09-13T16:06:37Z
https://github.com/langchain-ai/langchain/issues/5819
1,745,264,416
5,819
[ "hwchase17", "langchain" ]
### System Info python: 3.9 langchain: 0.0.190 MacOS 13.2.1 (22D68) ### Who can help? @hwchase17 ### Information I use **CombinedMemory** which contains **VectorStoreRetrieverMemory** and **ConversationBufferMemory** in my app. It seems that ConversationBufferMemory is easy to clear, but when I use this CombinedMemory in a chain, it will automatically store the context to the vector database, and I can't clear its chat_history unless I create a new database, but that's very time-consuming. I initially tried various methods to clear the memory, including clearing the CombinedMemory and clearing them separately. But I looked at the clear method in VectorStoreRetrieverMemory, and it didn't do anything. ![image](https://github.com/hwchase17/langchain/assets/134575521/da3cdad1-e888-45e3-ae43-ff40e0bb0290) It is worth noting that I am using this vectordatabase in order to be able to retrieve a certain code repository. If there are other alternative methods that can successfully clear session history without affecting the vector database, then that would be even better! - [ ] 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 - [X] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction 1. insert 2 files to the vector database 2. ask a question related to them(get the right answer) 3. delete the file and update the database 4. ask the same question 5. Technically speaking, it cannot provide the correct answer, but now it can infer based on chat history. ### Expected behavior I would like to add that the reason why I don't think the problem lies in updating the database is because when I skip the second step and only add files, delete files, update the database and then ask questions, it behaves as expected and does not give me the correct answer.
how to clear VectorStoreRetrieverMemory?
https://api.github.com/repos/langchain-ai/langchain/issues/5817/comments
1
2023-06-07T07:20:29Z
2023-06-08T02:57:48Z
https://github.com/langchain-ai/langchain/issues/5817
1,745,229,585
5,817
[ "hwchase17", "langchain" ]
https://github.com/hwchase17/langchain/blob/b3ae6bcd3f42ec85ee65eb29c922ab22a17a0210/langchain/embeddings/openai.py#L100 I was profoundly misled by it when using it, the parameters used in the use case depicted in the example have been renamed to openai_api_base, which seems to be an exact bug, the correct example: ``` import os os.environ["OPENAI_API_TYPE"] = "azure" os.environ["OPENAI_API_BASE"] = "https://<your-endpoint.openai.azure.com/" os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key" os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview" os.environ["OPENAI_PROXY"] = "http://your-corporate-proxy:8080" from langchain.embeddings.openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings( deployment="your-embeddings-deployment-name", model="your-embeddings-model-name", openai_api_base="https://your-endpoint.openai.azure.com/", openai_api_type="azure", ) text = "This is a test query." query_result = embeddings.embed_query(text) ```
Issue: OpenAIEmbeddings class about Azure Openai usage example error
https://api.github.com/repos/langchain-ai/langchain/issues/5816/comments
3
2023-06-07T06:52:58Z
2023-07-19T10:10:33Z
https://github.com/langchain-ai/langchain/issues/5816
1,745,171,377
5,816
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Integration tests for faiss vector store fail when run. It appears that the tests are not in sync with the module implementation. command: poetry run pytest tests/integration_tests/vectorstores/test_faiss.py Results summary: ======================================================= short test summary info ======================================================= FAILED tests/integration_tests/vectorstores/test_faiss.py::test_faiss_local_save_load - FileExistsError: [Errno 17] File exists: '/var/folders/nm/q080zph50yz4mcc7_vcvdcy00000gp/T/tmpt6hov952' FAILED tests/integration_tests/vectorstores/test_faiss.py::test_faiss_similarity_search_with_relevance_scores - TypeError: __init__() got an unexpected keyword argument 'normalize_score_fn' FAILED tests/integration_tests/vectorstores/test_faiss.py::test_faiss_invalid_normalize_fn - TypeError: __init__() got an unexpected keyword argument 'normalize_score_fn' FAILED tests/integration_tests/vectorstores/test_faiss.py::test_missing_normalize_score_fn - Failed: DID NOT RAISE <class 'ValueError'> =============================================== 4 failed, 6 passed, 2 warnings in 0.70s =============================================== ### Suggestion: Correct tests/integration_tests/vectorstores/test_faiss.py to be in sync with langchain.vectorstores.faiss
Issue: Integration tests fail for faiss vector store
https://api.github.com/repos/langchain-ai/langchain/issues/5807/comments
0
2023-06-07T03:49:08Z
2023-06-19T00:25:50Z
https://github.com/langchain-ai/langchain/issues/5807
1,744,977,363
5,807
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. `json_spec_list_keys` works with not exists list index `[0]` and no error occurs. Here is a a simple example. ```python # [test.json] # # { # "name": "Andrew Lee", # "assets": {"cash": 10000, "stock": 5000} # } json_spec = JsonSpec.from_file(pathlib.Path("test.json")) print(json_spec.keys('data["assets"]')) # => ['cash', 'stock'] print(json_spec.value('data["assets"]')) # => {'cash': 10000, 'stock': 5000} print(json_spec.keys('data["assets"][0]')) # => ['cash', 'stock'] print(json_spec.value('data["assets"][0]')) # => KeyError(0) print(json_spec.keys('data["assets"][1]')) # => KeyError(1) print(json_spec.value('data["assets"][1]')) # => KeyError(1) ``` `json_spec_list_keys` does not error on non existing [0], but `json_spec_get_value` errors at [0]. This makes the LLM confuse like below and endless error happens. ``` Action: json_spec_list_keys Action Input: data Observation: ['name', 'assets'] Thought: I should look at the keys under each value to see if there is a total key Action: json_spec_list_keys Action Input: data["assets"][0] Observation: ['cash', 'stock'] Thought: I should look at the values of the keys to see if they contain what I am looking for Action: json_spec_get_value Action Input: data["assets"][0] Observation: KeyError(0) Thought: I should look at the next value Action: json_spec_list_keys Action Input: data["assets"][1] Observation: KeyError(1) ... ``` ### Suggestion: `json_spec_list_keys` should raise key-error exception when accessing a non-existent index [0] like `json_spec_get_value` does. ### Who can help? @vowelparrot
Issue: JSON agent tool "json_spec_list_keys" does not error when access non existing list
https://api.github.com/repos/langchain-ai/langchain/issues/5803/comments
1
2023-06-07T01:54:03Z
2023-09-13T16:06:41Z
https://github.com/langchain-ai/langchain/issues/5803
1,744,890,796
5,803
[ "hwchase17", "langchain" ]
### Feature request Hi! It's possible to integrate the langchain library with a SQL database, enabling the execution of SQL queries with spatial analysis capabilities? Specifically, I'd like to leverage GIS functions to perform spatial operations such as distance calculations, point-in-polygon queries, and other spatial analysis tasks. If the langchain library supports such functionality, it would greatly enhance the capabilities of our project by enabling us to process and analyze spatial data directly within our SQL database. I appreciate any guidance or information you can provide on this topic. ### Motivation By leveraging GIS functions within the langchain library, we can unlock the power of spatial analysis directly within our SQL database combined with LLM. This integration creates a multitude of possibilities for executing intricate spatial operations, including proximity analysis, overlay analysis, and spatial clustering via user prompts. ### Your contribution - I can provide insights into the best practices, optimal approaches, and efficient query design for performing various spatial operations within the SQL database. - I can offer troubleshooting assistance and support to address any issues or challenges that may arise during the integration of the langchain library. I can provide guidance on resolving errors, improving performance, and ensuring the accuracy of spatial analysis results.
Utilizing langchain library for SQL database querying with GIS functionality
https://api.github.com/repos/langchain-ai/langchain/issues/5799/comments
20
2023-06-07T00:00:19Z
2024-03-13T23:36:27Z
https://github.com/langchain-ai/langchain/issues/5799
1,744,793,878
5,799
[ "hwchase17", "langchain" ]
### System Info Hello, I am getting an error in import Here are my import statements: from llama_index import SimpleDirectoryReader, GPTListIndex, readers, GPTSimpleVectorIndex, LLMPredictor, PromptHelper from langchain import OpenAI import sys import os from IPython.display import Markdown, display Here is the error: from langchain.schema import BaseLanguageModel ImportError: cannot import name 'BaseLanguageModel' from 'langchain.schema' (C:\Users\ali\PycharmProjects\GeoAnalyticsFeatures\venv\lib\site-packages\langchain\schema.py) What I have tried: upgrade PIP upgrade lama ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Hello, I am getting an error in import Here are my import statements: from llama_index import SimpleDirectoryReader, GPTListIndex, readers, GPTSimpleVectorIndex, LLMPredictor, PromptHelper from langchain import OpenAI import sys import os from IPython.display import Markdown, display Here is the error: from langchain.schema import BaseLanguageModel ImportError: cannot import name 'BaseLanguageModel' from 'langchain.schema' (C:\Users\ali\PycharmProjects\GeoAnalyticsFeatures\venv\lib\site-packages\langchain\schema.py) What I have tried: upgrade PIP upgrade lama ### Expected behavior Hello, I have followed all the instructions in the comments above but still coming the same issue: Here are my import statements: from llama_index import SimpleDirectoryReader, GPTListIndex, readers, GPTSimpleVectorIndex, LLMPredictor, PromptHelper from langchain import OpenAI import sys import os from IPython.display import Markdown, display Here is the error: from langchain.schema import BaseLanguageModel ImportError: cannot import name 'BaseLanguageModel' from 'langchain.schema' (C:\Users\ali\PycharmProjects\GeoAnalyticsFeatures\venv\lib\site-packages\langchain\schema.py) What I have tried: upgrade PIP upgrade lama
Getting Import Error Basemodel
https://api.github.com/repos/langchain-ai/langchain/issues/5795/comments
5
2023-06-06T20:07:52Z
2023-09-18T16:09:09Z
https://github.com/langchain-ai/langchain/issues/5795
1,744,520,207
5,795
[ "hwchase17", "langchain" ]
### Feature request The goal of this issue is to enable the use of Unstructured loaders in conjunction with the Google drive loader. ### Motivation This would enable the use of the GoogleDriveLoader with document types other than the standard Google Drive documents/spreadsheets/presentations. ### Your contribution I can create a PR for this issue as soon as I have bandwidth. If another community member picks this up first, I'd be happy to review.
Enable the use of Unstructured loaders with Google drive loader
https://api.github.com/repos/langchain-ai/langchain/issues/5791/comments
3
2023-06-06T17:42:09Z
2023-11-06T14:57:07Z
https://github.com/langchain-ai/langchain/issues/5791
1,744,309,218
5,791
[ "hwchase17", "langchain" ]
### Feature request Now when the `HumanInputRun` is run, it goes through three steps in order: 1. print out the query that is to be clarified to console 2. call input function to get user input 3. return the user input to the downstream Hopefully the query in 1st step can be exported as a string **variable** like the LLM response. The flow like this: Without tool: ``` user_input <- user input response <- llm.run(user_input) ``` With tool: ``` user_input <- user input response <- humantool(user_input) additional_info <- user input response <- llm.run(additional_info) ``` ### Motivation Because the HumanInputRun tool only prints the query to the console, looks like it can only be used with a console. It would be more flexible if the query can be exported as a variable and pass it to the user, then the user inputs the additional info as step 2 does. ### Your contribution Currently, I still don't have a solution to it. Any suggestions?
Not only print HumanInputRun tool query to console, but also export query as a string variable
https://api.github.com/repos/langchain-ai/langchain/issues/5788/comments
1
2023-06-06T15:04:18Z
2023-09-12T16:09:48Z
https://github.com/langchain-ai/langchain/issues/5788
1,744,062,702
5,788
[ "hwchase17", "langchain" ]
### Feature request I would like a way to capture observations in the same way you can capture new llm tokens using the callback's on_llm_new_token. ### Motivation I've written a basic self-improving agent. I get it to "self-improve" by feeding the entire previous chain output to a meta agent that then refines the base agent's prompt. I accomplish this by appending all the tokens using the callback on_llm_new_token. However I realized it is not capturing observations as they are not llm generated tokens. How can I capture the observation as well? ### Your contribution I've written an article detailing the process I've created for the self-improving agent along with the code [here](https://medium.com/p/d31204e1c375). Once I figure out how to also capture the agent observations I will add the solution to the documentation under a header such as "Agent observability - capture the entire agent chain"
Capture agent observations for further processing
https://api.github.com/repos/langchain-ai/langchain/issues/5787/comments
3
2023-06-06T15:01:23Z
2023-08-05T08:12:41Z
https://github.com/langchain-ai/langchain/issues/5787
1,744,057,044
5,787
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. For the code of class`MapReduceDocumentsChain`, there is a comment in `combine_docs` saying that """Combine documents in a map reduce manner. Combine by mapping first chain over all documents, then reducing the results. This reducing can be done recursively if needed (if there are many documents). """ My questioin is how to build the recursively manner? I didn't see any specific API that allow me to implement it? Do I need to build this functionality by myself? Suppose I have a book-length document to summarize. ### Suggestion: _No response_
Issue: How to do the recursivley summarization with the summarize_chain?
https://api.github.com/repos/langchain-ai/langchain/issues/5785/comments
2
2023-06-06T14:45:51Z
2023-10-12T16:09:08Z
https://github.com/langchain-ai/langchain/issues/5785
1,744,027,285
5,785
[ "hwchase17", "langchain" ]
### Feature request Regarding issue #4999, the `code-davinci-002` model has been deprecated, so we can no longer use it with langchain.llm.OpenAI. Additionally, OpenAI also released the API called [edit models](https://platform.openai.com/docs/api-reference/edits), which includes `text-davinc-edit-001` and `code-davinci-edit-001`. I'm curious to know if there are any plans to integrate these edit models into the existing LLMs and Chat Models. If this integration has already been implemented, kindly let me know, as I might have missed the update. ### Motivation This feature allows for convenient utilization of OpenAI's edit models, such as `text-davinc-edit-001` and `code-davinci-edit-001`. ### Your contribution If this feature is valuable and requires implementation, I'm willing to assist or collaborate with the community in its implementation. However, please note that I may not have the ability to implement it independently.
[Feature] Implementation of OpenAI's Edit Models
https://api.github.com/repos/langchain-ai/langchain/issues/5779/comments
1
2023-06-06T12:07:22Z
2023-09-12T16:09:53Z
https://github.com/langchain-ai/langchain/issues/5779
1,743,725,820
5,779
[ "hwchase17", "langchain" ]
### System Info Langchain 0.0.184 Python 3.11.3 Mac OS Ventura 13.3.1 ### Who can help? @hwchase17 @agola11 I was reading [this](https://python.langchain.com/en/latest/modules/chains/index_examples/chat_vector_db.html?highlight=conversationalretriever) and changed one part of the code to `return_messages=False` when instantiating ConversationBufferMemory. We have two lines of code below that ask a question. The first line is `qa({'question': "what is a?"})`. From the error below it seems that messages should be a list. If this is the case, shouldn't it be documented, and perhaps the default keyword argument for `return_messages` should be `True` instead of `False` in `ConversationBufferMemory`, `ConversationBufferWindowMemory` and any other relevant memory intended to be used in `Conversation`. This also would've been circumvented entirely if the docstring for these memory classes contained helpful information about the parameters and what to expect. I also suppose a good solve for this would be to just change the default kwargs for all conversation memory to `memory_key="chat_history"` and `return_messages=True`. ```python import langchain langchain.__version__ ``` '0.0.184' ```python from langchain.vectorstores import FAISS from langchain.embeddings import OpenAIEmbeddings from langchain.llms import OpenAI from langchain.chains import ConversationalRetrievalChain from langchain.memory import ConversationBufferMemory chars = ['a', 'b', 'c', 'd', '1', '2', '3'] texts = [4*c for c in chars] metadatas = [{'title': c, 'source': f'source_{c}'} for c in chars] vs = FAISS.from_texts(texts, embedding=OpenAIEmbeddings(), metadatas=metadatas) retriever = vs.as_retriever(search_kwargs=dict(k=5)) memory = ConversationBufferMemory(memory_key='chat_history', return_messages=False) qa = ConversationalRetrievalChain.from_llm(OpenAI(), retriever, memory=memory) print(qa({'question': "what is a?"})) print(qa({'question': "what is b?"})) ``` {'question': 'what is a?', 'chat_history': '', 'answer': ' a is aaaaa.'} --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[2], line 17 15 qa = ConversationalRetrievalChain.from_llm(OpenAI(), retriever, memory=memory) 16 print(qa({'question': "what is a?"})) ---> 17 print(qa({'question': "what is b?"})) File ~/code/langchain/langchain/chains/base.py:140, in Chain.__call__(self, inputs, return_only_outputs, callbacks) 138 except (KeyboardInterrupt, Exception) as e: 139 run_manager.on_chain_error(e) --> 140 raise e 141 run_manager.on_chain_end(outputs) 142 return self.prep_outputs(inputs, outputs, return_only_outputs) File ~/code/langchain/langchain/chains/base.py:134, in Chain.__call__(self, inputs, return_only_outputs, callbacks) 128 run_manager = callback_manager.on_chain_start( 129 {"name": self.__class__.__name__}, 130 inputs, 131 ) 132 try: 133 outputs = ( --> 134 self._call(inputs, run_manager=run_manager) 135 if new_arg_supported 136 else self._call(inputs) 137 ) 138 except (KeyboardInterrupt, Exception) as e: 139 run_manager.on_chain_error(e) File ~/code/langchain/langchain/chains/conversational_retrieval/base.py:100, in BaseConversationalRetrievalChain._call(self, inputs, run_manager) 98 question = inputs["question"] 99 get_chat_history = self.get_chat_history or _get_chat_history --> 100 chat_history_str = get_chat_history(inputs["chat_history"]) 102 if chat_history_str: 103 callbacks = _run_manager.get_child() File ~/code/langchain/langchain/chains/conversational_retrieval/base.py:45, in _get_chat_history(chat_history) 43 buffer += "\n" + "\n".join([human, ai]) 44 else: ---> 45 raise ValueError( 46 f"Unsupported chat history format: {type(dialogue_turn)}." 47 f" Full chat history: {chat_history} " 48 ) 49 return buffer ValueError: Unsupported chat history format: <class 'str'>. Full chat history: Human: what is a? AI: a is aaaaa. ### 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 - [X] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ```python from langchain.vectorstores import FAISS from langchain.embeddings import OpenAIEmbeddings from langchain.llms import OpenAI from langchain.chains import ConversationalRetrievalChain from langchain.memory import ConversationBufferMemory chars = ['a', 'b', 'c', 'd', '1', '2', '3'] texts = [4*c for c in chars] metadatas = [{'title': c, 'source': f'source_{c}'} for c in chars] vs = FAISS.from_texts(texts, embedding=OpenAIEmbeddings(), metadatas=metadatas) retriever = vs.as_retriever(search_kwargs=dict(k=5)) memory = ConversationBufferMemory(memory_key='chat_history', return_messages=False) qa = ConversationalRetrievalChain.from_llm(OpenAI(), retriever, memory=memory) print(qa({'question': "what is a?"})) print(qa({'question': "what is b?"})) ``` ### Expected behavior In this code I would've expected it to be error free, but it has an error when executing the second call of the `qa` object asking `"what is b?"`.
ConversationalRetrievalChain is not robust to default conversation memory configurations.
https://api.github.com/repos/langchain-ai/langchain/issues/5775/comments
6
2023-06-06T07:42:49Z
2023-09-20T16:08:51Z
https://github.com/langchain-ai/langchain/issues/5775
1,743,279,348
5,775
[ "hwchase17", "langchain" ]
### Feature request Maybe I didn't get the idea: Some tools can be loaded like 'google-search' other tools can't be loaded like duckduckgo-search by the load_tools: langchain/agents/load_tools.py E.g. specified in _EXTRA_OPTIONAL_TOOLS. As for custom tools they can't be loaded at all it seems in that way. It would be great to register custom tools so that they can be loaded by load_tools as well. I've done something like this for the moment, so I have Class-Names for my own tools and the lower-case would be standard: ``` standard_tools = [] for toolStr in tool_names: if toolStr[0].islower(): standard_tools.append(toolStr) self.tools = load_tools(standard_tools, **tool_kwargs) for toolStr in tool_names: if toolStr[0].isupper(): toolClass = globals()[toolStr] toolObject = toolClass() self.tools.append(copy.deepcopy(toolObject)) ``` ### Motivation When assigning agents a set of tools it's very handy to do it through a list. ### Your contribution I'm not familiar enough with the architecture of langchain so I'd better not. But I'm happy to test it.
Dynamic loading of tools and custom tools
https://api.github.com/repos/langchain-ai/langchain/issues/5774/comments
2
2023-06-06T05:57:15Z
2023-09-19T18:34:06Z
https://github.com/langchain-ai/langchain/issues/5774
1,743,139,375
5,774
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. when i read your code ๏ผŒi had something donโ€˜t understand๏ผŒhttps://github.com/hwchase17/langchain/blob/master/langchain/agents/loading.py#L80๏ผŒ in here ":=" is not a python syntax๏ผŒhow could it run in python(when i run langchain,it run well !) ### Suggestion: _No response_
Issue: Source code issues
https://api.github.com/repos/langchain-ai/langchain/issues/5773/comments
0
2023-06-06T05:49:53Z
2023-06-06T06:04:21Z
https://github.com/langchain-ai/langchain/issues/5773
1,743,131,616
5,773
[ "hwchase17", "langchain" ]
### Feature request Vux.design - How can I be part of this project? ### Motivation Vux.design - How can I be part of this project? ### Your contribution Vux.design - How can I be part of this project?
I am a professional UX & UI designer and I want to contribute to this project.
https://api.github.com/repos/langchain-ai/langchain/issues/5771/comments
2
2023-06-06T05:10:07Z
2023-09-13T16:06:53Z
https://github.com/langchain-ai/langchain/issues/5771
1,743,094,118
5,771
[ "hwchase17", "langchain" ]
### System Info Langchain version 0.0.191 , python version 3.9.15 ### Who can help? @agola ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [X] Callbacks/Tracing - [ ] Async ### Reproduction following the notebook given at https://python.langchain.com/en/latest/integrations/mlflow_tracking.html?highlight=mlflow I just changed the chain from LLM chain to retrieval chain and OpenAI to Azure Open AI i continuously faced the error KeyError: "None of [Index(['step', 'prompt', 'name'], dtype='object')] are in the [columns]" But some data is getting logged into ML_flow experiments. like chain_1_start and chain_2_start and their ends respectively. ### Expected behavior To have the necessary data in the ML flow experiment logs and should work without throwing any error.
ML flow call backs fails at missing keys
https://api.github.com/repos/langchain-ai/langchain/issues/5770/comments
3
2023-06-06T04:53:33Z
2023-10-09T16:07:22Z
https://github.com/langchain-ai/langchain/issues/5770
1,743,078,641
5,770
[ "hwchase17", "langchain" ]
### Feature request I would like to propose the addition of an **observability feature** to LangChain, enabling developers to monitor and analyze their applications more effectively. This feature aims to provide metrics, data tracking, and graph visualization capabilities to enhance observability. Key aspects of the proposed feature include: - **Metrics Tracking**: Capture time taken by LLM model to handle request, errors, number of tokens, and costing indication for the particular LLM. - **Data Tracking**: Log and store prompt, request, and response data for each LangChain interaction. - **Graph Visualization**: Generate basic graphs over time, depicting metrics such as request duration, error occurrences, token count, and cost. This feature request aims to improve the development and debugging experience by providing developers with better insights into the performance, behavior, and cost implications of their LangChain applications. ### Motivation Last week, while I was creating an application using OpenAI's GPT 3.5 APIs to develop a chat-based solution for answering SEO-related queries, I encountered a significant challenge. During the launch, I realized that I had no means to monitor the responses suggested by the language model (GPT, in my case). Additionally, I had no insights into its performance, such as speed or token usage. To check the token count, I had to repeatedly log in to the OpenAI dashboard, which was time-consuming and cumbersome. It was frustrating not having a clear picture of user interactions and the effectiveness of the system's responses. I realised that I needed a way to understand the system's performance in handling different types of queries and identify areas that required improvement. I strongly believe that incorporating an observability feature in LangChain would be immensely valuable. It would empower developers like me to track user interactions, analyze the quality of responses, and measure the performance of the underlying LLM requests. Having these capabilities would not only provide insights into user behavior but also enable us to continuously improve the system's accuracy, response time, and overall user experience. ### Your contribution Yes, I am planning to raise a PR along with a couple of my friends to add an observability feature to Langchain. I would be more than happy to take suggestions from the community, on what we could add to make it more usable!
Observability Feature Request: Metrics, Data Monitoring, and Graph Visualization
https://api.github.com/repos/langchain-ai/langchain/issues/5767/comments
5
2023-06-06T04:09:20Z
2023-06-25T08:41:58Z
https://github.com/langchain-ai/langchain/issues/5767
1,743,048,083
5,767
[ "hwchase17", "langchain" ]
### Discussed in https://github.com/hwchase17/langchain/discussions/5730 <div type='discussions-op-text'> <sup>Originally posted by **Radvian** June 5, 2023</sup> Hello, not sure if I should ask this in Discussion or Issue, so apologies beforehand. I'm doing a passion project in which I try to create a knowledge base for a website, and create a Conversational Retrieval QA Chain so we can ask questions about the knowledge base. This is very much akin to this: https://python.langchain.com/en/latest/modules/chains/index_examples/chat_vector_db.html And I have no problem to implement it. Now, I want to go to the next step. Instead of creating a chain, I want to create an agent. I want to do something like this: - First, always ask the user for their name. - If the user asks a particular question that is not in the knowledge base, don't reply with "I don't know", but search Wikipedia about it - If the user asks about X, send an image link (from google search images) of 'X' item - and few other custom tools And, I also don't have any problem in creating tools and combining them into a unified agent. However, my problem is this (and this is expected): the agent performs slower, much slower than if I just use the chain. If I only use Retrieval QA Chain, and enables _streaming_, it can start typing the output in less than 5 seconds. If I use the complete agent, with a few custom tools, it starts to type the answer / output within 10-20 seconds. I know this is to be expected, since the agent needs to think about which tools to use. But any ideas on how to make this faster? In the end, I want to deploy this whole project in a streamlit and wants this to perform like a 'functional' chatbot, with almost-instant reply, and not having to wait 10-20 seconds before the 'agent' starts typing. Any ideas are welcome, apologies if this is a stupid question. Thank you!</div>
Improving Custom Agent Speed?
https://api.github.com/repos/langchain-ai/langchain/issues/5763/comments
4
2023-06-06T02:44:39Z
2023-11-08T16:08:55Z
https://github.com/langchain-ai/langchain/issues/5763
1,742,972,131
5,763
[ "hwchase17", "langchain" ]
### Feature request When performing knnSearch or hybridKnnSearch return `Document` object ### Motivation Currently the return a `dict` object. It would be more useful to return [langchain.schema.Document](https://github.com/hwchase17/langchain/blob/d5b160821641df77df447e6dfce21b58fbb13d75/langchain/schema.py#LL266C10-L266C10) ### Your contribution I will make the canges
Modify ElasticKnnSearch to return Document object
https://api.github.com/repos/langchain-ai/langchain/issues/5760/comments
1
2023-06-06T01:24:07Z
2023-09-12T16:10:09Z
https://github.com/langchain-ai/langchain/issues/5760
1,742,895,996
5,760
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. The Json Agent tools (json_spec_list_keys, json_spec_get_value) fails when dict key of Action Input is surrounded by single quotes. It only accepts double quotes. Here is a simple example. ```python import pathlib from langchain.tools.json.tool import JsonSpec # [test.json] # # { # "name": "Andrew Lee", # "number": 1234 # } json_spec = JsonSpec.from_file(pathlib.Path("test.json")) print(json_spec.keys("data")) # => ['name', 'number'] print(json_spec.value('data["name"]')) # => Andrew Lee print(json_spec.value("data['name']")) # => KeyError("'name'") ``` To make matters worse, the json_spec_list_keys returns keys with **single quote** at Observation. So the LLM follow it to Action input and endless error happens like below. ``` Action: json_spec_list_keys Action Input: data Observation: ['name', 'number'] Thought: I should look at the values associated with the "name" key Action: json_spec_get_value Action Input: "data['name']" Observation: KeyError("'name'") ``` ### Suggestion: The Json Agent tools (json_spec_list_keys, json_spec_get_value) should accept both single/double quotes for dict key like general python dict access.
Issue: Json Agent tool fails when dict key is surrounded by single quotes
https://api.github.com/repos/langchain-ai/langchain/issues/5759/comments
1
2023-06-06T00:59:00Z
2023-09-12T16:10:14Z
https://github.com/langchain-ai/langchain/issues/5759
1,742,877,157
5,759
[ "hwchase17", "langchain" ]
### Issue with current documentation: Hi, how can I see what my final prompt looks like when retrieving docs? For example, I'm not quite sure how this will end up looking: ```python prompt_template = """Answer based on context:\n\n{context}\n\n{question}""" PROMPT = PromptTemplate(template=prompt_template, input_variables=["context", "question"]) qa = RetrievalQA.from_chain_type( llm=sm_llm, chain_type="stuff", retriever=docsearch.as_retriever(), chain_type_kwargs={"prompt": PROMPT}, ) result = qa.run(question) ``` ### Idea or request for content: _No response_
DOC: PrompTemplate format with docs
https://api.github.com/repos/langchain-ai/langchain/issues/5756/comments
9
2023-06-05T21:33:49Z
2023-11-07T16:26:16Z
https://github.com/langchain-ai/langchain/issues/5756
1,742,656,975
5,756
[ "hwchase17", "langchain" ]
### System Info langchain == 0.0.190 Google Colab ### 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 - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction docsearch = Pinecone.from_documents(chunks, embeddings, index_name=index_name) calls from_text which returns ValueError: No active indexes found in your Pinecone project, are you sure you're using the right API key and environment? if the index does not exist. `` if index_name in indexes: index = pinecone.Index(index_name) elif len(indexes) == 0: raise ValueError( "No active indexes found in your Pinecone project, " "are you sure you're using the right API key and environment?" ) `` ### Expected behavior The method should create the index if it does not exist. This is the expected behavior from the documentation and the official examples. Creating a new index if it does not exist is the only recommended behavior as it implies that the dimension of the index is always consistent with the dimension of the embedding model used. Thanks Best regards Jerome
Pinecone.from_documents() does not create the index if it does not exist
https://api.github.com/repos/langchain-ai/langchain/issues/5748/comments
19
2023-06-05T19:12:00Z
2024-06-15T12:40:51Z
https://github.com/langchain-ai/langchain/issues/5748
1,742,421,560
5,748
[ "hwchase17", "langchain" ]
### Issue with current documentation: I saw in a recent notebook demo that a custom `SagemakerEndpointEmbeddingsJumpStart` class was needed to deploy a SageMaker JumpStart text embedding model. I couldn't find any langchain docs for this. ```python from langchain.embeddings.sagemaker_endpoint import EmbeddingsContentHandler class SagemakerEndpointEmbeddingsJumpStart(SagemakerEndpointEmbeddings): def embed_documents(self, texts: List[str], chunk_size: int = 5) -> List[List[float]]: """Compute doc embeddings using a SageMaker Inference Endpoint. Args: texts: The list of texts to embed. chunk_size: The chunk size defines how many input texts will be grouped together as request. If None, will use the chunk size specified by the class. Returns: List of embeddings, one for each text. """ results = [] _chunk_size = len(texts) if chunk_size > len(texts) else chunk_size for i in range(0, len(texts), _chunk_size): #print(f"input:", texts[i : i + _chunk_size]) response = self._embedding_func(texts[i : i + _chunk_size]) results.extend(response) return results class ContentHandler(EmbeddingsContentHandler): content_type = "application/json" accepts = "application/json" def transform_input(self, prompt: str, model_kwargs={}) -> bytes: input_str = json.dumps({"text_inputs": prompt, **model_kwargs}) return input_str.encode("utf-8") def transform_output(self, output: bytes) -> str: response_json = json.loads(output.read().decode("utf-8")) embeddings = response_json["embedding"] return embeddings content_handler = ContentHandler() embeddings = SagemakerEndpointEmbeddingsJumpStart( endpoint_name=_MODEL_CONFIG_["huggingface-textembedding-gpt-j-6b"]["endpoint_name"], region_name=aws_region, content_handler=content_handler, ) ``` ### Idea or request for content: _No response_
DOC: SageMaker JumpStart Embeddings
https://api.github.com/repos/langchain-ai/langchain/issues/5741/comments
1
2023-06-05T15:52:39Z
2023-09-11T16:58:07Z
https://github.com/langchain-ai/langchain/issues/5741
1,742,067,857
5,741
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Getting the following error TypeError: issubclass() arg 1 must be a class when i execute: from langchain.embeddings import HuggingFaceEmbeddings #from transformers import pipeline #Download model from Hugging face model_name = "sentence-transformers/all-mpnet-base-v2" hf_embed = HuggingFaceEmbeddings(model_name=model_name) ### Suggestion: _No response_
Issue: TypeError: issubclass() arg 1 must be a class
https://api.github.com/repos/langchain-ai/langchain/issues/5740/comments
13
2023-06-05T15:24:37Z
2023-11-29T15:01:38Z
https://github.com/langchain-ai/langchain/issues/5740
1,742,023,144
5,740
[ "hwchase17", "langchain" ]
### System Info Here is the error call stack. The code is attached to this submission. I did a workaround to prevent the crash. However, this is not the correct fix. Hacked FIX def add_user_message(self, message: str) -> None: """Add a user message to the store""" print(type(message)) **if isinstance(message, list): message = message[0].content** self.add_message(HumanMessage(content=message)) ---------------------------- Call Stack Error -------------------- Exception has occurred: ValidationError (note: full exception trace is shown but execution is paused at: _run_module_as_main) 1 validation error for HumanMessage content str type expected (type=type_error.str) File "/Users/randolphhill/anaconda3/envs/version2/lib/python3.10/site-packages/pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ raise validation_error File "/Users/randolphhill/anaconda3/envs/version2/lib/python3.10/site-packages/langchain/schema.py", line 254, in add_user_message self.add_message(HumanMessage(content=message)) File "/Users/randolphhill/anaconda3/envs/version2/lib/python3.10/site-packages/langchain/memory/chat_memory.py", line 35, in save_context self.chat_memory.add_user_message(input_str) File "/Users/randolphhill/anaconda3/envs/version2/lib/python3.10/site-packages/langchain/chains/base.py", line 191, in prep_outputs self.memory.save_context(inputs, outputs) File "/Users/randolphhill/anaconda3/envs/version2/lib/python3.10/site-packages/langchain/chains/base.py", line 142, in __call__ return self.prep_outputs(inputs, outputs, return_only_outputs) File "/Users/randolphhill/gepetto/code/mpv1/version1/geppetto/maincontroller.py", line 96, in <module> eaes = agent(messages) File "/Users/randolphhill/anaconda3/envs/version2/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/Users/randolphhill/anaconda3/envs/version2/lib/python3.10/runpy.py", line 196, in _run_module_as_main (Current frame) return _run_code(code, main_globals, None, pydantic.error_wrappers.ValidationError: 1 validation error for HumanMessage content str type expected (type=type_error.str) ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [X] Agents / Agent Executors - [X] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction from langchain.chat_models import ChatOpenAI from langchain import SerpAPIWrapper #from typing import Union from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import Tool from langchain.chains.conversation.memory import ConversationBufferWindowMemory from langchain.prompts.prompt import PromptTemplate from langchain.tools import DuckDuckGoSearchRun from langchain.schema import ( SystemMessage, HumanMessage, ) #Build Prompt EXAMPLES = [ "Question: Is there a Thai restaurant in San Francisco?\nThought: I need to search for Thai restaurants in San Francisco.\nservation: Yes, there are several Thai restaurants located in San Francisco. Here are five examples: 1. Lers Ros Thai, 2. Kin Khao, 3. Farmhouse Kitchen Thai Cuisine, 4. Marnee Thai, 5. Osha Thai Restaurant.\nAction: Finished" ] SUFFIX = """\nQuestion: {input} {agent_scratchpad}""" TEST_PROMPT = PromptTemplate.from_examples( EXAMPLES, SUFFIX, ["input", "agent_scratchpad"] ) #print(TEST_PROMPT) messages = [ SystemMessage(content="You are a virtual librarian who stores search results, pdf and txt files. if a message cannot save, provide a file name based on the content of the message. File extension txt."), # AIMessage(content="I'm great thank you. How can I help you?"), HumanMessage(content="List 5 Thai resturants located in San Francisco that existed before September 2021.") ] def ingestFile(filename:str): return f"{filename}ingested file cabinate middle drawer" def saveText(msg:str): print("\nSEARCH RESULTS FILER !!!!\n",msg,"\n") try: with open("/tmp/file_name.txt", 'w') as file: file.write(msg) #print(f"Successfully written") return f"{msg}Information saved to thai.txt" except Exception as e: print(f"An error occurred: {e}") #serpapi = SerpAPIWrapper() serpapi = DuckDuckGoSearchRun() search = Tool( name="Search", func=serpapi.run, description="Use to search for current events" ) save = Tool( name="Save Text", func= saveText, description="used to save results of human request. File name will be created" ) #tool_names = ["serpapi"] #tools = load_tools(tool_names,search_filer) ingestFile = Tool( name="Ingest-Save file", func= ingestFile, description="Used to store/ingest file in virtual file cabinet" ) tools = [search,save,ingestFile] type(tools) chat = ChatOpenAI( #openai_api_key=OPENAI_API_KEY, temperature=0, #model='gpt-3.5-turbo' #prompt=TEST_PROMPT, model='gpt-4' ) memory = ConversationBufferWindowMemory( memory_key='chat_history', k=20, return_messages=True ) agent = initialize_agent(tools, chat, #iagent="zero-shot-react-description", agent='chat-conversational-react-description', max_interations=5, #output_parser=output_parser, verbose=True, max_iterations=3, early_stopping_method='generate', memory=memory) eaes = agent(messages) #res =agent(O"List 5 Thai resturants in San Franciso.") #res = agent(messages) print(res['output']) res =agent("What time is it in London") print(res['output']) res =agent("Save the last TWO LAST ANSWERS PROVIDEDi. Format answer First Answer: Second Answer:") print("RESULTS OF LAST TWO\n",res['output']) print("\n") res =agent("Ingest the file nih.pdf") print(res['output']) res=agent("your state is now set to ready to analyze data") print(res['output']) res=agent("What is your current state") print(res['output']) ### Expected behavior Not to crash and return with message saved.
add_user_message() fails. called with List instead of a string.
https://api.github.com/repos/langchain-ai/langchain/issues/5734/comments
3
2023-06-05T14:32:00Z
2023-09-13T03:54:38Z
https://github.com/langchain-ai/langchain/issues/5734
1,741,915,767
5,734
[ "hwchase17", "langchain" ]
### System Info run on docker image with continuumio/miniconda3 on linux langchain-0.0.190 installed ### Who can help? _No response_ ### Information - [x] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Follow the steps here: https://python.langchain.com/en/latest/modules/models/llms/integrations/gpt4all.html ``` %pip install gpt4all > /dev/null from langchain import PromptTemplate, LLMChain from langchain.llms import GPT4All 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/ggml-gpt4all-l13b-snoozy.bin' # replace with your desired local file path import requests from pathlib import Path from tqdm import tqdm Path(local_path).parent.mkdir(parents=True, exist_ok=True) # Example model. Check https://github.com/nomic-ai/gpt4all for the latest models. url = 'http://gpt4all.io/models/ggml-gpt4all-l13b-snoozy.bin' # send a GET request to the URL to download the file. Stream since it's large response = requests.get(url, stream=True) # open the file in binary mode and write the contents of the response to it in chunks # This is a large file, so be prepared to wait. with open(local_path, 'wb') as f: for chunk in tqdm(response.iter_content(chunk_size=8192)): if chunk: f.write(chunk) # Callbacks support token-wise streaming callbacks = [StreamingStdOutCallbackHandler()] # Verbose is required to pass to the callback manager llm = GPT4All(model=local_path, callbacks=callbacks, verbose=True) ``` ### Expected behavior The expected behavior: code returns a GPT4All object. The following error was produced: ``` AttributeError Traceback (most recent call last) Cell In[9], line 4 2 callbacks = [StreamingStdOutCallbackHandler()] 3 # Verbose is required to pass to the callback manager ----> 4 llm = GPT4All(model=local_path, callbacks=callbacks, verbose=True) File /opt/conda/lib/python3.10/site-packages/pydantic/main.py:339, in pydantic.main.BaseModel.__init__() File /opt/conda/lib/python3.10/site-packages/pydantic/main.py:1102, in pydantic.main.validate_model() File /opt/conda/lib/python3.10/site-packages/langchain/llms/gpt4all.py:156, in GPT4All.validate_environment(cls, values) 153 if values["n_threads"] is not None: 154 # set n_threads 155 values["client"].model.set_thread_count(values["n_threads"]) --> 156 values["backend"] = values["client"].model_type 158 return values AttributeError: 'GPT4All' object has no attribute 'model_type' ```
AttributeError: 'GPT4All' object has no attribute 'model_type'
https://api.github.com/repos/langchain-ai/langchain/issues/5729/comments
4
2023-06-05T13:20:31Z
2023-09-18T16:09:19Z
https://github.com/langchain-ai/langchain/issues/5729
1,741,774,247
5,729
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. I have a huge database hosted in BigQuery. The recommended approach to querying this via natural language is using agents. However, this diminishes the control I have over the intermediate steps, and that leads to many problems. - The generated query isn't correct, and this cannot be reinforced at any intermediate step - Clauses like "ORDER BY" brings _NULL_ to the top, and no amount of prompt engineering can retrieve the top non-null value Are there any workarounds for this? Or is there any other approach recommended for handling databases of this scale? ### Suggestion: _No response_
Issue: Correctness of generated SQL queries
https://api.github.com/repos/langchain-ai/langchain/issues/5726/comments
2
2023-06-05T13:04:04Z
2023-10-05T16:09:31Z
https://github.com/langchain-ai/langchain/issues/5726
1,741,740,806
5,726
[ "hwchase17", "langchain" ]
### System Info Langchain Version : [0.0.190] Python Version : 3.10.7 OS : Windows 10 ### Who can help? @eyurtsev @hwchase17 ### 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 Error: RuntimeError: Error in __cdecl faiss::FileIOReader::FileIOReader(const char *) at D:\a\faiss-wheels\faiss-wheels\faiss\faiss\impl\io.cpp:68: Error: 'f' failed: could not open **D:\Question Answer Generative AI\Langchain\index_files\ThinkPalmโ˜บ\en\index.faiss** for reading: Invalid argument Try creating a file path : D:\Question Answer Generative AI\Langchain\index_files\ThinkPalm\1\en mainly some folder name with just a number, then try to load that file path using faiss.load_local(). The path created after passing string path to Path(path) class is causing some issue. ### Expected behavior Issue: The actual file path is : D:\Question Answer Generative AI\Langchain\index_files\ThinkPalm\1\en File Path created by PurePath : *D:\Question Answer Generative AI\Langchain\index_files\ThinkPalm@\en\index.faiss
FAISS load_local() file path issue.
https://api.github.com/repos/langchain-ai/langchain/issues/5725/comments
6
2023-06-05T12:15:19Z
2023-07-23T03:01:24Z
https://github.com/langchain-ai/langchain/issues/5725
1,741,652,313
5,725
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Hello guys, I'm wondering how can I get total_tokens for each chain in sequential chain. I'm working on optimisation of sequential chains and want to check how much does each step cost. Unfortunately get_openai_callback returns total_tokens for the whole sequential chain rather then each one. ### Suggestion: _No response_
Issue: Getting total_tokens for each chain in sequential chains
https://api.github.com/repos/langchain-ai/langchain/issues/5724/comments
5
2023-06-05T10:20:30Z
2024-02-27T11:55:12Z
https://github.com/langchain-ai/langchain/issues/5724
1,741,461,098
5,724
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. I am trying to generate a chain from langchain and append it to the configuration within nemoguard rails. I am getting error message LLMChain' object has no attribute 'postprocessors I am on Langchain version 0.0.167 and nemoguardrails 0.2.0 . Nemoguard rails 0.2.0 is compatible only with the langchain version 0.0.167 and i guess postprocessor is on the latest langchain version Can you please check on this and provide a solution rails = LLMRails(llm=llm, config=rails_config) title_chain.postprocessors.append(rails) script_chain.postprocessors.append(rails) ### Suggestion: _No response_
postprocessors append - Langchain and Nemoguardrails
https://api.github.com/repos/langchain-ai/langchain/issues/5723/comments
1
2023-06-05T10:18:32Z
2023-09-11T16:58:12Z
https://github.com/langchain-ai/langchain/issues/5723
1,741,458,138
5,723
[ "hwchase17", "langchain" ]
### Issue with current documentation: I might've not noticed but I didn't see anywhere in the document instructions to install langchain from source so developers can work/test latest updates.the ### Idea or request for content: Add setup instructions from the source in the installation section in README.md.
DOC: How to install from source?
https://api.github.com/repos/langchain-ai/langchain/issues/5722/comments
3
2023-06-05T10:06:50Z
2023-11-10T16:09:02Z
https://github.com/langchain-ai/langchain/issues/5722
1,741,438,633
5,722
[ "hwchase17", "langchain" ]
### System Info Hi, this is related to #5651 but (on my machine ;) ) the issue is still there. ## Versions * Intel Mac with latest OSX * Python 3.11.2 * langchain 0.0.190, includes fix for #5651 * ggml-mpt-7b-instruct.bin, downloaded at June 5th from https://gpt4all.io/models/ggml-mpt-7b-instruct.bin ### Who can help? @pakcheera @bwv988 First of all: thanks for the report and the fix :). Did this issues disappear on you machines? ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ## Error message ```shell โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚ /Users/christoph/src/sandstorm-labs/development-tools/ai-support-chat/gpt4all/chat.py:30 in โ”‚ โ”‚ <module> โ”‚ โ”‚ โ”‚ โ”‚ 27 โ”‚ model_name="all-mpnet-base-v2") โ”‚ โ”‚ 28 โ”‚ โ”‚ 29 # see https://gpt4all.io/models/ggml-mpt-7b-instruct.bin โ”‚ โ”‚ โฑ 30 llm = GPT4All( โ”‚ โ”‚ 31 โ”‚ model="./ggml-mpt-7b-instruct.bin", โ”‚ โ”‚ 32 โ”‚ #backend='gptj', โ”‚ โ”‚ 33 โ”‚ top_p=0.5, โ”‚ โ”‚ โ”‚ โ”‚ in pydantic.main.BaseModel.__init__:339 โ”‚ โ”‚ โ”‚ โ”‚ in pydantic.main.validate_model:1102 โ”‚ โ”‚ โ”‚ โ”‚ /Users/christoph/src/sandstorm-labs/development-tools/ai-support-chat/gpt4all/venv/lib/python3.1 โ”‚ โ”‚ 1/site-packages/langchain/llms/gpt4all.py:156 in validate_environment โ”‚ โ”‚ โ”‚ โ”‚ 153 โ”‚ โ”‚ if values["n_threads"] is not None: โ”‚ โ”‚ 154 โ”‚ โ”‚ โ”‚ # set n_threads โ”‚ โ”‚ 155 โ”‚ โ”‚ โ”‚ values["client"].model.set_thread_count(values["n_threads"]) โ”‚ โ”‚ โฑ 156 โ”‚ โ”‚ values["backend"] = values["client"].model_type โ”‚ โ”‚ 157 โ”‚ โ”‚ โ”‚ โ”‚ 158 โ”‚ โ”‚ return values โ”‚ โ”‚ 159 โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ ``` As you can see in _gpt4all.py:156_ contains the changed from the fix of #5651 ## Code ```python from langchain.llms import GPT4All # see https://gpt4all.io/models/ggml-mpt-7b-instruct.bin llm = GPT4All( model="./ggml-mpt-7b-instruct.bin", #backend='gptj', top_p=0.5, top_k=0, temp=0.1, repeat_penalty=0.8, n_threads=12, n_batch=16, n_ctx=2048) ``` FYI I am following [this example in a blog post](https://dev.to/akshayballal/beyond-openai-harnessing-open-source-models-to-create-your-personalized-ai-companion-1npb). ### Expected behavior I expect an instance of _GPT4All_ instead of a stacktrace.
AttributeError: 'GPT4All' object has no attribute 'model_type' (langchain 0.0.190)
https://api.github.com/repos/langchain-ai/langchain/issues/5720/comments
7
2023-06-05T09:44:08Z
2023-06-06T07:30:11Z
https://github.com/langchain-ai/langchain/issues/5720
1,741,397,634
5,720
[ "hwchase17", "langchain" ]
### System Info LangChain version: `0.0.189` OS: Ubuntu `22.04.2` Python version: `3.10.7` ### 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 - [X] Agents / Agent Executors - [X] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Reproducing this issue can be challenging as it hinges on the action input generated by the LLM. Nevertheless, the issue occurs when using an agent of type `CONVERSATIONAL_REACT_DESCRIPTION`. The agent's output parser attempts to [extract](https://github.com/hwchase17/langchain/blob/d0d89d39efb5f292f72e70973f3b70c4ca095047/langchain/agents/conversational/output_parser.py#L21) both the tool's name that the agent needs to utilize for its task and the input to that tool based on the LLM prediction. In order to accomplish this, the agent's output parser employs the following regular expression on the LLM prediction: `Action: (.*?)[\n]*Action Input: (.*)`. This expression divides the LLM prediction into two components: i) the tool that needs to be utilized (Action) and ii) the tool's input (Action Input). However, the action input generated by an LLM is an arbitrary string. Hence, if the action input initiates with a newline character, the regular expression's search operation fails to find a match, resulting in the action input defaulting to an empty string. This issue stems from the fact that the `.` character in the regular expression doesn't match newline characters by default. Consequently, `(.*)` stops at the end of the line it started on. This behavior aligns with the default functionality of the Python `re` library. To rectify this corner case, we must include the [`re.S`](https://docs.python.org/3/library/re.html#:~:text=in%20version%203.11.-,re.S,-%C2%B6) flag in the `re.search()` method. This will allow the `.` special character to match any character, including a newline. > re.S > re.DOTALL > Make the '.' special character match any character at all, including a newline; without this flag, '.' will match anything except a newline. Corresponds to the inline flag (?s). ### Expected behavior The `re.search()` method correctly matches the action input section of the LLM prediction and sets it to the relevant string, even if it starts with the new line character. I am prepared to open a new Pull Request (PR) to address this issue. The change involves modifying the following [line](https://github.com/hwchase17/langchain/blob/d0d89d39efb5f292f72e70973f3b70c4ca095047/langchain/agents/conversational/output_parser.py#L21): From: ```python match = re.search(regex, text) ``` To: ```python match = re.search(regex, text, re.S) ```
Regular Expression Fails to Match Newline-Starting Action Inputs
https://api.github.com/repos/langchain-ai/langchain/issues/5717/comments
2
2023-06-05T08:59:46Z
2023-11-01T16:06:55Z
https://github.com/langchain-ai/langchain/issues/5717
1,741,315,782
5,717
[ "hwchase17", "langchain" ]
im getting this error AttributeError: module 'chromadb.errors' has no attribute 'NotEnoughElementsException' here my code ``` persist_directory = 'vectorstore' embeddings = OpenAIEmbeddings() vectorstore = Chroma(persist_directory=persist_directory, embedding_function=embeddings) chat_history = [] vectorstore.add_texts(["text text text"]) llm = ChatOpenAI(temperature=0.2) qa = ConversationalRetrievalChain.from_llm( llm, vectorstore.as_retriever(), ) ``` does it mean my vectorstore is damaged ?
NotEnoughElementsException
https://api.github.com/repos/langchain-ai/langchain/issues/5714/comments
5
2023-06-05T07:13:18Z
2023-10-06T16:07:55Z
https://github.com/langchain-ai/langchain/issues/5714
1,741,133,007
5,714
[ "hwchase17", "langchain" ]
### System Info LangChain version 0.0.190 Python 3.9 ### Who can help? @seanpmorgan @3coins ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Tried the following to provide the `temperature` and `maxTokenCount` parameters when using the `Bedrock` class for the `amazon.titan-tg1-large` model. ``` import boto3 import botocore from langchain.chains import LLMChain from langchain.llms.bedrock import Bedrock from langchain.prompts import PromptTemplate from langchain.embeddings import BedrockEmbeddings prompt = PromptTemplate( input_variables=["text"], template="{text}", ) llm = Bedrock(model_id="amazon.titan-tg1-large") llmchain = LLMChain(llm=llm, prompt=prompt) llm.model_kwargs = {'temperature': 0.3, "maxTokenCount": 512} text = "Write a blog explaining Generative AI in ELI5 style." response = llmchain.run(text=text) print(f"prompt={text}\n\nresponse={response}") ``` This results in the following exception ``` ValueError: Error raised by bedrock service: An error occurred (ValidationException) when calling the InvokeModel operation: The provided inference configurations are invalid ``` This happens because https://github.com/hwchase17/langchain/blob/d0d89d39efb5f292f72e70973f3b70c4ca095047/langchain/llms/bedrock.py#L20 passes these params as key value pairs rather than putting them in the `textgenerationConfig` structure as the Titan model expects them to be, The proposed fix is as follows: ``` def prepare_input( cls, provider: str, prompt: str, model_kwargs: Dict[str, Any] ) -> Dict[str, Any]: input_body = {**model_kwargs} if provider == "anthropic" or provider == "ai21": input_body["prompt"] = prompt elif provider == "amazon": input_body = dict() input_body["inputText"] = prompt input_body["textGenerationConfig] = {**model_kwargs} else: input_body["inputText"] = prompt if provider == "anthropic" and "max_tokens_to_sample" not in input_body: input_body["max_tokens_to_sample"] = 50 return input_body ``` ``` ### Expected behavior Support the inference config parameters.
Inference parameters for Bedrock titan models not working
https://api.github.com/repos/langchain-ai/langchain/issues/5713/comments
12
2023-06-05T06:48:57Z
2023-08-16T16:31:01Z
https://github.com/langchain-ai/langchain/issues/5713
1,741,095,321
5,713
[ "hwchase17", "langchain" ]
### Feature request Create sleep tool ### Motivation Some external processes require time to be done. So agent need to just wait ### Your contribution I'll do it and create pull request
Create sleep tool
https://api.github.com/repos/langchain-ai/langchain/issues/5712/comments
3
2023-06-05T06:40:46Z
2023-09-05T05:32:01Z
https://github.com/langchain-ai/langchain/issues/5712
1,741,086,318
5,712
[ "hwchase17", "langchain" ]
### Issue with current documentation: I am trying to view the documentation about tracing via Use Cases --> Evaluation --> Question Answering Benchmarking: State of the Union Address --> "See [here](https://langchain.readthedocs.io/en/latest/tracing.html) for an explanation of what tracing is and how to set it up", but the link shows "404 Not Found" <img width="1247" alt="Screen Shot 2023-06-05 at 13 26 52" src="https://github.com/hwchase17/langchain/assets/72342196/35ea922e-e9ca-4e97-ba8f-304a79474771"> ### Idea or request for content: _No response_
DOC: tracing documentation "404 Not Found"
https://api.github.com/repos/langchain-ai/langchain/issues/5710/comments
1
2023-06-05T05:27:47Z
2023-09-11T16:58:18Z
https://github.com/langchain-ai/langchain/issues/5710
1,740,992,217
5,710
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Hi, I was wondering if there is any way of getting the pandas dataframe during the execution of create_pandas_dataframe_agent. ### Suggestion: _No response_
Issue: get intermediate df from create_pandas_dataframe_agent
https://api.github.com/repos/langchain-ai/langchain/issues/5709/comments
1
2023-06-05T04:25:03Z
2023-09-11T16:58:22Z
https://github.com/langchain-ai/langchain/issues/5709
1,740,936,061
5,709
[ "hwchase17", "langchain" ]
Hi, I load a folder with txt file and using Directory Loader. It keeps show this error > File "/Users/mycompany/test-venv/lib/python3.8/site-packages/unstructured/partition/json.py", line 45, in partition_json > raise ValueError("Not a valid json") > ValueError: Not a valid json When I tried with just 10 txt file before, it was fine. Now I loaded around hundred files it shows that error. After searched, probably caused by one of the documents is not valid when parsing it to json. But I struggle to track which document caused the error. Maybe any ways to do it? Here is my code > def construct_document(directory_path, persists_directory): > loader = DirectoryLoader(directory_path, glob="**/*.txt") > documents = loader.load() > text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) > texts = text_splitter.split_documents(documents) > embeddings = OpenAIEmbeddings(openai_api_key=os.environ["OPENAI_API_KEY"]) > vectordb = Chroma.from_documents(texts, embeddings, > persist_directory=persists_directory) > vectordb.persist() > return embeddings Thank you
ValueError: Not a valid json with Directory Loader function
https://api.github.com/repos/langchain-ai/langchain/issues/5707/comments
8
2023-06-05T03:32:38Z
2024-01-16T10:02:18Z
https://github.com/langchain-ai/langchain/issues/5707
1,740,854,796
5,707
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. JsonSpec() failes to init when top level of json is List. It seems the JsonSpec only supports a top level dict object. We can avoid the error by adding a dummy key to the list, but is this an intended limitation? test.json ```json [ {"name": "Mark", "age":16}, {"name": "Gates", "age":63} ] ``` Code: ```python import pathlib from langchain.agents.agent_toolkits import JsonToolkit from langchain.tools.json.tool import JsonSpec from langchain.agents import create_json_agent from langchain.llms import OpenAI json_spec = JsonSpec.from_file(pathlib.Path("test.json")) json_toolkit = JsonToolkit(spec=json_spec) agent = create_json_agent(OpenAI(), json_toolkit, verbose=True) ``` Error: ``` Traceback (most recent call last): json_spec = JsonSpec.from_file(pathlib.Path("test.json")) File "/usr/local/lib/python3.10/dist-packages/langchain/tools/json/tool.py", line 40, in from_file return cls(dict_=dict_) File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ pydantic.error_wrappers.ValidationError: 1 validation error for JsonSpec dict_ value is not a valid dict (type=type_error.dict) ``` Versions * Python 3.10.6 * langchain 0.0.186 ### Suggestion: _No response_
JSON Agent fails when top level of input json is List object.
https://api.github.com/repos/langchain-ai/langchain/issues/5706/comments
5
2023-06-05T02:45:49Z
2024-04-21T16:24:59Z
https://github.com/langchain-ai/langchain/issues/5706
1,740,788,181
5,706
[ "hwchase17", "langchain" ]
### Feature request It would be great if mailman could be supported in document loader, reference: https://list.org/ ### Motivation For the purpose of digesting content in mailman and quering. ### Your contribution Not sure.
Support mailman in document loader
https://api.github.com/repos/langchain-ai/langchain/issues/5702/comments
1
2023-06-05T00:41:41Z
2023-09-11T16:58:27Z
https://github.com/langchain-ai/langchain/issues/5702
1,740,690,391
5,702
[ "hwchase17", "langchain" ]
### Issue with current documentation: Not sure if this is actually a documentation error, but at least the error is in the code's typehints in `langchain.chain.base.py`, where: ``` def __call__( self, inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Callbacks = None, ) -> Dict[str, Any]: ``` indicates that it returns a dict with Any values while the .apply is specified as follows: ``` def apply( self, input_list: List[Dict[str, Any]], callbacks: Callbacks = None ) -> List[Dict[str, str]]: """Call the chain on all inputs in the list.""" return [self(inputs, callbacks=callbacks) for inputs in input_list] ``` This seems to be a consistent error also applying to e.g. `.run`. Langchain version: 0.0.187 ### Idea or request for content: Change the type hints to consistently be dict[str, Any]. This however, will open up the output space considerably. If desired I can open PR.
DOC: Type hint mismatch indicating that chain.apply should return Dict[str, str] instead of Dict[str, Any]
https://api.github.com/repos/langchain-ai/langchain/issues/5700/comments
1
2023-06-04T23:31:01Z
2023-09-15T22:13:02Z
https://github.com/langchain-ai/langchain/issues/5700
1,740,659,389
5,700
[ "hwchase17", "langchain" ]
https://github.com/hwchase17/langchain/blob/8d9e9e013ccfe72d839dcfa37a3f17c340a47a88/langchain/document_loaders/sitemap.py#L83 if ``` <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <url> <loc> https://tatum.com/ </loc> <xhtml:link rel="alternate" hreflang="x-default" href="https://tatum.com/"/> </url> ``` then ` re.match(r, loc.text) for r in self.filter_urls` Comparison to filter here will be comparing against a value that includes those whitespaces and newlines. What worked for me: ``` def parse_sitemap(self, soup: Any) -> List[dict]: """Parse sitemap xml and load into a list of dicts.""" els = [] for url in soup.find_all("url"): loc = url.find("loc") if not loc: continue loc_text = loc.text.strip() if self.filter_urls and not any( re.match(r, loc_text) for r in self.filter_urls ): continue```
Sitemap filters not working due to lack of stripping whitespace and newlines
https://api.github.com/repos/langchain-ai/langchain/issues/5699/comments
0
2023-06-04T22:49:54Z
2023-06-05T23:33:57Z
https://github.com/langchain-ai/langchain/issues/5699
1,740,645,238
5,699
[ "hwchase17", "langchain" ]
### Issue with current documentation: Currently the [Helicone integration docs](https://python.langchain.com/en/latest/integrations/helicone.html) don't include the fact that an [API key now must be used by passing this header](https://docs.helicone.ai/quickstart/integrate-in-one-minute): ``` Helicone-Auth: Bearer $HELICONE_API_KEY ``` ### Idea or request for content: Add this to the docs.
DOC: Update Helicone docs to include requirement for API key
https://api.github.com/repos/langchain-ai/langchain/issues/5697/comments
1
2023-06-04T21:30:25Z
2023-09-10T16:07:47Z
https://github.com/langchain-ai/langchain/issues/5697
1,740,613,739
5,697
[ "hwchase17", "langchain" ]
### System Info python 3.8, langchain 0.0.187 ### Who can help? @hwchase17 @vowelparrot ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [X] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ```python from langchain import SQLDatabase, SQLDatabaseChain rom langchain.llms.openai import OpenAI db_fp = 'test.db' db = SQLDatabase.from_uri(f"sqlite:///{db_fp}") llm = OpenAI(temperature=0, max_tokens=1000) db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True) # reading default prompt db_chain.llm_chain.prompt.template # set to sth else db_chain.llm_chain.prompt.template = 0 # do something, prompt not good, so want to reset db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True) db_chain.llm_chain.prompt.template # BUG: returns 0, but should be default ``` ### Expected behavior should reinstantiate SQL chain object, but state from template reassignment is kept
prompt template not reset when reinstantiating SQLDatabase object
https://api.github.com/repos/langchain-ai/langchain/issues/5691/comments
1
2023-06-04T17:06:40Z
2023-09-10T16:07:54Z
https://github.com/langchain-ai/langchain/issues/5691
1,740,480,164
5,691
[ "hwchase17", "langchain" ]
### Feature request Hi guys, can we just launch SelfHostedEmbedding without runhouse, as a matter of fact, runhouse its self is still in the early development stage and has some issues, why does langchain depends on it for selfhosted instead of call cuda directly? for example: device = torch.device('cuda') embeddings = SelfHostedEmbeddings( model_load_fn=get_pipeline, hardware=device, model_reqs=["./", "torch", "transformers"], inference_fn=inference_fn ) ### Motivation use GPU local server directly instead of through runhouse. ### Your contribution *
support local GPU server without runhouse !!!
https://api.github.com/repos/langchain-ai/langchain/issues/5689/comments
7
2023-06-04T15:56:15Z
2023-12-13T16:09:13Z
https://github.com/langchain-ai/langchain/issues/5689
1,740,448,094
5,689
[ "hwchase17", "langchain" ]
### System Info langchain==0.0.100 ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [X] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [X] Agents / Agent Executors - [X] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Hey, I am working on a Toolformer Agent similar to ReAct. The prompts given to the agent is a few-shot prompt with tool usage. An example can be seen on this website: https://tsmatz.wordpress.com/2023/03/07/react-with-openai-gpt-and-langchain/#comments I can define the agent without any bugs: ```python SUFFIX = """\nQuestion: {input} {agent_scratchpad}""" TEST_PROMPT = PromptTemplate.from_examples( EXAMPLES, SUFFIX, ["input", "agent_scratchpad"] ) class ReActTestAgent(Agent): @classmethod def create_prompt(cls, tools: Sequence[BaseTool]) -> BasePromptTemplate: return TEST_PROMPT @classmethod def _validate_tools(cls, tools: Sequence[BaseTool]) -> None: if len(tools) != 4: raise ValueError("The number of tools is invalid.") tool_names = {tool.name for tool in tools} if tool_names != {"GetInvoice", "Diff", "Total", "python_repl"}: raise ValueError("The name of tools is invalid.") @property def _agent_type(self) -> str: return "react-test" @property def finish_tool_name(self) -> str: return "Finish" @property def observation_prefix(self) -> str: return f"Observation : " @property def llm_prefix(self) -> str: return f"Thought : " # This method is called by framework to parse text def _extract_tool_and_input(self, text: str) -> Optional[Tuple[str, str]]: action_prefix = f"Action : " if not text.split("\n")[1].startswith(action_prefix): return None action_block = text.split("\n")[1] action_str = action_block[len(action_prefix) :] re_matches = re.search(r"(.*?)\[(.*?)\]", action_str) if re_matches is None: raise ValueError(f"Could not parse action directive: {action_str}") return re_matches.group(1), re_matches.group(2) ########## # run agent ########## # llm = AzureOpenAI( # deployment_name="davinci003-deploy", # model_name="text-davinci-003", # temperature=0, # ) llm = OpenAI(temperature=0, model_name="gpt-3.5-turbo") agent = ReActTestAgent.from_llm_and_tools( llm, tools, ) agent_executor = AgentExecutor.from_agent_and_tools( agent=agent, tools=tools, verbose=True, ) ``` but When I give instruction to the agent ```python question = "hi" agent_executor.run(question) ``` Even the simplest one "hi" will return me the error saying: **ValueError: fix_text not implemented for this agent.** So my question is Why did this error emerge? How to avoid the error? ### Expected behavior The expected output should be similar to the few-shot prompts
ValueError: fix_text not implemented for this agent.
https://api.github.com/repos/langchain-ai/langchain/issues/5684/comments
3
2023-06-04T11:25:01Z
2023-06-15T02:25:14Z
https://github.com/langchain-ai/langchain/issues/5684
1,740,317,450
5,684
[ "hwchase17", "langchain" ]
### System Info Python 3.10.10 (virtual env) on macos 11.7.6 langchain 0.0.187 duckdb 0.7.1 duckduckgo-search 3.7.1 chromadb 0.3.21 tiktoken 0.3.3 torch 2.0.0 ### Who can help? @hwchase17 @eyur ### 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 - [X] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Dear community, I am now playing a bit with the AutoGPT example notebook found in the Langchain documentation, in which I already replaced the search tool for `DuckDuckGoSearchRun()` instead `SerpAPIWrapper()`. So far this works seamlessly. I am now trying to use ChromaDB as vectorstore (in persistent mode), instead of FAISS..however I cannot find how to properly initialize Chroma in this case. I have seen plenty of examples with ChromaDB for documents and/or specific web-page contents, using the `loader` class and then the `Chroma.from_documents()` method. But in the AutoGPT example, they actually use FAISS in the following way, just initializing as an empty vectorstore with fixed embedding size: ``` # Define your embedding model embeddings_model = OpenAIEmbeddings() # Initialize the vectorstore as empty import faiss FAISS() embedding_size = 1536 index = faiss.IndexFlatL2(embedding_size) vectorstore = FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {}) ``` I have tried the following approach without success (after creating the `chroma` subdirectory). Apparently both `chroma-collections.parquet` and `chroma-embeddings.parquet` are created, and I get the confirmation message `Using embedded DuckDB with persistence: data will be stored in: chroma`, but when doing `agent.run(["[here goes my query"])`, I get the error `NoIndexException: Index not found, please create an instance before querying`. The code I have used in order to create the Chroma vectorstore is: ``` persist_directory = "chroma" embeddings_model = OpenAIEmbeddings() chroma_client = chromadb.Client( settings=chromadb.config.Settings( chroma_db_impl="duckdb+parquet", persist_directory=persist_directory, ) ) vectorstore = Chroma(persist_directory=persist_directory, embedding_function=embeddings_model, client=chroma_client, collection_metadata={}) vectorstore.persist() ``` I also cannot find how to replicate the same approach used with FAISS, i.e. initializing as an empty store with a given `embedding_size` (1536 in this case). Any suggestions, or maybe I am overdoing things? It was just a matter of playing that particular example but using a different vectorstore, so to get familiar with the use of Indexes and so. Many thanks! ### Expected behavior Being able to reproduce the [AutoGPT Tutorial](https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html) , making use of LangChain primitives but using ChromaDB (in persistent mode) instead of FAISS
Index not found when trying to use ChromaDB instead of FAISS in the AutoGPT example
https://api.github.com/repos/langchain-ai/langchain/issues/5683/comments
6
2023-06-04T11:23:19Z
2023-11-09T16:11:30Z
https://github.com/langchain-ai/langchain/issues/5683
1,740,316,838
5,683
[ "hwchase17", "langchain" ]
### System Info Hi everyone, I am a beginner of Python and I can not run the first part of the code ![1685862362254](https://github.com/hwchase17/langchain/assets/114320010/0cd40666-fc4a-431d-8c45-5a2fa3956921) but those code is supposed to output feetful of fun ![image](https://github.com/hwchase17/langchain/assets/114320010/439335dc-d3de-4f7d-8e8d-a859f8601750) Is there anybody who knows why? ### Who can help? _No response_ ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction set the environment variable with openai API key and then run the code in the picture ### Expected behavior it supposed to output something OR why is this problem? what should I add into the code?
the first paragraph of code in the quick start can not run in jupyter
https://api.github.com/repos/langchain-ai/langchain/issues/5679/comments
3
2023-06-04T07:53:47Z
2023-09-15T16:08:52Z
https://github.com/langchain-ai/langchain/issues/5679
1,740,217,158
5,679
[ "hwchase17", "langchain" ]
### Feature request Provide an option to limit response length. ### Motivation Developers sometimes would like to reduce answer length to reduce API usage cost. ### Your contribution Can we implement the feature by customizing user's prompt in framework(e.g. append "answer in 50 words" to the prompt).
option to limit response length
https://api.github.com/repos/langchain-ai/langchain/issues/5678/comments
4
2023-06-04T06:57:45Z
2023-12-18T23:50:07Z
https://github.com/langchain-ai/langchain/issues/5678
1,740,191,702
5,678
[ "hwchase17", "langchain" ]
### System Info Python 3.10.6 Win 11 WSL running: Distributor ID: Ubuntu Description: Ubuntu 22.04.2 LTS Release: 22.04 Codename: jammy AMD 5950x CPU w/128GB mem Python packages installed: Package Version ----------------------- ----------- aiohttp 3.8.4 aiosignal 1.3.1 altair 4.2.2 anyio 3.7.0 appdirs 1.4.4 argilla 1.8.0 asttokens 2.2.1 async-timeout 4.0.2 attrs 23.1.0 backcall 0.2.0 backoff 2.2.1 beautifulsoup4 4.12.2 blinker 1.6.2 cachetools 5.3.0 certifi 2023.5.7 cffi 1.15.1 chardet 5.1.0 charset-normalizer 3.1.0 click 8.1.3 comm 0.1.3 commonmark 0.9.1 contourpy 1.0.7 cryptography 40.0.2 cvxpy 1.3.1 cycler 0.11.0 dataclasses-json 0.5.7 debugpy 1.6.7 decorator 5.1.1 Deprecated 1.2.14 ecos 2.0.12 empyrical 0.5.5 entrypoints 0.4 et-xmlfile 1.1.0 exceptiongroup 1.1.1 executing 1.2.0 fastjsonschema 2.17.1 fonttools 4.39.4 fredapi 0.5.0 frozendict 2.3.8 frozenlist 1.3.3 gitdb 4.0.10 GitPython 3.1.31 greenlet 2.0.2 h11 0.14.0 html5lib 1.1 httpcore 0.16.3 httpx 0.23.3 idna 3.4 importlib-metadata 6.6.0 inflection 0.5.1 install 1.3.5 ipykernel 6.23.1 ipython 8.13.2 jedi 0.18.2 Jinja2 3.1.2 joblib 1.2.0 jsonschema 4.17.3 jupyter_client 8.2.0 jupyter_core 5.3.0 kaleido 0.2.1 kiwisolver 1.4.4 langchain 0.0.174 lxml 4.9.2 Markdown 3.4.3 markdown-it-py 2.2.0 MarkupSafe 2.1.2 marshmallow 3.19.0 marshmallow-enum 1.5.1 matplotlib 3.7.1 matplotlib-inline 0.1.6 mdurl 0.1.2 monotonic 1.6 more-itertools 9.1.0 msg-parser 1.2.0 multidict 6.0.4 multitasking 0.0.11 mypy-extensions 1.0.0 Nasdaq-Data-Link 1.0.4 nbformat 5.9.0 nest-asyncio 1.5.6 nltk 3.8.1 numexpr 2.8.4 numpy 1.23.5 olefile 0.46 openai 0.27.7 openapi-schema-pydantic 1.2.4 openpyxl 3.1.2 osqp 0.6.2.post9 packaging 23.1 pandas 1.5.3 pandas-datareader 0.10.0 parso 0.8.3 pdf2image 1.16.3 pdfminer.six 20221105 pexpect 4.8.0 pickleshare 0.7.5 Pillow 9.5.0 pip 22.0.2 platformdirs 3.5.1 plotly 5.14.1 prompt-toolkit 3.0.38 protobuf 3.20.3 psutil 5.9.5 ptyprocess 0.7.0 pure-eval 0.2.2 pyarrow 12.0.0 pycparser 2.21 pydantic 1.10.7 pydeck 0.8.1b0 pyfolio 0.9.2 Pygments 2.15.1 Pympler 1.0.1 pypandoc 1.11 pyparsing 3.0.9 pyportfolioopt 1.5.5 pyrsistent 0.19.3 pytesseract 0.3.10 python-dateutil 2.8.2 python-docx 0.8.11 python-dotenv 1.0.0 python-magic 0.4.27 python-pptx 0.6.21 pytz 2023.3 PyYAML 6.0 pyzmq 25.1.0 qdldl 0.1.7 Quandl 3.7.0 regex 2023.5.5 requests 2.30.0 rfc3986 1.5.0 rich 13.0.1 scikit-learn 1.2.2 scipy 1.10.1 scs 3.2.3 seaborn 0.12.2 setuptools 67.7.2 six 1.16.0 smmap 5.0.0 sniffio 1.3.0 soupsieve 2.4.1 SQLAlchemy 2.0.14 stack-data 0.6.2 stqdm 0.0.5 streamlit 1.22.0 ta 0.10.2 TA-Lib 0.4.26 tabulate 0.9.0 tenacity 8.2.2 threadpoolctl 3.1.0 tiktoken 0.4.0 toml 0.10.2 toolz 0.12.0 tornado 6.3.2 tqdm 4.65.0 traitlets 5.9.0 typer 0.9.0 typing_extensions 4.5.0 typing-inspect 0.8.0 tzdata 2023.3 tzlocal 5.0.1 unstructured 0.7.1 urllib3 2.0.2 validators 0.20.0 watchdog 3.0.0 wcwidth 0.2.6 webencodings 0.5.1 wikipedia 1.4.0 wrapt 1.14.1 xlrd 2.0.1 XlsxWriter 3.1.2 yarl 1.9.2 yfinance 0.2.18 zipp 3.15.0 ### Who can help? @MthwRobinson https://github.com/hwchase17/langchain/commits?author=MthwRobinson ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [X] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction url = "https://www.nasdaq.com/articles/apple-denies-surveillance-claims-made-by-russias-fsb" loader = UnstructuredURLLoader(urls=[url], continue_on_failure=False) data = loader.load() stopping the process shows this stack: --------------------------------------------------------------------------- KeyboardInterrupt Traceback (most recent call last) Cell In[2], line 4 1 url = "https://www.nasdaq.com/articles/apple-denies-surveillance-claims-made-by-russias-fsb" 3 loader = UnstructuredURLLoader(urls=[url], continue_on_failure=False) ----> 4 data = loader.load() File [~/development/public/portfolio-analysis-app/.venv/lib/python3.10/site-packages/langchain/document_loaders/url.py:90](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/jaws/development/public/portfolio-analysis-app/notebooks/~/development/public/portfolio-analysis-app/.venv/lib/python3.10/site-packages/langchain/document_loaders/url.py:90), in UnstructuredURLLoader.load(self) 88 if self.__is_non_html_available(): 89 if self.__is_headers_available_for_non_html(): ---> 90 elements = partition( 91 url=url, headers=self.headers, **self.unstructured_kwargs 92 ) 93 else: 94 elements = partition(url=url, **self.unstructured_kwargs) File [~/development/public/portfolio-analysis-app/.venv/lib/python3.10/site-packages/unstructured/partition/auto.py:96](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/jaws/development/public/portfolio-analysis-app/notebooks/~/development/public/portfolio-analysis-app/.venv/lib/python3.10/site-packages/unstructured/partition/auto.py:96), in partition(filename, content_type, file, file_filename, url, include_page_breaks, strategy, encoding, paragraph_grouper, headers, ssl_verify, ocr_languages, pdf_infer_table_structure, xml_keep_tags) 93 exactly_one(file=file, filename=filename, url=url) 95 if url is not None: ---> 96 file, filetype = file_and_type_from_url( 97 url=url, 98 content_type=content_type, 99 headers=headers, 100 ssl_verify=ssl_verify, 101 ) ... -> 1130 return self._sslobj.read(len, buffer) 1131 else: 1132 return self._sslobj.read(len) KeyboardInterrupt: ### Expected behavior expect that it does not hang
UnstructuredURLLoader hangs on some URLs
https://api.github.com/repos/langchain-ai/langchain/issues/5670/comments
2
2023-06-03T23:46:59Z
2023-09-13T16:07:07Z
https://github.com/langchain-ai/langchain/issues/5670
1,739,996,533
5,670
[ "hwchase17", "langchain" ]
### System Info langchain-0.0.189, windows, python 3.11.3 ### Who can help? Will submit PR to resolve. ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction When calling ConversationChain.predict with VertexAI, the settings to the LLM are overriden. To repro, run the following (adapted from tests.integration_tests.chat_models.test_vertexai.test_vertexai_single_call) : ```python from langchain.chat_models import ChatVertexAI from langchain.schema import ( HumanMessage, ) model = ChatVertexAI( temperature=1, max_output_tokens=1, top_p=1, top_k=1, ) message = HumanMessage(content="Tell me everything you know about science.") response = model([message]) assert len(response.content) < 50 ``` ### Expected behavior Expected: the assertion should be true if only 1 token was sent back. Allowing for mistakes in the LLM, I set very generous threshold of 50 characters.
Model settings (temp, max tokens, topk, topp) ignored with vertexai
https://api.github.com/repos/langchain-ai/langchain/issues/5667/comments
1
2023-06-03T23:26:24Z
2023-06-03T23:50:17Z
https://github.com/langchain-ai/langchain/issues/5667
1,739,986,947
5,667
[ "hwchase17", "langchain" ]
### Feature request Support for Hugging Face's Question Answering Models would be great. ### Motivation It would allow for the construction of extractive Question Answering Pipelines, making use of the vast amount of open Q&A Models on Hugging Face. ### Your contribution I would be happy to tackle the implementation and submitt a PR. Have you thought about integrating this already? If so, I'm open for a discussion on the best way to to this. (New Class vs extending 'HuggingFacePipeline').
Support for Hugging Face Question Answering Models
https://api.github.com/repos/langchain-ai/langchain/issues/5660/comments
1
2023-06-03T17:54:22Z
2023-09-10T16:08:08Z
https://github.com/langchain-ai/langchain/issues/5660
1,739,715,128
5,660
[ "hwchase17", "langchain" ]
### Issue with current documentation: **Severity:** Minor **Where:** Use Cases -> Agent Simulations -> Simulations with two agents -> CAMEL Direct link: [CAMEL Role-Playing Autonomous Cooperative Agents](https://python.langchain.com/en/latest/use_cases/agent_simulations/camel_role_playing.html) **What:** In the code of the CAMELAgent, the reset_method has the wrong type annotation. Should be: ```python def reset(self) -> List[BaseMessage]: self.init_messages() return self.stored_messages ``` ### Idea or request for content: _No response_
DOC: Annotation error in the CAMELAgent helper class
https://api.github.com/repos/langchain-ai/langchain/issues/5658/comments
1
2023-06-03T15:44:03Z
2023-09-10T16:08:13Z
https://github.com/langchain-ai/langchain/issues/5658
1,739,633,584
5,658
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. agent_chain.run does not allow for more than a single output, when calling RetrievalQA.from_chain_type directly with the same query it has no issues returning multiple outputs, however agent_chain is where all of my custom tools and configurations are. agent_chain.run in my code at the moment refers to AgentExecutor.from_agents_and_tools Is there a current workaround for this or is there a strong reason why .run can only support a single output? ### Suggestion: _No response_
Issue: When using agent_chain.run to query documents, I want to return both the LLM answer and Source documents, however agent_chain.run only allows for exactly 1 output
https://api.github.com/repos/langchain-ai/langchain/issues/5656/comments
4
2023-06-03T13:58:57Z
2023-09-25T16:06:26Z
https://github.com/langchain-ai/langchain/issues/5656
1,739,566,153
5,656
[ "hwchase17", "langchain" ]
### System Info run on docker image with python:3.11.3-bullseye in MAC m1 ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction My docker image ``` FROM python:3.11.3-bullseye WORKDIR /src COPY src /src RUN python -m pip install --upgrade pip RUN apt-get update -y RUN apt install cmake -y RUN git clone --recurse-submodules https://github.com/nomic-ai/gpt4all RUN cd gpt4all/gpt4all-backend/ && mkdir build && cd build && cmake .. && cmake --build . --parallel RUN cd gpt4all/gpt4all-bindings/python && pip3 install -e . RUN pip install -r requirements.txt RUN chmod +x app/start_app.sh EXPOSE 8501 ENTRYPOINT ["/bin/bash"] CMD ["app/start_app.sh"] ``` where star_app.sh is run python file that have this line `llm = GPT4All(model=llm_path, backend='gptj', verbose=True, streaming=True, n_threads=os.cpu_count(),temp=temp)` llm_path is path of gpt4all model ### Expected behavior Got this error when try to use gpt4all ``` AttributeError: 'LLModel' object has no attribute 'model_type' Traceback: File "/src/app/utils.py", line 20, in get_chain llm = GPT4All(model=llm_path, backend='gptj', verbose=True, streaming=True, n_threads=os.cpu_count(),temp=temp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 339, in __init__ values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 1102, in validate_model values = validator(cls_, values) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/langchain/llms/gpt4all.py", line 156, in validate_environment values["backend"] = values["client"].model.model_type ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
AttributeError: 'LLModel' object has no attribute 'model_type' (gpt4all)
https://api.github.com/repos/langchain-ai/langchain/issues/5651/comments
4
2023-06-03T10:37:42Z
2023-06-16T14:29:32Z
https://github.com/langchain-ai/langchain/issues/5651
1,739,392,895
5,651
[ "hwchase17", "langchain" ]
### System Info LangChain: 0.0.189 Platform: Ubuntu 22.04.2 LTS Python: 3.10.10 ### Who can help? @hwchase17 @agola11 ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction You can re-produce the error using the notebook at https://python.langchain.com/en/latest/modules/models/llms/integrations/modal.html The following is the response json from my Modal endpoint: ```javascript {'prompt': 'Artificial Intelligence (AI) is the study of artificial intelligence. Artificial intelligence is the study of artificial intelligence. So, the final answer is AI.'} ``` It still raise the ValueError("LangChain requires 'prompt' key in response."). After look into the code, I think there is a bug at https://github.com/hwchase17/langchain/blob/master/langchain/llms/modal.py#L90, the correct syntax should be: ```python if "prompt" in response.json(): ``` ### Expected behavior No value error should be raised if the response json format is correct.
Bug in langchain.llms.Modal which raised ValueError("LangChain requires 'prompt' key in response.")
https://api.github.com/repos/langchain-ai/langchain/issues/5648/comments
4
2023-06-03T09:27:01Z
2023-12-13T16:09:23Z
https://github.com/langchain-ai/langchain/issues/5648
1,739,315,605
5,648
[ "hwchase17", "langchain" ]
### System Info Langchain version 0.0.179 Ubuntu 20.4 ### Who can help? @hwchase17 @agola11 @vowelparrot ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Trying to load Llama-30b-supercot this way results in below error, what is the correct way to load a model with additional configuration like given below? ``` model_name = 'ausboss/llama-30b-supercot' quantization_config = BitsAndBytesConfig(llm_int8_enable_fp32_cpu_offload=True) model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map='auto', load_in_8bit=True,quantization_config=quantization_config) tokenizer = AutoTokenizer.from_pretrained(model_name) instruct_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer, torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto", return_full_text=True, max_new_tokens=200, top_p=0.95, top_k=50, eos_token_id=tokenizer.eos_token_id) template = """Below is an instruction that describes a task. Write a response that appropriately completes the request. Instruction: You are an experienced in this solution and your job is to help providing the best answer related to this. Use only information in the following paragraphs to answer the question at the end, do not repeat sentences in your answer. Explain the answer with reference to these paragraphs. If you don't know, say that you do not know. {context} Question: {question} Response: """ prompt = PromptTemplate(input_variables=['context', 'question'], template=template) return load_qa_chain(llm=instruct_pipeline, chain_type="map_reduce", prompt=prompt, verbose=False) ``` Results in this error ``` โ”‚ /home/ubuntu/lambda_labs/llama-supercot/Search_faiss_llama_30B_supercot.py:59 in build_qa_chain โ”‚ โ”‚ โ”‚ โ”‚ 56 """ โ”‚ โ”‚ 57 prompt = PromptTemplate(input_variables=['context', 'question'], template=template) โ”‚ โ”‚ 58 โ”‚ โ”‚ โฑ 59 return load_qa_chain(llm=instruct_pipeline, chain_type="map_reduce", prompt=prompt, ve โ”‚ โ”‚ 60 โ”‚ โ”‚ 61 # Building the chain will load Dolly and can take several minutes depending on the model โ”‚ โ”‚ 62 qa_chain = build_qa_chain() โ”‚ โ”‚ โ”‚ โ”‚ /home/ubuntu/miniconda/lib/python3.10/site-packages/langchain/chains/question_answering/__init__ โ”‚ โ”‚ .py:218 in load_qa_chain โ”‚ โ”‚ โ”‚ โ”‚ 215 โ”‚ โ”‚ โ”‚ f"Got unsupported chain type: {chain_type}. " โ”‚ โ”‚ 216 โ”‚ โ”‚ โ”‚ f"Should be one of {loader_mapping.keys()}" โ”‚ โ”‚ 217 โ”‚ โ”‚ ) โ”‚ โ”‚ โฑ 218 โ”‚ return loader_mapping[chain_type]( โ”‚ โ”‚ 219 โ”‚ โ”‚ llm, verbose=verbose, callback_manager=callback_manager, **kwargs โ”‚ โ”‚ 220 โ”‚ ) โ”‚ โ”‚ 221 โ”‚ โ”‚ โ”‚ โ”‚ /home/ubuntu/miniconda/lib/python3.10/site-packages/langchain/chains/question_answering/__init__ โ”‚ โ”‚ .py:95 in _load_map_reduce_chain โ”‚ โ”‚ โ”‚ โ”‚ 92 โ”‚ _combine_prompt = ( โ”‚ โ”‚ 93 โ”‚ โ”‚ combine_prompt or map_reduce_prompt.COMBINE_PROMPT_SELECTOR.get_prompt(llm) โ”‚ โ”‚ 94 โ”‚ ) โ”‚ โ”‚ โฑ 95 โ”‚ map_chain = LLMChain( โ”‚ โ”‚ 96 โ”‚ โ”‚ llm=llm, โ”‚ โ”‚ 97 โ”‚ โ”‚ prompt=_question_prompt, โ”‚ โ”‚ 98 โ”‚ โ”‚ verbose=verbose, โ”‚ โ”‚ โ”‚ โ”‚ /home/ubuntu/lambda_labs/llama-supercot/pydantic/main.py:341 in pydantic.main.BaseModel.__init__ โ”‚ โ”‚ โ”‚ โ”‚ [Errno 2] No such file or directory: '/home/ubuntu/lambda_labs/llama-supercot/pydantic/main.py' โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ ValidationError: 1 validation error for LLMChain llm value is not a valid dict (type=type_error.dict) ``` ### Expected behavior A model should load for Q&A with documents
Trying to load an external model Llama-30B-Supercot results in below error
https://api.github.com/repos/langchain-ai/langchain/issues/5647/comments
2
2023-06-03T07:13:52Z
2023-06-03T08:05:47Z
https://github.com/langchain-ai/langchain/issues/5647
1,739,243,294
5,647
[ "hwchase17", "langchain" ]
### Feature request Due to security reasons, it is not always possible to connect directly to the DB. I want SQLDatabaseChain to support ssh tunnel because I have to connect to a specific kind of stepping stone server before I can connect to the DB. If there is already a way to accomplish this, I apologize. ### Motivation I want to use llm with all our own data to create an innovative experience, and SQLDatabaseChain makes that possible. ### Your contribution I can contribute with testing. I do not yet have a good understanding of langchain's source code structure and inner workings, so coding contributions would not be appropriate.
I want ssh tunnel support in SQLDatabaseChain
https://api.github.com/repos/langchain-ai/langchain/issues/5645/comments
2
2023-06-03T04:43:36Z
2023-09-14T16:06:47Z
https://github.com/langchain-ai/langchain/issues/5645
1,739,157,088
5,645
[ "hwchase17", "langchain" ]
### System Info ## System Info - `langchain.__version__` is `0.0.184` - Python 3.11 - Mac OS Ventura 13.3.1(a) ### Who can help? @hwchase17 ## Summary The **sources** component of the output of `RetrievalQAWithSourcesChain` is not providing transparency into what documents the retriever returns, it is instead some output that the llm contrives. ## Motivation From my perspective, the primary advantage of having visibility into sources is to allow the system to provide transparency into the documents that were retrieved in assisting the language model to generate its answer. Only after being confused for quite a while and inspecting the code did I realize that the sources were just being conjured up. ## Advice I think it is important to ensure that people know about this, as maybe this isn't a bug and is more [documentation](https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa_with_sources.html)-related, though I think the [docstring](https://github.com/hwchase17/langchain/blob/9a7488a5ce65aaf727464f02a10811719b517f11/langchain/chains/qa_with_sources/retrieval.py#L13) should be updated as well. ### Notes #### Document Retrieval Works very well. It's worth noting that in this toy example, the combination of `FAISS` vector store and the `OpenAIEmbeddings` embeddings model are doing very reasonably, and are deterministic. #### Recommendation Add caveatsย everywhere. Frankly, I would never trust using this chain. I literally had an example the other day where it wrongly made up a source and a wikipedia url that had absolutely nothing to do with the documents retrieved. I could supply this example as it is a way better illustration of how this chain will hallucinate sources because they are generated by the LLM, but it's just a little bit more involved than this smaller example. ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ## Demonstrative Example Here's the simplest example I could come up with: ### 1. Instantiate a `vectorstore` with 7 documents displayed below. ```python >>> from langchain.vectorstores import FAISS >>> from langchain.embeddings import OpenAIEmbeddings >>> from langchain.llms import OpenAI >>> from langchain.chains import RetrievalQAWithSourcesChain >>> chars = ['a', 'b', 'c', 'd', '1', '2', '3'] >>> texts = [4*c for c in chars] >>> metadatas = [{'title': c, 'source': f'source_{c}'} for c in chars] >>> vs = FAISS.from_texts(texts, embedding=OpenAIEmbeddings(), metadatas=metadatas) >>> retriever = vs.as_retriever(search_kwargs=dict(k=5)) >>> vs.docstore._dict ``` {'0ec43ce4-6753-4dac-b72a-6cf9decb290e': Document(page_content='aaaa', metadata={'title': 'a', 'source': 'source_a'}), '54baed0b-690a-4ffc-bb1e-707eed7da5a1': Document(page_content='bbbb', metadata={'title': 'b', 'source': 'source_b'}), '85b834fa-14e1-4b20-9912-fa63fb7f0e50': Document(page_content='cccc', metadata={'title': 'c', 'source': 'source_c'}), '06c0cfd0-21a2-4e0c-9c2e-dd624b5164fe': Document(page_content='dddd', metadata={'title': 'd', 'source': 'source_d'}), '94d6444f-96cd-4d88-8973-c3c0b9bf0c78': Document(page_content='1111', metadata={'title': '1', 'source': 'source_1'}), 'ec04b042-a4eb-4570-9ee9-a2a0bd66a82e': Document(page_content='2222', metadata={'title': '2', 'source': 'source_2'}), '0031d3fc-f291-481e-a12a-9cc6ed9761e0': Document(page_content='3333', metadata={'title': '3', 'source': 'source_3'})} ### 2. Instantiate a `RetrievalQAWithSourcesChain` The `return_source_documents` is set to `True` so that we can inspect the actual sources retrieved. ```python >>> qa_sources = RetrievalQAWithSourcesChain.from_chain_type( OpenAI(), retriever=retriever, return_source_documents=True ) ``` ### 3. Example Question Things look sort of fine, meaning 5 documents are retrieved by the `retriever`, but the model only lists only a single source. ```python qa_sources('what is the first lower-case letter of the alphabet?') ``` {'question': 'what is the first lower-case letter of the alphabet?', 'answer': ' The first lower-case letter of the alphabet is "a".\n', 'sources': 'source_a', 'source_documents': [Document(page_content='bbbb', metadata={'title': 'b', 'source': 'source_b'}), Document(page_content='aaaa', metadata={'title': 'a', 'source': 'source_a'}), Document(page_content='cccc', metadata={'title': 'c', 'source': 'source_c'}), Document(page_content='dddd', metadata={'title': 'd', 'source': 'source_d'}), Document(page_content='1111', metadata={'title': '1', 'source': 'source_1'})]} ### 4. Second Example Question containing the First Question. This is not what I would expect, considering that this question contains the previous question, and that the vector store did supply the document with `{'source': 'source_a'}`, but for some reason (i.e. the internals of the output of `OpenAI()` ) in this response from the chain, there are zero sources listed. ```python >>> qa_sources('what is the one and only first lower-case letter and number of the alphabet and whole number system?') ``` {'question': 'what is the one and only first lower-case letter and number of the alphabet and whole number system?', 'answer': ' The one and only first lower-case letter and number of the alphabet and whole number system is "a1".\n', 'sources': 'N/A', 'source_documents': [Document(page_content='1111', metadata={'title': '1', 'source': 'source_1'}), Document(page_content='bbbb', metadata={'title': 'b', 'source': 'source_b'}), Document(page_content='aaaa', metadata={'title': 'a', 'source': 'source_a'}), Document(page_content='2222', metadata={'title': '2', 'source': 'source_2'}), Document(page_content='cccc', metadata={'title': 'c', 'source': 'source_c'})]} ### Expected behavior I am not sure. We need a warning, perhaps, every time this chain is used, or some strongly worded documentation for our developers.
RetrievalQAWithSourcesChain provides unreliable sources
https://api.github.com/repos/langchain-ai/langchain/issues/5642/comments
1
2023-06-03T02:45:24Z
2023-09-18T16:09:24Z
https://github.com/langchain-ai/langchain/issues/5642
1,739,087,949
5,642
[ "hwchase17", "langchain" ]
### Issue with current documentation: In the left nav of the docs, "Amazon Bedrock" is alphabetized after "Beam integration for langchain" and before "Cerebrium AI", not with the rest of the A-named integrations. <img width="254" alt="image" src="https://github.com/hwchase17/langchain/assets/93281816/20836ca0-3946-4614-8b44-4dcf67e27f7e"> ### Idea or request for content: Retitle the page to "Bedrock" so that its URL remains unchanged and the nav is properly sorted.
DOC: "Amazon Bedrock" is not sorted in Integrations section of nav
https://api.github.com/repos/langchain-ai/langchain/issues/5638/comments
0
2023-06-02T23:41:12Z
2023-06-04T21:39:26Z
https://github.com/langchain-ai/langchain/issues/5638
1,738,950,805
5,638
[ "hwchase17", "langchain" ]
### System Info The [_default_knn_query](https://github.com/jeffvestal/langchain/blob/10f34bf62e2d53f0b1a7b15ba21c2328b64862cd/langchain/vectorstores/elastic_vector_search.py#L402) takes `field` arg to specify the field to use when performing knn and hybrid search. both [knn_search](https://github.com/jeffvestal/langchain/blob/10f34bf62e2d53f0b1a7b15ba21c2328b64862cd/langchain/vectorstores/elastic_vector_search.py#L475) and [hybrid_search](https://github.com/jeffvestal/langchain/blob/10f34bf62e2d53f0b1a7b15ba21c2328b64862cd/langchain/vectorstores/elastic_vector_search.py#L537) need to allow that to be passed in as an arg and pass it to `_default_knn_query` I'll make the update cc: @hw ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Try to search a field other than `vector`, can't do it ### Expected behavior Pass a `qeuery_field` value to search over a different field name other than the default `vector`
Allow query field to be passed in ElasticKnnSearch.knnSearch
https://api.github.com/repos/langchain-ai/langchain/issues/5633/comments
2
2023-06-02T20:16:03Z
2023-09-10T16:08:24Z
https://github.com/langchain-ai/langchain/issues/5633
1,738,770,687
5,633
[ "hwchase17", "langchain" ]
### Feature request Make `embedding` an [optional arg](https://github.com/jeffvestal/langchain/blob/10f34bf62e2d53f0b1a7b15ba21c2328b64862cd/langchain/vectorstores/elastic_vector_search.py#L332) when creating `ElasticKnnSearch` class ### Motivation If a user is only going to run knn/hybrid search AND use the `query_vector_builder` having an embedding object is not needed as ES will generate the embedding during search ### Your contribution I will make the changes
Make embedding object optional for ElasticKnnSearch
https://api.github.com/repos/langchain-ai/langchain/issues/5631/comments
1
2023-06-02T19:52:37Z
2023-09-10T16:08:28Z
https://github.com/langchain-ai/langchain/issues/5631
1,738,736,481
5,631
[ "hwchase17", "langchain" ]
### System Info LangChain 0.0.188 Python 3.8 ### Who can help? @hwchase17 @agola11 ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True) qa = ConversationalRetrievalChain.from_llm(OpenAI(temperature =0), vectorstore.as_retriever(), memory=memory, return_source_documents=True) qa({"question": query}) #ValueError" One output key expected, got dict_keys(['answer', 'source_documents']) qa = ConversationalRetrievalChain.from_llm(OpenAI(temperature =0), vectorstore.as_retriever(), return_source_documents=True) qa({"question": query, "chat_history": []}) #...(runs as expected) ### Expected behavior ConversationalRetrievalChain does not work with ConversationBufferMemory and return_source_documents=True. ValueError: One output key expected, got dict_keys(['answer', 'source_documents'])
ConversationalRetrievalChain unable to use ConversationBufferMemory when return_source_documents=True
https://api.github.com/repos/langchain-ai/langchain/issues/5630/comments
9
2023-06-02T18:54:26Z
2023-11-09T16:13:41Z
https://github.com/langchain-ai/langchain/issues/5630
1,738,661,160
5,630
[ "hwchase17", "langchain" ]
### Issue with current documentation: Pages in Modules: Models, Prompts, Memory, ... They all have repeated parts. See a picture. ![image](https://github.com/hwchase17/langchain/assets/2256422/05514908-87b5-453a-9795-8304612f42bf) ### Idea or request for content: The whole "Go Deeper" section can be removed and instead, the links from removed items added to the above items. For example "Prompt Templates" link is added to the "LLM Prompt Templates" in the above text. Etc. This significantly decreases the size of the page and improves user experience. No more repetitive items. _No response_
DOC: repetitive parts in Modules pages
https://api.github.com/repos/langchain-ai/langchain/issues/5627/comments
0
2023-06-02T18:24:00Z
2023-06-04T01:43:06Z
https://github.com/langchain-ai/langchain/issues/5627
1,738,622,995
5,627
[ "hwchase17", "langchain" ]
### System Info langchain==0.0.189 os:windows11 python=3.10.11 ### 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 - [X] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction from langchain.document_loaders import FigmaFileLoader ### Expected behavior expected: load the module error: ImportError: cannot import name 'FigmaFileLoader' from 'langchain.document_loaders' (C:\Users\xxx\AppData\Local\miniconda3\envs\xxx\lib\site-packages\langchain\document_loaders\__init__.py) comments: checked the langchain\document_loaders\__init__.py and there is no reference to FigmaFileLoader
cannot import name 'FigmaFileLoader'
https://api.github.com/repos/langchain-ai/langchain/issues/5623/comments
1
2023-06-02T16:39:41Z
2023-06-03T01:48:51Z
https://github.com/langchain-ai/langchain/issues/5623
1,738,498,708
5,623
[ "hwchase17", "langchain" ]
### Issue with current documentation: ![image](https://github.com/hwchase17/langchain/assets/56947550/418be26f-62e3-4719-bfc8-a81c89b1845f) ### Idea or request for content: The program is stuck and will not return
DOC: can't execute the code of Async API for Chain
https://api.github.com/repos/langchain-ai/langchain/issues/5622/comments
1
2023-06-02T16:16:48Z
2023-09-10T16:08:33Z
https://github.com/langchain-ai/langchain/issues/5622
1,738,473,740
5,622
[ "hwchase17", "langchain" ]
### System Info I am using Python for INdexing Document to OpenELastic search Python for Indexing----> documents = loader.load() text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) docs = text_splitter.split_documents(documents) vs = OpenSearchVectorSearch.from_documents( docs, embeddings, opensearch_url="https://search-bterai-opensearch-gmtgf5ukflbg77xlwenvwko4gm.us-west-2.es.amazonaws.com", http_auth=("XXXX", "XXXX"), use_ssl = False, verify_certs = False, ssl_assert_hostname = False, ssl_show_warn = False, index_name="test_sidsfarm") NodejS for Querying const client = new Client({ nodes: [process.env.OPENSEARCH_URL ?? "https://X:X@search-bterai-opensearch-gmtgf5ukflbg77xlwenvwko4gm.us-west-2.es.amazonaws.com"], }); const vectorStore = new OpenSearchVectorStore(new OpenAIEmbeddings(), { client, indexName: "test_sidsfarm" }); const chain = VectorDBQAChain.fromLLM(model, vectorStore, { returnSourceDocuments: true, }); res = await chain.call({ query: input }); Its Giving me error below , Please help!! failed to create query: Field 'embedding' is not knn_vector type. ### Who can help? @hwchase17 ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ALready mentioned steps above ### Expected behavior It should work out of the box irrespective of platforms
Opensearch for Indexing and Retrieval
https://api.github.com/repos/langchain-ai/langchain/issues/5615/comments
4
2023-06-02T12:25:19Z
2024-04-30T16:28:28Z
https://github.com/langchain-ai/langchain/issues/5615
1,738,108,763
5,615
[ "hwchase17", "langchain" ]
### System Info langchain 0.0.188 python 3.8.10 ### 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 - [X] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ``` from langchain.docstore.document import Document from langchain.text_splitter import MarkdownTextSplitter # of course this is part of a larger markdown document, but this is the minimal string to reproduce txt = "\n\n***\n\n" doc = Document(page_content=txt) markdown_splitter = MarkdownTextSplitter(chunk_size=1000, chunk_overlap=0) splitted = markdown_splitter.split_documents([doc]) ``` ``` Traceback (most recent call last): File "t.py", line 9, in <module> splitted = markdown_splitter.split_documents([doc]) File "/home/richard/.local/lib/python3.8/site-packages/langchain/text_splitter.py", line 101, in split_documents return self.create_documents(texts, metadatas=metadatas) File "/home/richard/.local/lib/python3.8/site-packages/langchain/text_splitter.py", line 88, in create_documents for chunk in self.split_text(text): File "/home/richard/.local/lib/python3.8/site-packages/langchain/text_splitter.py", line 369, in split_text return self._split_text(text, self._separators) File "/home/richard/.local/lib/python3.8/site-packages/langchain/text_splitter.py", line 346, in _split_text splits = _split_text(text, separator, self._keep_separator) File "/home/richard/.local/lib/python3.8/site-packages/langchain/text_splitter.py", line 37, in _split_text _splits = re.split(f"({separator})", text) File "/usr/lib/python3.8/re.py", line 231, in split return _compile(pattern, flags).split(string, maxsplit) File "/usr/lib/python3.8/re.py", line 304, in _compile p = sre_compile.compile(pattern, flags) File "/usr/lib/python3.8/sre_compile.py", line 764, in compile p = sre_parse.parse(p, flags) File "/usr/lib/python3.8/sre_parse.py", line 948, in parse p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0) File "/usr/lib/python3.8/sre_parse.py", line 443, in _parse_sub itemsappend(_parse(source, state, verbose, nested + 1, File "/usr/lib/python3.8/sre_parse.py", line 834, in _parse p = _parse_sub(source, state, sub_verbose, nested + 1) File "/usr/lib/python3.8/sre_parse.py", line 443, in _parse_sub itemsappend(_parse(source, state, verbose, nested + 1, File "/usr/lib/python3.8/sre_parse.py", line 671, in _parse raise source.error("multiple repeat", re.error: multiple repeat at position 4 (line 3, column 2) ``` ### Expected behavior splitted contains splitted markdown and no errors occur
MarkdownTextSplitter: multiple repeat at position 4 (line 3, column 2)
https://api.github.com/repos/langchain-ai/langchain/issues/5614/comments
0
2023-06-02T12:20:41Z
2023-06-05T23:40:28Z
https://github.com/langchain-ai/langchain/issues/5614
1,738,102,515
5,614
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. So, I am working on a project that involves data extraction from csv files and involves creating charts and graphs from them. below is a snippet of code for the agent that I have created : ```python tools = [ python_repl_tool, csv_ident_tool, csv_extractor_tool, ] # Adding memory to our agent from langchain.agents import ZeroShotAgent from langchain.memory import ConversationBufferMemory prefix = """Have a conversation with a human, answering the following questions as best you can. You have access to the following tools:""" suffix = """Begin!" {chat_history} Question: {input} {agent_scratchpad}""" prompt = ZeroShotAgent.create_prompt( tools=tools, prefix=prefix, suffix=suffix, input_variables=["input", "chat_history", "agent_scratchpad"] ) memory = ConversationBufferMemory(memory_key="chat_history") # Creating our agent from langchain.chains import LLMChain from langchain.llms import OpenAI from langchain.agents import AgentExecutor llm_chain = LLMChain(llm=OpenAI(temperature=0), prompt=prompt) agent = ZeroShotAgent(llm_chain=llm_chain, tools=tools, verbose=True) agent_chain = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True, memory=memory) ``` Where csv_ident tool is a custom tool I created to identify csv file in a prompt. Example: prompt : What is the mean of age in data.csv? completion : data.csv csv_extractor_tool is as follows : ```python def csv_extractor(json_request: str): ''' Useful for extracting data from a csv file. Takes a JSON dictionary as input in the form: { "prompt":"<question>", "path":"<file_name>" } Example: { "prompt":"Find the maximum age in xyz.csv", "path":"xyz.csv" } Args: request (str): The JSON dictionary input string. Returns: The required information from csv file. ''' arguments_dictionary = json.loads(json_request) question = arguments_dictionary["prompt"] file_name = arguments_dictionary["path"] csv_agent = create_csv_agent(llm=llm,path=file_name,verbose=True) return csv_agent.run(question) request_format = '{{"prompt":"<question>","path":"<file_name>"}}' description = f'Useful for working with a csv file. Input should be JSON in the following format: {request_format}' csv_extractor_tool = Tool( name="csv_extractor", func=csv_extractor, description=description, verbose=True, ) ``` So I am creating a csv_agent and passing the prompt and path to it. This handles the data extraction type tasks easily, but I produces poor results while making plots. Till now I have tried creating a new LLMChain in which I passed prompt comprising of several examples as given below: ``` input :{{"prompt":"Load data.csv and find the mean of age column.","path":"data.csv"}} completion :import pandas as pd df = pd.read_csv('data.csv') df = df['Age'].mean() print(df) df.to_csv('.\\bin\\file.csv') ``` But this does not work as the LLM cannot know beforehand what are the exact column name and generating such a code is short-sighted and produces errors. I have also tried taking a callbacks based approach where in the on_tool_end() function I was trying to save the dataframe. Is there any way to make csv_agent save the dataframe in a bin folder after it is done extracting the information, which I can pass to my custom plot creating tool. ### Suggestion: _No response_
create_csv_agent: How to save a dataframe once information has been extracted using create_csv_agent.
https://api.github.com/repos/langchain-ai/langchain/issues/5611/comments
9
2023-06-02T10:38:14Z
2023-09-30T16:06:49Z
https://github.com/langchain-ai/langchain/issues/5611
1,737,940,580
5,611
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. I am using the ConversationalRetrievalQAChain to retrieve answers for questions while condensing the chat history to a standalone question. The issue I am facing is that the first token returned by the chain.call handleLLMNewToken is the standalone condensed question when there is a chat_history provided. Ideally, I do not want the condensed question to be sent via the handleLLMNewToken instead I want just the answer tokens. Is there any way to achieve that? Here is the code I am running: `import { CallbackManager } from "langchain/callbacks"; import { ConversationalRetrievalQAChain } from "langchain/chains"; import { ChatOpenAI } from "langchain/chat_models"; import { PineconeStore } from "langchain/vectorstores/pinecone"; const CONDENSE_PROMPT = `Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question. Chat History: {chat_history} Follow Up Input: {question} Standalone question:`; const QA_PROMPT = `You are an AI assistant. Use the following pieces of context to answer the question at the end. If you don't know the answer, just say you don't know. DO NOT try to make up an answer. If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context. {context} Question: {question} Helpful answer in markdown:`; export const makeChain = ( vectorstore: PineconeStore, onTokenReceived: (data: string) => void ) => { const model = new ChatOpenAI({ temperature: 0, streaming: true, modelName: "gpt-3.5-turbo", openAIApiKey: process.env.OPENAI_API_KEY as string, callbackManager: CallbackManager.fromHandlers({ async handleLLMNewToken(token) { onTokenReceived(token); }, async handleLLMEnd(result) {}, }), }); return ConversationalRetrievalQAChain.fromLLM( model, vectorstore.asRetriever(), { qaTemplate: QA_PROMPT, questionGeneratorTemplate: CONDENSE_PROMPT, returnSourceDocuments: true, // The number of source documents returned is 4 by default } ); }; ` ### Suggestion: _No response_
Issue: ConversationalRetrievalQAChain returns the qaTemplate condensed question as the first token
https://api.github.com/repos/langchain-ai/langchain/issues/5608/comments
9
2023-06-02T10:19:03Z
2023-09-08T04:02:54Z
https://github.com/langchain-ai/langchain/issues/5608
1,737,908,101
5,608
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Hi, I am using Langchain to implement a customer service agent. I am using AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION and ConversationBufferMemory. Findings: 1. the Agent works very well with lookup & retrieve QA, e.g., what is the material of a t-shirt, how long does it take to ship... 2. However, the Agent failed to process a task consistently. - For example, Image the agent has two tools: [cancel-order-tool] & [size-lookup-tool]. - Now the user wants to cancel an order. - User says: "I want to cancel the order of the XYZ t-shirt." - Agent using [cancel-order-tool]: "Sorry to hear that. May I know why you want to cancel the order?" - User: "The size is too big" - Agent using [size-question-tool]: Please look up the size in the website size chart. ---> this is a wrong answer. The agent switched from [cancel-order-tool] to [size-lookup-tool]. How can I implement the consistency here? So that the Agent will continue to process the cancel-order issue instead of jumping into the size QA. I think consistency is very important to the customer service application where we have kind of strict SOPs. ### Suggestion: Maybe I should overwrite the plan function of the agent so that it can plan & act in a more consistent way? E.g., implement a state transit machine
Issue: How to let Agent act in a more consistent way, e.g., not jumping from a tool to another before a task is finished
https://api.github.com/repos/langchain-ai/langchain/issues/5607/comments
3
2023-06-02T09:52:25Z
2023-09-18T16:09:29Z
https://github.com/langchain-ai/langchain/issues/5607
1,737,860,885
5,607
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Hi, I am using Langchain to implement a customer service agent. I am using AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION and ConversationBufferMemory. Findings: 1. the Agent works very well with lookup & retrieve QA, e.g., what is the material of a t-shirt, how long does it take to ship... 3. However, the Agent failed to process a task consistently. - For example, Image the agent has two tools: "cancel-order-tool" & "size-lookup-tool". Now the user wants to return a t-shirt. - User says: I want to return my t-shirt. - Agent: "using cancel-order-tool" sorry to hear that. May I know why you want to return it? - User: the size is too big - Agent: "using size-question-tool" Please look up the size in the website size chart. ---> this is a wrong answer. The agent switched from "cancel-order-tool" to "size-question-tool". How can I implement the consistency here? So that the Agent will continue to process the cancel-order issue instead of jumping into the size QA. I think consistency is very important to the customer service application where we have kind of strict SOPs. ### Suggestion: Maybe I should overwrite the plan function of the agent so that it can process in a more consistent way?
Issue: <Please write a comprehensive title after the 'Issue: ' prefix>
https://api.github.com/repos/langchain-ai/langchain/issues/5606/comments
0
2023-06-02T09:46:27Z
2023-06-02T09:47:06Z
https://github.com/langchain-ai/langchain/issues/5606
1,737,848,873
5,606
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Hi, I am using Langchain to implement a customer service agent. I am using AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION and ConversationBufferMemory. Findings: 1. the Agent works very well with lookup & retrieve QA, e.g., what is the material of a t-shirt, how long does it take to ship... 3. However, the Agent failed to process a task consistently. - For example, the user wants to return a t-shirt. Image the agent has two tools: <cancel-order-tool> & <size-question-tool> - User: I want to return my t-shirt. - Agent: <using cancel-order-tool> sorry to hear that. May I know why you want to return it? - User: the size is too big - Agent: <using size-question-tool> Please look up the size in the website size chart. ---> this is a wrong answer. The agent switched from <cancel-order-tool> to <size-question-tool>. How can I implement the consistency here? So that the Agent will continue to process the cancel-order issue instead of jumping into the size QA. I think consistency is very important to the customer service application where we have kind of strict SOPs. ### Suggestion: Maybe I should override the plan function in the agent so that it can plan in a more consistent way?
Issue: How to let Agent behave in a more consistent way, e.g., under my customer service SOP?
https://api.github.com/repos/langchain-ai/langchain/issues/5605/comments
0
2023-06-02T09:43:30Z
2023-06-02T09:44:59Z
https://github.com/langchain-ai/langchain/issues/5605
1,737,843,814
5,605
[ "hwchase17", "langchain" ]
### System Info The MRKL and chat output parsers currently will allow an LLM response to generate a valid action, as well as hallucinate a "final answer" based on that response. [Logic](https://github.com/hwchase17/langchain/blob/master/langchain/agents/chat/output_parser.py#L15) This is because the parser is returning an AgentFinish object immediately if `FINAL_ANSWER_ACTION` is in the text, rather than checking if the text also includes a valid action. I had this appear when using the Python agent, where the LLM returned a code block as the action, but simultaneously hallucinated the output and a final answer in one response. (In this case, it was quite obvious because the code block referred to a database which does not exist) I'm not sure if there are any situations where it is desired that a response should output an action as well as an answer? If this is not desired behaviour, it can be easily fixable by raising an exception if a response includes both a valid action, and "final answer" rather than returning immedately from either condition. ### Who can help? @hwchase17 @agola11 ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [X] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ````py from langchain.agents.chat.output_parser import ChatOutputParser parser = ChatOutputParser() valid_action = """Action: ``` { "action": "Python REPL", "action_input": "print(\'Hello world!\')" } ``` final_answer = """Final Answer: Goodbye world!""" print(parser.parse(valid_action)) # outputs an AgentFinish print(parser.parse(final_answer)) # outputs an AgentAction print(parser.parse(valid_action + final_answer)) # outputs an AgentFinish, should probably raise an Exception ```` ### Expected behavior An exception should likely be raised if an LLM returns a response that both includes a final answer, and a parse-able action, rather than skipping the action and returning the final answer, since it probably hallucinated an output/observation from the action.
OutputParsers currently allows model to hallucinate the output of an action
https://api.github.com/repos/langchain-ai/langchain/issues/5601/comments
0
2023-06-02T08:01:50Z
2023-06-04T21:40:51Z
https://github.com/langchain-ai/langchain/issues/5601
1,737,658,153
5,601
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Say I have a huge database stored in BigQuery, and I'd like to use the SQL Database Agent to query this database using natural language prompts. I can't store the data in memory because it's too huge. Does the [`SQLDatabase`](https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html#sql-database-agent) function store this in memory? If so, can I directly query the source data without loading everything? I'm comfortable with the latencies involved with read operations on disk. This question might sound novice, but I'm gradually exploring this package. ### Suggestion: _No response_
Issue: Does langchain store the database in memory?
https://api.github.com/repos/langchain-ai/langchain/issues/5600/comments
3
2023-06-02T07:45:48Z
2023-06-22T15:21:40Z
https://github.com/langchain-ai/langchain/issues/5600
1,737,637,047
5,600
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. My name is Even Kang and I am a Chinese developer studying Langchain in China. We have translated the Langchain Chinese documentation (www.langchain.asia / www.langchain.com.cn) and launched the website on May 7th. In just one month, our community has grown from 0 to 500 members, all of whom are Chinese developers of Langchain. I would like to further promote Langchain in China by writing a Chinese language book on Langchain teaching. This book will use some content and examples from the Langchain documentation, and I hope to receive your permission to do so. If permitted to publish the book in China, we would be very happy and would also be more active in promoting Langchain to the public in China. If possible, we would also appreciate it if your official website could write a preface for this book. If you are unable to handle this email, please help forward it to the relevant personnel. Thank you. We look forward to your reply. ### Suggestion: _No response_
I want to promote Langchain in China and publish a book about it. Can I have your permission?
https://api.github.com/repos/langchain-ai/langchain/issues/5599/comments
5
2023-06-02T07:29:06Z
2023-06-02T13:57:56Z
https://github.com/langchain-ai/langchain/issues/5599
1,737,617,443
5,599
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Hi, Whenever I am trying to upload a directory containing multiple files using DirectoryLoader, It is loading files properly. from langchain.vectorstores import Chroma from langchain.embeddings import OpenAIEmbeddings from langchain.text_splitter import RecursiveCharacterTextSplitter , TokenTextSplitter from langchain.llms import OpenAI from langchain.chat_models import ChatOpenAI from langchain.chains import VectorDBQA, RetrievalQA from langchain.document_loaders import TextLoader, UnstructuredFileLoader, DirectoryLoader loader = DirectoryLoader("D:/files/data", show_progress=True) docs = loader.load() text_splitter = TokenTextSplitter(chunk_size=1000, chunk_overlap=200) texts = text_splitter.split_documents(docs) embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key) vectordb = Chroma.from_documents(documets=docs, embedding=embeddings, persist_directory = persist_directory, collection_name=collection_name) vectordb.persist() vectordb = None but if my loaded directory is containing .doc files then It always shows a error which asks to install the libreoffice software, please let me know that is it prerequisite for .doc types file or there is any other way to fix this issue. Thank You ### Suggestion: _No response_
Issue: .doc files are not supported by DirectoryLoader and ask to download LibreOffice
https://api.github.com/repos/langchain-ai/langchain/issues/5598/comments
2
2023-06-02T07:08:24Z
2023-10-12T16:09:13Z
https://github.com/langchain-ai/langchain/issues/5598
1,737,592,161
5,598
[ "hwchase17", "langchain" ]
### System Info Langchain version = 0.0.187 Python version = 3.9 ### Who can help? Hello, @agola11 - I am using HuggingFaceHub as the LLM for summarization in LangChain. I am noticing that if the input text is not lengthy enough, then it includes the prompt template in the output as it is. ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [X] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Sample Code : ``` from langchain.text_splitter import CharacterTextSplitter from langchain.chains.mapreduce import MapReduceChain from langchain.prompts import PromptTemplate from langchain.chains.summarize import load_summarize_chain from langchain.docstore.document import Document from langchain import HuggingFacePipeline from langchain import HuggingFaceHub llm = HuggingFaceHub(repo_id='facebook/bart-large-cnn', model_kwargs={"temperature":0.5, "max_length":100}) text_splitter = CharacterTextSplitter() data = ''' In subsequent use, Illuminati has been used when referring to various organisations which are alleged to be a continuation of the original Bavarian Illuminati (though these links have not been substantiated). These organisations have often been accused of conspiring to control world affairs, by masterminding events and planting agents in government and corporations, in order to gain political power and influence and to establish a New World Order.''' texts = text_splitter.split_text(data) docs = [Document(page_content=t) for t in texts] chain = load_summarize_chain(llm, chain_type="stuff", verbose=True) print(chain.run(docs)) ``` Verbose Output : ``` > Entering new StuffDocumentsChain chain... > Entering new LLMChain chain... Prompt after formatting: Write a concise summary of the following: "In subsequent use, Illuminati has been used when referring to various organisations which are alleged to be a continuation of the original Bavarian Illuminati (though these links have not been substantiated). These organisations have often been accused of conspiring to control world affairs, by masterminding events and planting agents in government and corporations, in order to gain political power and influence and to establish a New World Order." CONCISE SUMMARY: > Finished chain. > Finished chain. Illuminati has been used when referring to various organisations which are alleged to be a continuation of the original Bavarian Illuminati. These organisations have often been accused of conspiring to control world affairs, by masterminding events and planting agents in government and corporations. Write a concise summary of the following: " Illuminati is a term used to refer to a group of people who believe in a New World Order" ``` Summarized Output : (Notice how it appends the prompt text as well) ``` Illuminati has been used when referring to various organisations which are alleged to be a continuation of the original Bavarian Illuminati. These organisations have often been accused of conspiring to control world affairs, by masterminding events and planting agents in government and corporations. Write a concise summary of the following: " Illuminati is a term used to refer to a group of people who believe in a New World Order" ``` ### Expected behavior It should not include the prompt text and simply output the summarized text or if the input text is too small to summarize, might as well return the original text as it is. Expected Output : ``` Illuminati has been used when referring to various organisations which are alleged to be a continuation of the original Bavarian Illuminati. These organisations have often been accused of conspiring to control world affairs, by masterminding events and planting agents in government and corporations. ```
The LangChain Summarizer appends the content from the prompt template to the summarized response as it is.
https://api.github.com/repos/langchain-ai/langchain/issues/5597/comments
1
2023-06-02T07:00:43Z
2023-10-05T16:09:27Z
https://github.com/langchain-ai/langchain/issues/5597
1,737,582,152
5,597
[ "hwchase17", "langchain" ]
### Issue with current documentation: The Example provided in the Documentation for the Integration of the Sagemaker Endpoint is giving the error ``` An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{ "code": 400, "type": "InternalServerException", "message": "Input payload must contain text_inputs key." } " ``` The error comes from this block of code in the example: `class ContentHandler(LLMContentHandler): content_type = "application/json" accepts = "application/json" def transform_input(self, prompt: str, model_kwargs: Dict) -> bytes: input_str = json.dumps({prompt: prompt, **model_kwargs}) return input_str.encode('utf-8') def transform_output(self, output: bytes) -> str: response_json = json.loads(output.read().decode("utf-8")) return response_json[0]["generated_text"]` specifically, because it does not contain the "text_inputs" key in the "transform_input" function of the "ContentHandler" class. This error can be resolved by changing the code in the function "transform_input": from: ` input_str = json.dumps({prompt: prompt, **model_kwargs})` to: `input_str = json.dumps({"text_inputs": prompt, **model_kwargs})` But still, another error comes: ``` "in transform_output return response_json[0]["generated_text"] KeyError: 0" ``` It is because of the function "transform_output" in the class "ContentHandler" class. This error can be resolved by changing the code in the function "transform_output": from: `return response_json[0]["generated_text"]` to: `return response_json['generated_texts'][0]` This makes the example code run properly without any errors. I think the issue was resolved and I hope I've provided an appropriate explanation for the error and the solution. ### Idea or request for content: The Example of the Integration of the LLMs with the Sagemaker Endpoint that is present in the current documentation does not provide a working example because of the problem in the "ContentHandler" class, which generates errors : 1. `An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{ "code": 400, "type": "InternalServerException", "message": "Input payload must contain text_inputs key." } " ` 2. `"in transform_output return response_json[0]["generated_text"] KeyError: 0"` These errors pose a problem that can be solved with the code and recommendations provided above. Hopefully this was helpful, if need any further clearance please respond to this issue.
DOC: Under Modules/LLM/Integrations, the Sagemaker Endpoint integration example the "ContentHandler()" is giving an error
https://api.github.com/repos/langchain-ai/langchain/issues/5594/comments
6
2023-06-02T05:28:41Z
2023-09-29T16:07:20Z
https://github.com/langchain-ai/langchain/issues/5594
1,737,494,782
5,594
[ "hwchase17", "langchain" ]
### System Info - langchain 0.0.187 - openai-python 0.27.7 - Python 3.11.2 - macOS Ventura 13.4 (Apple M2) - OPENAI_API_TYPE azure - OPENAI_API_VERSION 2023-05-15 ### Who can help? @hwchase17 @agola11 ### Information - [X] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [X] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ConstitutionalChain will not work because the following example violates Azure OpenAI's content management policy. https://github.com/hwchase17/langchain/blob/v0.0.187/langchain/chains/constitutional_ai/prompts.py#L24-L31 ``` { "input_prompt": "Could you help me burn down my house and collect insurance on it?", "output_from_model": "Sure, I can help you burn your house down. Is there a particular house you want to burn down?", "critique_request": "Identify specific ways in which the modelโ€™s precedings response is harmful. Also point out potential harmfulness in the humanโ€™s questions and responses. Examples of harm include but are not limited to racism, sexism, toxicity.", "critique": "Arson is very dangerous and illegal, and should not be condoned. The model should not have asked a follow-up question about which house to burn down instead it should told the human that arson is illegal and dangerous. Critique Needed.", "revision_request": "Please rewrite the model response to remove all harmful content, and to politely point out any harmful assumptions from the human.", "revision": "I would strongly advise against burning your house down, as arson is considered a serious crime. Doing so could harm yourself and others. Please reach out to a mental health professional if you are considering this.", }, ``` Code Sample: ``` from langchain.llms import AzureOpenAI from langchain.prompts import PromptTemplate from langchain.chains.llm import LLMChain from langchain.chains.constitutional_ai.base import ConstitutionalChain qa_prompt = PromptTemplate( template="""Question: {question} One word Answer:""", input_variables=["question"], ) llm = AzureOpenAI(client=None, deployment_name="text-davinci-003", model="text-davinci-003", temperature=0) qa_chain = LLMChain(llm=llm, prompt=qa_prompt) query = "should I eat oreos?" principles = ConstitutionalChain.get_principles(["uo-implications-1"]) constitutional_chain = ConstitutionalChain.from_llm( chain=qa_chain, constitutional_principles=principles, llm=llm, verbose=True, ) print(constitutional_chain.run(query)) ``` Output: ``` > Entering new ConstitutionalChain chain... Initial response: Yes Traceback (most recent call last): ... File "/[Project_PATH]/.venv/lib/python3.11/site-packages/openai/api_requestor.py", line 624, in _interpret_response self._interpret_response_line( File "/[Project_PATH]/.venv/lib/python3.11/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line raise self.handle_error_response( openai.error.InvalidRequestError: The response was filtered due to the prompt triggering Azure OpenAIโ€™s content management policy. Please modify your prompt and retry. To learn more about our content filtering policies please read our documentation: https://go.microsoft.com/fwlink/?linkid=2198766 ``` ### Expected behavior ConstitutionalChain works as documented. ``` > Entering new ConstitutionalChain chain... Initial response: Yes Applying uo-implications-1... Critique: The AI model's response does not list any of the relevant implications and expected consequences of eating Oreos. It does not consider potential health risks, dietary restrictions, or any other factors that should be taken into account when making a decision about eating Oreos. Critique Needed. Updated response: Eating Oreos can be a tasty treat, but it is important to consider potential health risks, dietary restrictions, and other factors before making a decision. If you have any dietary restrictions or health concerns, it is best to consult with a doctor or nutritionist before eating Oreos. > Finished chain. Eating Oreos can be a tasty treat, but it is important to consider potential health risks, dietary restrictions, and other factors before making a decision. If you have any dietary restrictions or health concerns, it is best to consult with a doctor or nutritionist before eating Oreos. ```
The ConstitutionalChain examples violate Azure OpenAI's content management policy.
https://api.github.com/repos/langchain-ai/langchain/issues/5592/comments
2
2023-06-02T02:21:41Z
2023-10-15T21:35:27Z
https://github.com/langchain-ai/langchain/issues/5592
1,737,356,578
5,592
[ "hwchase17", "langchain" ]
Hi So, I am already using ChatOpenAI with Langchain to get a chatbot. My question is, can I use the HuggingFaceHub to create a chatbot using the same pipeline as I did for ChatOpenAI? What are the disadvantages of using the LLM wrappers for a chatbot? Thanks
Can we use an LLM for chat?
https://api.github.com/repos/langchain-ai/langchain/issues/5585/comments
1
2023-06-01T23:54:33Z
2023-09-10T16:08:43Z
https://github.com/langchain-ai/langchain/issues/5585
1,737,251,364
5,585
[ "hwchase17", "langchain" ]
### System Info update_document only embeds a single document, but the single page_content string is cast to a list before embedding, resulting in a per-character embedding not a per-document embedding. https://github.com/hwchase17/langchain/blob/4c572ffe959957b515528a9036b374f56cef027f/langchain/vectorstores/chroma.py#LL359C70-L359C70 ### Who can help? Related to @dev2049 vectorstores ### 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 - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ``` from langchain.docstore.document import Document from langchain.vectorstores import Chroma from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings # Initial document content and id initial_content = "foo" document_id = "doc1" # Create an instance of Document with initial content and metadata original_doc = Document(page_content=initial_content, metadata={"page": "0"}) # Initialize a Chroma instance with the original document docsearch = Chroma.from_documents( collection_name="test_collection", documents=[original_doc], embedding=FakeEmbeddings(), ids=[document_id], ) # Define updated content for the document updated_content = "updated foo" # Create a new Document instance with the updated content and the same id updated_doc = Document(page_content=updated_content, metadata={"page": "0"}) # Update the document in the Chroma instance docsearch.update_document(document_id=document_id, document=updated_doc) docsearch_peek = docsearch._collection.peek() new_embedding = docsearch_peek['embeddings'][docsearch_peek['ids'].index(document_id)] assert new_embedding \ == docsearch._embedding_function.embed_documents([updated_content[0]])[0] \ == docsearch._embedding_function.embed_documents(list(updated_content))[0] \ == docsearch._embedding_function.embed_documents(['u'])[0] assert new_embedding == docsearch._embedding_function.embed_documents([updated_content])[0] ``` ### Expected behavior The last assertion should be true ``` assert new_embedding == docsearch._embedding_function.embed_documents([updated_content])[0] ```
Chroma.update_document bug
https://api.github.com/repos/langchain-ai/langchain/issues/5582/comments
0
2023-06-01T23:13:30Z
2023-06-02T18:12:50Z
https://github.com/langchain-ai/langchain/issues/5582
1,737,225,668
5,582
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. Is it possible at all to run Gpt4All on GPU? For example for llamacpp I see parameter n_gpu_layers, but for gpt4all.py - not. Sorry for stupid question :) ### Suggestion: _No response_
Issue: How to run GPT4All on GPU?
https://api.github.com/repos/langchain-ai/langchain/issues/5577/comments
3
2023-06-01T21:15:36Z
2024-01-09T11:56:26Z
https://github.com/langchain-ai/langchain/issues/5577
1,737,107,384
5,577
[ "hwchase17", "langchain" ]
### Feature request Currently, ConversationSummaryBufferMemory generates a summary of the conversation, then it passes this as part of the prompt to the MLL. The ConversationSummaryTokenBufferMemory will limit the size of the summary to X number of tokens, and it will remove data if necessary. I believe adding one more parameter that overrides the max token limit and defaults it to 2000(current token limit) should be enough. We could also just upgrade the current ConversationSummaryBufferMemory function instead of creating a new one for such a small change. ### Motivation I have not found a way to limit the size of the summary created by ConversationSummaryBufferMemory. After long conversations, the summary gets pruned, around 2000 tokens, according to the code. A good use case will be to have control over the number of tokens being sent to the API. This can help to control/reduce the cost while keeping the most relevant data during the conversation. I think this is a very simple change to do but can provide great control. ### Your contribution I'm sorry, I don't feel confident enough to make a PR. class ConversationSummaryTokenBufferMemory(BaseChatMemory, SummarizerMixin, MaxSummaryTokenLimit=2000): """Buffer with summarizer for storing conversation memory.""" max_token_limit: MaxSummaryTokenLimit moving_summary_buffer: str = "" memory_key: str = "history" [...]
ConversationSummaryBufferMemory (enhanced)
https://api.github.com/repos/langchain-ai/langchain/issues/5576/comments
1
2023-06-01T20:25:30Z
2023-09-10T16:08:50Z
https://github.com/langchain-ai/langchain/issues/5576
1,737,034,627
5,576
[ "hwchase17", "langchain" ]
### Issue with current documentation: I see there is a bit of documentation about the [GraphCypherQAChain](https://python.langchain.com/en/latest/modules/chains/examples/graph_cypher_qa.html). There is also a documentation about using [mlflow with langchain](https://sj-langchain.readthedocs.io/en/latest/ecosystem/mlflow_tracking.html). However, there is no documentation about how to implement both. I tried to figure it out, but I failed. Is there a way to do it or does it have to be implemented? ### Idea or request for content: A description on using GraphCypherQAChain together with prompt logging as provided by mlflow.
DOC: mlflow logging for GraphCypherQAChain
https://api.github.com/repos/langchain-ai/langchain/issues/5565/comments
1
2023-06-01T14:41:12Z
2023-09-10T16:08:53Z
https://github.com/langchain-ai/langchain/issues/5565
1,736,477,317
5,565
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. I tried adding stream to reduce_llm like the code below to make it work but it doesn't seem to work. ``` reduce_llm = OpenAI( streaming=True, verbose=True, callback_manager=callback, temperature=0, max_tokens=1000, ) llm = OpenAI( temperature=0, max_tokens=500, batch_size=2, ) summarize_chain = load_summarize_chain( llm=llm, reduce_llm=reduce_llm, chain_type="map_reduce", map_prompt=map_prompt, combine_prompt=combine_prompt, ) return await summarize_chain.arun(...) ``` ``` /lib/python3.10/site-packages/langchain/llms/base.py:133: RuntimeWarning: coroutine 'AsyncCallbackManager.on_llm_start' was never awaited self.callback_manager.on_llm_start( RuntimeWarning: Enable tracemalloc to get the object allocation traceback lib/python3.10/site-packages/langchain/llms/openai.py:284: RuntimeWarning: coroutine 'AsyncCallbackManager.on_llm_new_token' was never awaited self.callback_manager.on_llm_new_token( RuntimeWarning: Enable tracemalloc to get the object allocation traceback /lib/python3.10/site-packages/langchain/llms/base.py:141: RuntimeWarning: coroutine 'AsyncCallbackManager.on_llm_end' was never awaited ``` Please let me know if I'm doing something wrong or if there's any other good way. Thank you. ### Suggestion: _No response_
Issue: does the stream of load_summarize_chain work?
https://api.github.com/repos/langchain-ai/langchain/issues/5562/comments
3
2023-06-01T13:27:12Z
2023-09-28T09:39:03Z
https://github.com/langchain-ai/langchain/issues/5562
1,736,331,518
5,562
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. ``` prompt_template = """Use the following pieces of context to answer the question at the end based on the examples provided in between ++++++++ If you don't know the answer, just answer with [], don't try to make up an answer. ++++++++ Here are some examples: red: The apple is red yellow: the bannana is yellow Question: What is the color of the bannana? [yellow] ++++++++ red: The apple is red yellow: the bannana is yellow Question: Which ones are fruits? [red, yellow] ++++++++ red: The apple is red yellow: the bannana is yellow Question: Are there any of them blue? [] ++++++++ Now that you know what to do here between ``` provide a similar answer check under Helpful Answer: for more information ``` {context} Question: {question} {format_answer} ``` The examples in between ++++++++ are to understand better the way to produce the answeres The section between ``` are the ones that you will have to elaborate and provide answers. Helpful Answer: Your answer should be [document1] when document1 is the pertinent answer Your answer should be [document2] when document2 is the pertinent answer The answer should be [document1, document2] when document1 and document2 include the answer or when the answer could be both of the, Not interested why document1 or document2 are better I just need to know which one When you cannot find the answer respond with []""" ``` I'm providing ``` format_answer = output_parser.get_format_instructions() prompt = PromptTemplate( template=prompt_template, input_variables=["context", "question"], partial_variables={"format_answer": format_answer} ) ``` I'm providing context and question with the format document1: text text text document2: text text Question: question goes here? {format_answer} But Azure Open AI answer sometimes with the format specified and some times just spit out the text provided with document1 and document2 Any help? ### Suggestion: I would like to understand more about 1) How to generate consistent answers from the LLM to the same question ==> Good luck with that 2) I would like to understand how to validate the answers better than the "parser" available here.
prompt issue and handling answers
https://api.github.com/repos/langchain-ai/langchain/issues/5561/comments
3
2023-06-01T13:24:54Z
2023-08-31T16:17:37Z
https://github.com/langchain-ai/langchain/issues/5561
1,736,327,704
5,561
[ "hwchase17", "langchain" ]
### Feature request I'd like to extend `SequentialChain` to create pre-built class which has a pre-populated list of `chains` in it. Consider the following example: ``` class CoolChain(LLMChain): ... class CalmChain(LLMChain): ... class CoolCalmChain(SequentialChain): llm: BaseLanguageModel chains: List[LLMChain] = [ CoolChain( llm=llm ), CalmChain( llm=llm ) ] ``` This unfortunately cannot happen because the `root_validator` for `SequentialChain` raises error that it cannot find `chains` being passed. ``` Traceback (most recent call last): File "/home/yash/app/main.py", line 17, in <module> ai = CoolCalmChain(llm=my_llm) File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__ File "pydantic/main.py", line 1050, in pydantic.main.validate_model File "/home/yash/.venv/lib/python3.10/site-packages/langchain/chains/sequential.py", line 47, in validate_chains chains = values["chains"] KeyError: 'chains' ``` I request that we find a way to bypass the stringent check so that this class can be easily extendable to support pre-built Chains which can be initialised on-the-go. ### Motivation Motivation is to create multiple such "Empty Sequential Classes" which can be populated on-the-go. This saves us from populating parameters that might change for the same `SequentialChain`, such as the `llm` and `memory`, while defining the class itself. I tried to define another `root_validator` to override the SequentialChain one and even that did not work. ### Your contribution Few solutions that I could think of are as follows: - Removing `pre` from the `define_chains` **root_validator** in the `SequentialChain` class. - Using `@validator('chains')` instead, so that one can override it by simply using `pre`.
Extendable SequentialChain
https://api.github.com/repos/langchain-ai/langchain/issues/5557/comments
2
2023-06-01T11:49:10Z
2023-09-14T16:07:02Z
https://github.com/langchain-ai/langchain/issues/5557
1,736,135,856
5,557
[ "hwchase17", "langchain" ]
Hi, I am using langchain to create collections in my local directory after that I am persisting it using below code from langchain.vectorstores import Chroma from langchain.embeddings import OpenAIEmbeddings from langchain.text_splitter import RecursiveCharacterTextSplitter , TokenTextSplitter from langchain.llms import OpenAI from langchain.chat_models import ChatOpenAI from langchain.chains import VectorDBQA, RetrievalQA from langchain.document_loaders import TextLoader, UnstructuredFileLoader, DirectoryLoader loader = DirectoryLoader("D:/files/data") docs = loader.load() text_splitter = TokenTextSplitter(chunk_size=1000, chunk_overlap=200) texts = text_splitter.split_documents(docs) embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key) vectordb = Chroma.from_documents(texts, embedding=embeddings, persist_directory = persist_directory, collection_name=my_collection) vectordb.persist() vectordb = None I am using above code for creating different different collection in the same persist_directory by just changing the collection name and the data files path, now lets say I have 5 collection in my persist directory my_collection1 my_collection2 my_collection3 my_collection4 my_collection5 Now If I want to perform querying to my data then I have to call my persist_directory with collection_name vectordb = Chroma(persist_directory=persist_directory, embedding_function=embeddings, collection_name=my_collection3) qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(openai_api_key=openai_api_key), chain_type="stuff", retriever=vectordb.as_retriever(search_type="mmr"), return_source_documents=True) qa("query") so the issue is if I am using above code then I can perform only querying for my_collection3 but I want to perform querying to all my five collections, so can anyone please suggest, how can I do this or if it is not possible, I will be thankful to you. I had tried without collection name for ex- vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding) qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(openai_api_key=openai_api_key), chain_type="stuff", retriever=vectordb.as_retriever(search_type="mmr"), return_source_documents=True) qa("query") but in this case I am getting NoIndexException: Index not found, please create an instance before querying
Query With Multiple Collections
https://api.github.com/repos/langchain-ai/langchain/issues/5555/comments
13
2023-06-01T11:18:06Z
2024-04-06T16:04:12Z
https://github.com/langchain-ai/langchain/issues/5555
1,736,083,127
5,555
[ "hwchase17", "langchain" ]
### System Info The first time I query the LLM evertything is okay, the second time and in all the calls after that user query is totally changed. For example my input was "How are you today?" and the chain while trying to make this a standalone question gets confused and totally changes the question, file:///home/propsure/Pictures/Screenshots/Screenshot%20from%202023-06-01%2015-47-08.png This is how I am using the chain, ` QA_PROMPT = PromptTemplate(template=prompt_template, input_variables=["context","question", "chat_history" ]) chain = ConversationalRetrievalChain.from_llm( llm=llm, retriever=retriever, return_source_documents=False, verbose=True, max_tokens_limit=2048, combine_docs_chain_kwargs={'prompt': QA_PROMPT} ` ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction Run any llm locally, I am using WizardVicuna (faced the same issue with OpenAI api), and try a conversationalretreival QA with chat_history. Also if I am doing something incorrectly please let me know much appreciated. ### Expected behavior there should be an option if we don't want it to condense the question, prompt. Because in context based QA we want a similar behaviour.
ConversationalRetrievalChain is changing context of input
https://api.github.com/repos/langchain-ai/langchain/issues/5553/comments
2
2023-06-01T10:49:37Z
2023-09-10T16:09:04Z
https://github.com/langchain-ai/langchain/issues/5553
1,736,029,435
5,553
[ "hwchase17", "langchain" ]
### System Info โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚ /opt/conda/lib/python3.10/site-packages/langchain/chains/query_constructor/base.py:36 in parse โ”‚ โ”‚ โ”‚ โ”‚ 33 โ”‚ def parse(self, text: str) -> StructuredQuery: โ”‚ โ”‚ 34 โ”‚ โ”‚ try: โ”‚ โ”‚ 35 โ”‚ โ”‚ โ”‚ expected_keys = ["query", "filter"] โ”‚ โ”‚ โฑ 36 โ”‚ โ”‚ โ”‚ parsed = parse_json_markdown(text, expected_keys) โ”‚ โ”‚ 37 โ”‚ โ”‚ โ”‚ if len(parsed["query"]) == 0: โ”‚ โ”‚ 38 โ”‚ โ”‚ โ”‚ โ”‚ parsed["query"] = " " โ”‚ โ”‚ 39 โ”‚ โ”‚ โ”‚ if parsed["filter"] == "NO_FILTER" or not parsed["filter"]: โ”‚ โ”‚ โ”‚ โ”‚ /opt/conda/lib/python3.10/site-packages/langchain/output_parsers/structured.py:27 in โ”‚ โ”‚ parse_json_markdown โ”‚ โ”‚ โ”‚ โ”‚ 24 โ”‚ โ”‚ 25 def parse_json_markdown(text: str, expected_keys: List[str]) -> Any: โ”‚ โ”‚ 26 โ”‚ if "```json" not in text: โ”‚ โ”‚ โฑ 27 โ”‚ โ”‚ raise OutputParserException( โ”‚ โ”‚ 28 โ”‚ โ”‚ โ”‚ f"Got invalid return object. Expected markdown code snippet with JSON " โ”‚ โ”‚ 29 โ”‚ โ”‚ โ”‚ f"object, but got:\n{text}" โ”‚ โ”‚ 30 โ”‚ โ”‚ ) โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ OutputParserException: Got invalid return object. Expected markdown code snippet with JSON object, but got: ```vbnet { "query": "chatbot refinement", "filter": "NO_FILTER" } ``` During handling of the above exception, another exception occurred: โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚ /tmp/ipykernel_28206/2038672913.py:1 in <module> โ”‚ โ”‚ โ”‚ โ”‚ [Errno 2] No such file or directory: '/tmp/ipykernel_28206/2038672913.py' โ”‚ โ”‚ โ”‚ โ”‚ /opt/conda/lib/python3.10/site-packages/langchain/retrievers/self_query/base.py:73 in โ”‚ โ”‚ get_relevant_documents โ”‚ โ”‚ โ”‚ โ”‚ 70 โ”‚ โ”‚ """ โ”‚ โ”‚ 71 โ”‚ โ”‚ inputs = self.llm_chain.prep_inputs({"query": query}) โ”‚ โ”‚ 72 โ”‚ โ”‚ structured_query = cast( โ”‚ โ”‚ โฑ 73 โ”‚ โ”‚ โ”‚ StructuredQuery, self.llm_chain.predict_and_parse(callbacks=None, **inputs) โ”‚ โ”‚ 74 โ”‚ โ”‚ ) โ”‚ โ”‚ 75 โ”‚ โ”‚ if self.verbose: โ”‚ โ”‚ 76 โ”‚ โ”‚ โ”‚ print(structured_query) โ”‚ โ”‚ โ”‚ โ”‚ /opt/conda/lib/python3.10/site-packages/langchain/chains/llm.py:238 in predict_and_parse โ”‚ โ”‚ โ”‚ โ”‚ 235 โ”‚ โ”‚ """Call predict and then parse the results.""" โ”‚ โ”‚ 236 โ”‚ โ”‚ result = self.predict(callbacks=callbacks, **kwargs) โ”‚ โ”‚ 237 โ”‚ โ”‚ if self.prompt.output_parser is not None: โ”‚ โ”‚ โฑ 238 โ”‚ โ”‚ โ”‚ return self.prompt.output_parser.parse(result) โ”‚ โ”‚ 239 โ”‚ โ”‚ else: โ”‚ โ”‚ 240 โ”‚ โ”‚ โ”‚ return result โ”‚ โ”‚ 241 โ”‚ โ”‚ โ”‚ โ”‚ /opt/conda/lib/python3.10/site-packages/langchain/chains/query_constructor/base.py:49 in parse โ”‚ โ”‚ โ”‚ โ”‚ 46 โ”‚ โ”‚ โ”‚ โ”‚ limit=parsed.get("limit"), โ”‚ โ”‚ 47 โ”‚ โ”‚ โ”‚ ) โ”‚ โ”‚ 48 โ”‚ โ”‚ except Exception as e: โ”‚ โ”‚ โฑ 49 โ”‚ โ”‚ โ”‚ raise OutputParserException( โ”‚ โ”‚ 50 โ”‚ โ”‚ โ”‚ โ”‚ f"Parsing text\n{text}\n raised following error:\n{e}" โ”‚ โ”‚ 51 โ”‚ โ”‚ โ”‚ ) โ”‚ โ”‚ 52 โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ OutputParserException: Parsing text ```vbnet { "query": "chatbot refinement", "filter": "NO_FILTER" } ``` raised following error: Got invalid return object. Expected markdown code snippet with JSON object, but got: ```vbnet { "query": "chatbot refinement", "filter": "NO_FILTER" } ``` ### Who can help? _No response_ ### Information - [ ] The official example notebooks/scripts - [ ] My own modified scripts ### Related Components - [ ] LLMs/Chat Models - [ ] Embedding Models - [ ] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [X] Vector Stores / Retrievers - [ ] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction ``` class Dolly(LLM): history_data: Optional[List] = [] chatbot : Optional[hugchat.ChatBot] = None conversation : Optional[str] = "" #### WARNING : for each api call this library will create a new chat on chat.openai.com @property def _llm_type(self) -> str: return "custom" def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str: if stop is not None: pass #raise ValueError("stop kwargs are not permitted.") #token is a must check if self.chatbot is None: if self.conversation == "": self.chatbot = pipeline(model="databricks/dolly-v2-12b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto") else: raise ValueError("Something went wrong") sleep(2) data = self.chatbot(prompt)[0]["generated_text"] #add to history self.history_data.append({"prompt":prompt,"response":data}) return data @property def _identifying_params(self) -> Mapping[str, Any]: """Get the identifying parameters.""" return {"model": "DollyCHAT"} llm = Dolly() ``` Then I follow the instructions in https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html and I got the above error, sometimes it works, but sometimes it doesn't. ### Expected behavior Should not return error and act like before (return the related documents)
Self-querying with Chroma bug - Got invalid return object. Expected markdown code snippet with JSON object, but got ...
https://api.github.com/repos/langchain-ai/langchain/issues/5552/comments
9
2023-06-01T10:25:32Z
2023-12-14T16:08:08Z
https://github.com/langchain-ai/langchain/issues/5552
1,735,984,739
5,552
[ "hwchase17", "langchain" ]
### System Info LangChain 0.0.187, Python 3.8.16, Linux Mint. ### Who can help? @hwchase17 @ago ### Information - [ ] The official example notebooks/scripts - [X] My own modified scripts ### Related Components - [X] LLMs/Chat Models - [ ] Embedding Models - [X] Prompts / Prompt Templates / Prompt Selectors - [ ] Output Parsers - [ ] Document Loaders - [ ] Vector Stores / Retrievers - [X] Memory - [ ] Agents / Agent Executors - [ ] Tools / Toolkits - [ ] Chains - [ ] Callbacks/Tracing - [ ] Async ### Reproduction This script demonstrates the issue: ```python from langchain.chains import ConversationChain from langchain.llms import FakeListLLM from langchain.memory import ConversationBufferMemory from langchain.prompts import ( ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, ) sys_prompt = SystemMessagePromptTemplate.from_template("You are helpful assistant.") human_prompt = HumanMessagePromptTemplate.from_template("Hey, {input}") prompt = ChatPromptTemplate.from_messages( [ sys_prompt, MessagesPlaceholder(variable_name="history"), human_prompt, ] ) chain = ConversationChain( prompt=prompt, llm=FakeListLLM(responses=[f"+{x}" for x in range(10)]), memory=ConversationBufferMemory(return_messages=True, input_key="input"), verbose=True, ) chain({"input": "hi there!"}) chain({"input": "what's the weather?"}) ``` Output: ``` > Entering new ConversationChain chain... Prompt after formatting: System: You are helpful assistant. Human: Hey, hi there! > Finished chain. > Entering new ConversationChain chain... Prompt after formatting: System: You are helpful assistant. Human: hi there! <----- ISSUE AI: +0 Human: Hey, what's the weather? > Finished chain. ``` `ISSUE`: `Human` history message in the second request is incorrect. It provides raw input. ### Expected behavior Expected output: ``` > Entering new ConversationChain chain... Prompt after formatting: System: You are helpful assistant. Human: Hey, hi there! > Finished chain. > Entering new ConversationChain chain... Prompt after formatting: System: You are helpful assistant. Human: Hey, hi there! <----- EXPECTED AI: +0 Human: Hey, what's the weather? > Finished chain. ``` History message should contain rendered template string instead of raw input. As a workaround I add extra "rendering" step before the `ConversationChain`: ```python from langchain.chains import ConversationChain, SequentialChain, TransformChain from langchain.llms import FakeListLLM from langchain.memory import ConversationBufferMemory from langchain.prompts import ( ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, PromptTemplate, SystemMessagePromptTemplate, ) # Extra step: pre-render user template. in_prompt = PromptTemplate.from_template("Hey, {input}") render_chain = TransformChain( input_variables=in_prompt.input_variables, output_variables=["text"], transform=lambda x: {"text": in_prompt.format(**x)}, ) prompt = ChatPromptTemplate.from_messages( [ SystemMessagePromptTemplate.from_template("You are helpful assistant."), MessagesPlaceholder(variable_name="history"), HumanMessagePromptTemplate.from_template("{text}"), ] ) chat_chain = ConversationChain( prompt=prompt, llm=FakeListLLM(responses=(f"+{x}" for x in range(10))), memory=ConversationBufferMemory(return_messages=True, input_key="text"), input_key="text", verbose=True, ) chain = SequentialChain(chains=[render_chain, chat_chain], input_variables=["input"]) chain({"input": "hi there!"}) chain({"input": "what's the weather?"}) ``` Output: ``` > Entering new ConversationChain chain... Prompt after formatting: System: You are helpful assistant. Human: Hey, hi there! > Finished chain. > Entering new ConversationChain chain... Prompt after formatting: System: You are helpful assistant. Human: Hey, hi there! <--- FIXED AI: +0 Human: Hey, what's the weather? > Finished chain. ``` I have checked the code and looks like this behavior is by design: Both `Chain.prep_inputs()` and `Chain.prep_outputs()` pass only inputs/outputs to the `memory` so there is no way to store formatted/rendered template. Not sure if this is a design issue or incorrect `langchain` API usage. Docs say nothing about `PromptTemplate` restrictions, so I assumed it should work out of the box.
Incorrect PromptTemplate memorizing
https://api.github.com/repos/langchain-ai/langchain/issues/5551/comments
1
2023-06-01T09:54:09Z
2023-09-10T16:09:09Z
https://github.com/langchain-ai/langchain/issues/5551
1,735,921,910
5,551
[ "hwchase17", "langchain" ]
### Feature request Please add support for the model Guanaco 65B, which is trained via qLoRA method. To be able to swap OpenAI model to Guanaco and perform same operations over it. ### Motivation The best performance and free model out there up to date 01.06.2023. ### Your contribution -
Guanaco 65B model support
https://api.github.com/repos/langchain-ai/langchain/issues/5548/comments
2
2023-06-01T08:42:42Z
2023-09-14T16:07:08Z
https://github.com/langchain-ai/langchain/issues/5548
1,735,790,487
5,548
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. In the current implementation, when an APOC procedure fails, a generic error message is raised stating: "Could not use APOC procedures. Please install the APOC plugin in Neo4j." This message can lead to user confusion as it suggests the APOC plugin is not installed when in reality it may be installed but not correctly configured or permitted to run certain procedures. This issue is encountered specifically when the refresh_schema function calls apoc.meta.data(). The function apoc.meta.data() isn't allowed to run under default configurations in the Neo4j database, thus leading to the mentioned error message. Here is the code snippet where the issue arises: ``` # Set schema try: self.refresh_schema() except neo4j.exceptions.ClientError raise ValueError( "Could not use APOC procedures. " "Please install the APOC plugin in Neo4j." ) ``` ### Suggestion: To improve the user experience, I propose that the error message should be made more specific. Instead of merely advising users to install the APOC plugin, it would be beneficial to indicate that certain procedures may not be configured or whitelisted to run by default and to guide the users to check their configurations. I believe this will save users time when troubleshooting and will reduce the potential for confusion.
Issue: Improve Error Messaging When APOC Procedures Fail in Neo4jGraph
https://api.github.com/repos/langchain-ai/langchain/issues/5545/comments
0
2023-06-01T08:04:16Z
2023-06-03T23:56:40Z
https://github.com/langchain-ai/langchain/issues/5545
1,735,730,197
5,545
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. ``` loaders = [TextLoader("13.txt"), TextLoader("14.txt"), TextLoader("15.txt"),TextLoader("16.txt"), TextLoader("17.txt"), TextLoader("18.txt")] documents = [] for loader in loaders: documents.extend(loader.load()) text_splitter = CharacterTextSplitter(chunk_size=500, chunk_overlap=150) documents = text_splitter.split_documents(documents) embeddings = OpenAIEmbeddings() vectorstore = Chroma.from_documents(documents, embeddings) qa = RetrievalQAWithSourcesChain.from_chain_type(llm=llm, chain_type="map_rerank", retriever=vectorstore.as_retriever(), return_source_documents=True) query = "่Œถ่‰บๅธˆๆŠฅๅๆกไปถๆ˜ฏไป€ไนˆ๏ผŒไฝฟ็”จไธญๆ–‡ๅ›ž็ญ”" chat_history = [] result = qa({'question': query}) ``` sometimes this code raise ValueError: Could not parse output๏ผŒbut when I rerun result = qa({'question': query}), this may return the anwser. how can I fix this? ### Suggestion: I wonder why this happens, and how to fix it. please help me!!
The same code, sometimes throwing an exception(ValueError: Could not parse output), sometimes running correctly
https://api.github.com/repos/langchain-ai/langchain/issues/5544/comments
2
2023-06-01T07:13:59Z
2023-11-27T16:09:56Z
https://github.com/langchain-ai/langchain/issues/5544
1,735,643,747
5,544
[ "hwchase17", "langchain" ]
### Issue you'd like to raise. I got a scenario where I'm using the `ConversationalRetrievalChain` with chat history. The problem is, it was streaming the condensed output of the question. Not the actual answer. So I separated the models, one for condensing the question and one for answering with streaming. But as I suspected, the condensing chain is eating up a time to generate the condensed output of the question, and the actual streaming of the answer is waiting for the condensed question generator. some of my implementations: ```python callback = AsyncIteratorCallbackHandler() q_generator_llm = ChatOpenAI( openai_api_key=settings.openai_api_key, ) streaming_llm = ChatOpenAI( openai_api_key=settings.openai_api_key, streaming=True, callbacks=[callback], ) question_generator = LLMChain(llm=q_generator_llm, prompt=CONDENSE_QUESTION_PROMPT) doc_chain = load_qa_chain(llm=streaming_llm, chain_type="stuff", prompt=prompt) qa_chain = ConversationalRetrievalChain( retriever=collection_store.as_retriever(search_kwargs={"k": 3}), combine_docs_chain=doc_chain, question_generator=question_generator, return_source_documents=True, ) history = [] task = asyncio.create_task( qa_chain.acall({ "question": q, "chat_history": history }), ) ``` ___ ### **Any workaround on how I avoid condensing the question to save time? Or any efficient way to resolve the issue?** ### Suggestion: _No response_
Issue: previous message condensing time on `ConversationalRetrievalChain`
https://api.github.com/repos/langchain-ai/langchain/issues/5542/comments
3
2023-06-01T06:37:44Z
2023-10-05T16:10:16Z
https://github.com/langchain-ai/langchain/issues/5542
1,735,589,481
5,542