delayedkarma/langchain-issues huggingface dataset:
GraphCypherQAChain Unhandled Exception while running Erroneous Cypher Queries
Labels: name: auto:bug, name: auto:improvement

https://github.com/langchain-ai/langchain/blob/76905aa043e3e604b5b34faf5e91d0aedb5ed6dd/libs/langchain/langchain/chains/graph_qa/cypher.py#L266C2-L269C25

Hi, I am heavily using GraphCypherQAChain and sometimes cypher_query_corrector returns generated cypher as valid but have some syntax problems or completely it is not a cypher query; and during the execution of the neo4j, it raises errors. Where do you think that these errors should be handled, how to continue the chain execution without any interruption and return a plausible response to the user? @tomasonjo 

Example: 
<img width="1104" alt="image" src="https://github.com/langchain-ai/langchain/assets/9192832/0cac12a9-0a4c-4446-af30-2f54ac3290c8">


Thanks!
passing down vectorstore additional argument in SemanticSimilarityExampleSelector
Labels: name: area: vector store, name: auto:improvement

### Feature request

Currently, SemanticSimilarityExampleSelector only passes `k` as a parameter to vectorstore [see here](https://github.com/langchain-ai/langchain/blob/76905aa043e3e604b5b34faf5e91d0aedb5ed6dd/libs/core/langchain_core/example_selectors/semantic_similarity.py#L55C10-L55C10). vectorstore, depending on the implementation can take multiple other arguments. most notably, `filters` can be passed down [see here](https://github.com/langchain-ai/langchain/blob/76905aa043e3e604b5b34faf5e91d0aedb5ed6dd/libs/community/langchain_community/vectorstores/faiss.py#L505C13-L507C38)

### Motivation

Having the ability to filter down examples (on top of similarity search) would be very helpful in controlling the examples that are added to the prompt. This feature provides significant more control over examples selection. 

### Your contribution

It is very easy to update this. add a new attribute `vectorstore_kwargs` to the class 
    
    class SemanticSimilarityExampleSelector(BaseExampleSelector, BaseModel):
       """Example selector that selects examples based on SemanticSimilarity."""

       vectorstore: VectorStore
       """VectorStore than contains information about examples."""
       k: int = 4
       """Number of examples to select."""
       example_keys: Optional[List[str]] = None
       """Optional keys to filter examples to."""
       input_keys: Optional[List[str]] = None
       """Optional keys to filter input to. If provided, the search is based on
       the input variables instead of all variables."""
       vectorstore_kwargs: Optional[Dict[str, Any]] = None
        """additional arguments passed to vectorstore for similarity search."""

and then update the `select_examples` function with 

`example_docs = self.vectorstore.similarity_search(query, k=self.k, **self.vectorstore_kwargs)`
Fixes and Upgrades for the Tongyi LLM and ChatTongyi Model
Labels: name: auto:improvement, name: area: models, name: size:XL

 - **Description:** fixes and upgrades for the Tongyi LLM and ChatTongyi Model
      - Fixed typos; it should be `Tongyi`, not `OpenAI`.
      - Fixed a bug in `stream_generate_with_retry`; it's a real stream generator now.
      - Fixed a bug in `validate_environment`; the `dashscope_api_key` should be properly handled when set by environment variables or initialization parameters.
      - Changed the `dashscope` response to incremental output by setting the parameter `incremental_output`, which eliminates the need for the prefix-removal trick.
      - Removed some unused parameters, like `n`, `prefix_messages`.
      - Added `_stream` method.
      - Added async methods support, such as `_astream`, `_agenerate`, `_abatch`.
  - **Dependencies:** No new dependencies.
  - **Tag maintainer:** @baskaryan 

> PS: Some may be confused about the terms `dashscope`, `tongyi`, and `Qwen`:
> - `dashscope`: A platform to deploy LLMs and provide APIs to invoke the LLM.
> - `tongyi`: A brand name or overall term about Alibaba Cloud's LLM/AI.
> - `Qwen`: An LLM that is open-sourced and deployed in `dashscope`.
> 
> We use the `dashscope` SDK to interact with the `tongyi`-`Qwen` LLM.
RetrievalQA and AzureOpenAIEmbeddings lead to TypeError: cannot pickle '_thread.lock' object
Labels: name: area: embeddings, name: area: vector store, name: auto:bug, name: integration: chroma

### System Info

python = "^3.10"
openai = "^1.3.8"
langchain = "^0.0.349"

### Who can help?

_No response_

### 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
````
import chromadb
from langchain.embeddings import AzureOpenAIEmbeddings
from langchain.vectorstores.chroma import Chroma
client = chromadb.HttpClient(
    host=CHROMA_SERVER_HOST,
    port=CHROMA_SERVER_HTTP_PORT,
)
embeddings = AzureOpenAIEmbeddings(
    openai_api_type=AZURE_OPENAI_API_TYPE,
    azure_endpoint=AZURE_OPENAI_API_BASE,
    api_key=AZURE_OPENAI_API_KEY,
    openai_api_version=AZURE_OPENAI_API_VERSION,
    azure_deployment=AZURE_EMBEDDING_DEPLOYMENT_NAME,
)

vectordb = Chroma(
    client=client,
    collection_name=CHROMA_COLLECTION_NAME_FBIG_1000,
    embedding_function=embeddings,
)
````

### Expected behavior

TypeError: cannot pickle '_thread.RLock' object
When I use openai = "0.28.1" it doesn't have the above error
An output parsing error occurred. Could not parse LLM output create_csv_agent
Labels: name: area: agent, name: auto:bug

### System Info

Ubuntu 20.04
CUDA 12.1
NVIDIA RTX 4070 


### Who can help?

@hwchase17 
@eyurtsev 

### Information

- [X] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.chains import LLMChain
from langchain.llms import LlamaCpp
from langchain.prompts import PromptTemplate

template = """Question: {question} Answer: Your Answer"""
prompt = PromptTemplate(template=template, input_variables=["question"])
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
n_gpu_layers = 80  # Change this value based on your model and your GPU VRAM pool.
n_batch = 512  # Should be between 1 and n_ctx, consider the amount of VRAM in your GPU.llm = LlamaCpp(model_path="/home/rtx-4070/Downloads/openorca-platypus2-13b.Q4_K_M.gguf",
                n_gpu_layers=n_gpu_layers,
                n_batch=n_batch,
                callback_manager=callback_manager,
                verbose=True,
               n_ctx=2048
                )
from langchain_experimental.agents.agent_toolkits import create_csv_agent
from langchain.agents.agent_types import AgentType
agent = create_csv_agent(
    llm,
    "/home/rtx-4070/git_brainyneurals/langchain_local/docs/SPY.csv",
    verbose=True,
    agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    handle_parsing_errors=True
)
agent.run("How many rows are there?")
```
I am running opeorca model which I have downloaded from HuggingFace. But I am facing this erros. Could you please help me with related solutions? Or Suggest any other ways or models. Would be grateful.

Thanks in advance. 

### Expected behavior

I want to make work simple csv agent that runs on my RTX 4070 Desktop GPU with any open source models.
create mypy cache dir if it doesn't exist
Labels: name: lgtm, name: auto:nit, name: size:XS

### Description

When running `make lint` multiple times, i can see the error `mkdir: .mypy_cache: File exists`. Use `mkdir -p` to solve this problem.
<img width="1512" alt="Screenshot 2023-12-12 at 11 22 01 AM" src="https://github.com/langchain-ai/langchain/assets/10000925/1429383d-3283-4e22-8882-5693bc50b502">
Fix embeddings example for Databricks
Labels: name: area: embeddings, name: auto:documentation, name: size:XS

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->

Fix `from langchain.llms import DatabricksEmbeddings` to `from langchain.embeddings import DatabricksEmbeddings`.
docs[patch], templates[patch]: Import from core
Labels: name: auto:refactor, name: area: models, name: size:L

Update imports to use core for the low-hanging fruit changes. Ran following

```bash
git grep -l 'langchain.schema.runnable' {docs,templates,cookbook}  | xargs sed -i '' 's/langchain\.schema\.runnable/langchain_core.runnables/g'
git grep -l 'langchain.schema.output_parser' {docs,templates,cookbook} | xargs sed -i '' 's/langchain\.schema\.output_parser/langchain_core.output_parsers/g'
git grep -l 'langchain.schema.messages' {docs,templates,cookbook} | xargs sed -i '' 's/langchain\.schema\.messages/langchain_core.messages/g'
git grep -l 'langchain.schema.chat_histry' {docs,templates,cookbook} | xargs sed -i '' 's/langchain\.schema\.chat_history/langchain_core.chat_history/g'
git grep -l 'langchain.schema.prompt_template' {docs,templates,cookbook} | xargs sed -i '' 's/langchain\.schema\.prompt_template/langchain_core.prompts/g'
git grep -l 'from langchain.pydantic_v1' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.pydantic_v1/from langchain_core.pydantic_v1/g'
git grep -l 'from langchain.tools.base' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.tools\.base/from langchain_core.tools/g'
git grep -l 'from langchain.chat_models.base' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.chat_models.base/from langchain_core.language_models.chat_models/g'
git grep -l 'from langchain.llms.base' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.llms\.base\ /from langchain_core.language_models.llms\ /g'
git grep -l 'from langchain.embeddings.base' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.embeddings\.base/from langchain_core.embeddings/g'
git grep -l 'from langchain.vectorstores.base' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.vectorstores\.base/from langchain_core.vectorstores/g'
git grep -l 'from langchain.agents.tools' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.agents\.tools/from langchain_core.tools/g'
git grep -l 'from langchain.schema.output' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.schema\.output\ /from langchain_core.outputs\ /g'
git grep -l 'from langchain.schema.embeddings' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.schema\.embeddings/from langchain_core.embeddings/g'
git grep -l 'from langchain.schema.document' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.schema\.document/from langchain_core.documents/g'
git grep -l 'from langchain.schema.agent' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.schema\.agent/from langchain_core.agents/g'
git grep -l 'from langchain.schema.prompt ' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.schema\.prompt\ /from langchain_core.prompt_values /g'
git grep -l 'from langchain.schema.language_model' {docs,templates,cookbook} | xargs sed -i '' 's/from langchain\.schema\.language_model/from langchain_core.language_models/g'


```
fix: to rag-semi-structured template
Labels: name: lgtm, name: auto:nit, name: area: models, name: size:S

**Description:** 

Fixes to rag-semi-structured template.

- Added required libraries
- pdfminer was causing issues when installing with pip. pdfminer.six works best
- Changed the pdf name for demo from llama2 to llava


<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Predibase TypeError: LlmMixin.prompt() got an unexpected keyword argument 'model_name'
Labels: name: auto:bug, name: area: models

### System Info

Lanchain: 0.0.348
Python 3.12.0

### Who can help?

@hwchase17 
@agola11

### Information

- [X] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Steps to reproduce the error:

1. Run the [notebook](https://github.com/langchain-ai/langchain/blob/master/docs/docs/integrations/llms/predibase.ipynb) with the latest version of Langchain. The error occurs specficially in 13 `review = overall_chain.run("Tragedy at sunset on the beach")`

### Expected behavior

The expected behavior is simply to return the output from the LLM.
feat: adding paygo api support for Azure ML / Azure AI Studio
Labels: name: lgtm, name: auto:enhancement, name: area: models, name: size:XL

- **Description:** Introducing support for LLMs and Chat models running in Azure AI studio and Azure ML using the new deployment mode pay-as-you-go (model as a service).
- **Issue:** NA
- **Dependencies:** None.
- **Tag maintainer:** @prakharg-msft @gdyre 
- **Twitter handle:** @santiagofacundo

Examples added:
* [docs/docs/integrations/llms/azure_ml.ipynb](https://github.com/santiagxf/langchain/blob/santiagxf/azureml-endpoints-paygo-community/docs/docs/integrations/chat/azureml_endpoint.ipynb)
* [docs/docs/integrations/chat/azureml_chat_endpoint.ipynb](https://github.com/santiagxf/langchain/blob/santiagxf/azureml-endpoints-paygo-community/docs/docs/integrations/chat/azureml_chat_endpoint.ipynb)
Issue: Problem when using model llama2 13b chat to create SQL queries in 2 or more tables, it mixes the columns of the tables
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

Hi,
I have this issue when working with more than 1 table using the Llama2 model. Let's say table 1 has values A, B, C, and table 2 has values X, Y, Z. When I run the query, it often gives me an error that it creates the query but assumes that table 1 has values X, Y, Z, and it mixes them up. Any suggestions on how to avoid this? I'm trying to solve it with prompts, but the model seems to ignore instructions in these cases.

### Suggestion:

_No response_
GithubAPIWrapper throws list index out of range error
Labels: name: area: agent, name: auto:bug

### System Info

Name: langchain
Version: 0.0.348

Name: PyGithub
Version: 2.1.1

### Who can help?
@hwchase17 
@agola11 
``` 
Traceback (most recent call last):
  File "/Users/mac/Dev Projects/Chainlit_qa/test.py", line 12, in <module>
    github = GitHubAPIWrapper(
             ^^^^^^^^^^^^^^^^^
  File "/Users/mac/Dev Projects/Chainlit_qa/myenv/lib/python3.11/site-packages/pydantic/v1/main.py", line 339, in __init__
    values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mac/Dev Projects/Chainlit_qa/myenv/lib/python3.11/site-packages/pydantic/v1/main.py", line 1102, in validate_model
    values = validator(cls_, values)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mac/Dev Projects/Chainlit_qa/myenv/lib/python3.11/site-packages/langchain/utilities/github.py", line 69, in validate_environment
    installation = gi.get_installations()[0]
                   ~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/Users/mac/Dev Projects/Chainlit_qa/myenv/lib/python3.11/site-packages/github/PaginatedList.py", line 62, in __getitem__
    return self.__elements[index]
           ~~~~~~~~~~~~~~~^^^^^^^
IndexError: list index out of range
```

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Run basic python file:

```
from langchain.agents.agent_toolkits.github.toolkit import GitHubToolkit
from langchain.utilities.github import GitHubAPIWrapper

github = GitHubAPIWrapper()
toolkit = GitHubToolkit.from_github_api_wrapper(github)
tools = toolkit.get_tools()

```

### Expected behavior

Fetching github repository information
`ChatVertexAI` preserving original response
Labels: name: auto:improvement, name: area: models, name: size:M

Closes https://github.com/langchain-ai/langchain/issues/14548 by enabling something like this:

```python
model: ChatVertexAI

chat_generation = model.generate([prompt.format_messages()]).generations[0][0]
grounding_metadata = chat_generation.generation_info["grounding_metadata"]
```
Request: `ChatVertexAI` preserving `grounding_metadata`
Labels: name: auto:improvement, name: area: models

### Feature request

As of `langchain==0.0.348` in [`ChatVertexAI` here](https://github.com/langchain-ai/langchain/blob/v0.0.348/libs/langchain/langchain/chat_models/vertexai.py#L187-L191):

1. `vertexai.language_models.ChatSession.send_message` returns a `vertexai.language_models.MultiCandidateTextGenerationResponse` response
2. `ChatVertexAI` throws out the response's `grounding_metadata`, only preserving the `text`

The request is to not discard this useful metadata

### Motivation

I am trying to use the `response.grounding_metadata.citations` in my own code

### Your contribution

I will open a PR to make this:

```python
generations = [
    ChatGeneration(
        message=AIMessage(content=r.text),
        generation_info=r.raw_prediction_response,
    )
    for r in response.candidates
]
```

So the raw response remains accessible
Does HTML Doc Loader accept .htm sites?
Labels: name: area: doc loader, name: auto:bug

### System Info

Langchain 0.0.331, macOS Monterey, Python 3.10.9

### 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 UnstructuredHTMLLoader
 
loader = UnstructuredHTMLLoader("https://www.sec.gov/ix?doc=/Archives/edgar/data/40987/000004098720000010/gpc-12312019x10k.htm")
documents = loader.load()
 
FileNotFoundError: [Errno 2] No such file or directory: 'https://www.sec.gov/ix?doc=/Archives/edgar/data/40987/000004098720000010/gpc-12312019x10k.htm

### Expected behavior

Success loading .htm file
deprecating tql_query parameter in deeplake vectorstore
Labels: name: area: vector store, name: auto:improvement, name: size:L

Description: 

Deprecating tql_query parameter and fixing deeplake tests

Issue: 

previously we used to use `tql_query` as a parameter to specify tql query during the search. But later we decided to change that to `tql`. In the PR we are adding deprecation warning as well as, fixing some failing tests and adding the check during search to check for unsupported parameters.


<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Fix duplication of query embedding for OpenSearch MMR
Labels: name: area: vector store, name: auto:bug, name: size:S

  - **Description:** Currently, any time query is being embedded, it is being embedded twice. This is unecessary and expensive. This PR addresses this by embedding the query only do once and passing the existing embedding to _raw_similarity_search_with_score.
  - **Issue:** Haven't created one,
  - **Dependencies:** None
Adds progress bar to VertexAIEmbeddings
Labels: name: area: embeddings, name: auto:improvement, name: size:S

  - **Description:** Adds progress bar to VertexAIEmbeddings 
  - **Issue:** related issue https://github.com/langchain-ai/langchain/issues/13637

Signed-off-by: ugm2 <unaigaraymaestre@gmail.com>
fix a bug in RedisNum filter againt value 0
Labels: name: area: vector store, name: auto:bug, name: integration: redis, name: size:XS


  - **Description:** There is a bug in RedisNum filter that filter towards value 0 will be parsed as "*". This is a fix to it.
  - **Issue:** N/A
  - **Dependencies:** N/A
  - **Tag maintainer:** N/A
  - **Twitter handle:** N/A