delayedkarma/langchain-issues huggingface dataset:
fix(minor): added missing **kwargs parameter to chroma query function
Labels: name: lgtm, name: area: vector store, name: auto:improvement, name: integration: chroma, name: size:XS

**Description:**

This PR adds the `**kwargs` parameter to six calls in the `chroma.py` package. All functions already were able to receive `kwargs` but they were discarded before.

**Issue:**

When passing `kwargs` to functions in the `chroma.py` package they are being ignored.

For example:

```
chroma_instance.similarity_search_with_score(
    query,
    k=100,
    include=["metadatas", "documents", "distances", "embeddings"],  # this parameter gets ignored
)
```
The `include` parameter does not get passed on to the next function and does not have any effect.

**Dependencies:**

None
infra: run CI on all PRs
Labels: name: auto:improvement, name: size:XS

Somehow it looks like experimental linting didn't run properly on https://github.com/langchain-ai/langchain/pull/14842 before merging. Looks like it's because [check_diffs.yml](https://github.com/langchain-ai/langchain/blob/master/.github/workflows/check_diffs.yml#L8-L12) has some paths defined, and those paths are maybe only matched against the most recent commit, not the whole PR
Update arxiv.py with Entry ID as a return value
Labels: name: lgtm, name: area: doc loader, name: auto:improvement, name: size:XS

Added Entry ID as a return value inside get_summaries_as_docs

  - **Description:** Added the Entry ID as a return, so it's easier to track the IDs of the papers that are being returned.


With the addition return of the entry ID in functions like ArxivRetriever, it will be easier to reference the ID of the paper itself.
rename ChatGPTRouter to GPTRouter
Labels: name: lgtm, name: auto:refactor, name: area: models, name: size:M

**Description:**: Rename integration to GPTRouter 
**Tag maintainer:** @Gupta-Anubhav12 @samanyougarg @sirjan-ws-ext  
**Twitter handle:** [@SamanyouGarg](https://twitter.com/SamanyouGarg)
Issue when working with Azure and OpenAI Callback
Labels: name: auto:bug, name: area: models

### System Info

Langchain: v0.0.350
OS: Linux

### Who can help?

@agola11


### Information

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

### Related Components

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

### Reproduction

The problem occurs when you use Azure with an GPT 4 Model because the Azure API will always respond with `gpt-4` as the Model name. You can also see this in the official Microsoft documentation. https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/gpt-with-vision#output. It will therefore calculate the wrong price → if you use Turbo will the price will be `x3` as it actually should be.

Code to Reproduce:

```python


llm = AzureChatOpenAI(
     deployment_name="GPT4-TURBO"
)

with get_openai_callback() as cb:
    # Run LLM
    print((cb.total_tokens / 1000) * 0.01, "is instead", cb.total_cost)


```

### Expected behavior

It should return the correct price.
Fixing linter issue on Python 3.8 related to the prompt injection scanner check

 - **Description:** Fixing [linter problem on the Python 3.8](https://github.com/langchain-ai/langchain/pull/14842#issuecomment-1862733589) which became visible to new PRs after merging my previous PR https://github.com/langchain-ai/langchain/pull/14842.
  - **Issue:** https://github.com/langchain-ai/langchain/pull/14842#issuecomment-1862733589
  - **Dependencies:** N/A
  - **Tag maintainer:** N/A
  - **Twitter handle:** @laiyer_ai
`urllib3.connectionpool` warnings after upgrading to LangChain 0.0.351
Labels: name: auto:bug, name: area: models

### System Info

python: 3.11.4
langchain: 0.0.351
requests: 2.31.0

### Who can help?

@agola11 

### Information

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

### Related Components

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

### Reproduction

We have enabled the LangSmith tracing and after upgrading LangChain from `0.0.266` to `0.0.351` we started getting the following warnings:

```
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2423)'))': /runs
```

We also get the same warnings when we try to update the feedback from the LangSmith client.

```
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'RemoteDisconnected('Remote end closed connection without response')': /sessions?limit=1&name=mirror
```

Unfortunately, there is no additional stack trace.

This behavior is not consistent but it occurs randomly.

### Expected behavior

The expected behavior is all the runs to be propagated to the LangSmith and does not have this kind of warning.
Add retries logic to Yandex GPT API Calls
Labels: name: lgtm, name: auto:improvement, name: area: models, name: size:L

<!-- 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://python.langchain.com/docs/contributing/

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.
 -->
 **Description:** Added logic for re-calling the YandexGPT API in case of an error
Link to agent_with_wandb_tracing.html notebook is broken
Labels: name: area: doc loader, name: auto:documentation

### Issue with current documentation:

Ref: https://python.langchain.com/docs/integrations/providers/wandb_tracking

> Note: the WandbCallbackHandler is being deprecated in favour of the WandbTracer . In future please use the WandbTracer as it is more flexible and allows for more granular logging. To know more about the WandbTracer refer to the [agent_with_wandb_tracing.html](https://python.langchain.com/en/latest/integrations/agent_with_wandb_tracing.html) notebook or use the following [colab notebook](http://wandb.me/prompts-quickstart). To know more about Weights & Biases Prompts refer to the following [prompts documentation](https://docs.wandb.ai/guides/prompts).

The link to the `agent_with_wandb_tracing.html` results in a HTTP 404

### Idea or request for content:

_No response_
Issue: cannot import name 'LLMContentHandler' from 'langchain.llms.sagemaker_endpoint
Labels: name: auto:bug, name: area: models, name: integration: aws

Cannot import LLMContentHandler
langchain: 0.0.351
python: 3.9


To reproduce:

``` python
from langchain.llms.sagemaker_endpoint import LLMContentHandler
```

Issue could be resolved by updating 
https://github.com/langchain-ai/langchain/blob/583696732cbaa3d1cf3a3a9375539a7e8785850c/libs/langchain/langchain/llms/sagemaker_endpoint.py#L1C5-L7

as follow:
``` python
from langchain_community.llms.sagemaker_endpoint import (
    LLMContentHandler,
    SagemakerEndpoint,
)

__all__ = [
    "SagemakerEndpoint",
    "LLMContentHandler"
]
```
No input box show up when running the playground
Labels: name: auto:bug, name: area: models, name: integration: chroma

### System Info

In chain.py, relative code as below:
```
def get_retriever(text):
    _query = text
    llm = ...
    chroma_docs = [...]
    _model_name, _embedding = get_embedding_HuggingFace()
    chroma_vdb = Chroma.from_documents(chroma_docs, _embedding)
    document_content_description = "..."
    metadata_field_info = [...]
    retriever = get_structured_retriever(llm, chroma_vdb, document_content_description, metadata_field_info, _query)
    return retriever

chain = (
    RunnableParallel({
        "context": itemgetter("question") | RunnableLambda(get_retriever),
        "question": RunnablePassthrough()
    })
    | prompt
    | llm
    | StrOutputParser()
)
```

When running the playground, there is no input frame (show as below):
![image](https://github.com/langchain-ai/langchain/assets/14249712/d65f67df-acd4-4eee-96b0-54b149da6460)

But no error msg in langchain serve

### Who can help?

@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
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Show as the the code

### Expected behavior

Should have the input box
DOC: Wrong parameter name in doc string
Labels: name: auto:documentation, name: area: models

### Issue with current documentation:

Current:

```
class AzureChatOpenAI(ChatOpenAI):
    """`Azure OpenAI` Chat Completion API.

    To use this class you
    must have a deployed model on Azure OpenAI. Use `deployment_name` in the
    constructor to refer to the "Model deployment name" in the Azure portal.

    In addition, you should have the ``openai`` python package installed, and the
    following environment variables set or passed in constructor in lower case:
    - ``AZURE_OPENAI_API_KEY``
    - ``AZURE_OPENAI_API_ENDPOINT``
    - ``AZURE_OPENAI_AD_TOKEN``
    - ``OPENAI_API_VERSION``
    - ``OPENAI_PROXY``
```

### Idea or request for content:

It should be
```
class AzureChatOpenAI(ChatOpenAI):
    """`Azure OpenAI` Chat Completion API.

    To use this class you
    must have a deployed model on Azure OpenAI. Use `deployment_name` in the
    constructor to refer to the "Model deployment name" in the Azure portal.

    In addition, you should have the ``openai`` python package installed, and the
    following environment variables set or passed in constructor in lower case:
    - ``AZURE_OPENAI_API_KEY``
    - ``AZURE_OPENAI_ENDPOINT``    <---------- **Changed**
    - ``AZURE_OPENAI_AD_TOKEN``
    - ``OPENAI_API_VERSION``
    - ``OPENAI_PROXY``
```
Integrating GPTRouter
Labels: name: auto:enhancement, name: area: models, name: size:XL

**Description:** Adding a langchain integration for [GPTRouter](https://gpt-router.writesonic.com/) 🚀 , 
 **Tag maintainer:** @Gupta-Anubhav12 @samanyougarg @sirjan-ws-ext  
 **Twitter handle:** [@SamanyouGarg](https://twitter.com/SamanyouGarg)
 
Integration Tests Passing:
<img width="1137" alt="Screenshot 2023-12-19 at 5 45 31 PM" src="https://github.com/Writesonic/langchain/assets/151817113/4a59df9a-ee30-47aa-9df9-b8c4eeb9dc76">
`convert_to_openai_function` drops `description` for each parameter
Labels: name: auto:bug, name: area: models

### System Info

The `description` attribute of the function parameters described in our Pydantic *v2* model are missing in the output of `convert_to_openai_function` because it does not recognize Pydantic v2 `BaseModel` as a valid v1 `BaseModel`.

https://github.com/langchain-ai/langchain/blob/16399fd61d7744c529cca46464489e467b4b7741/libs/langchain/langchain/chains/openai_functions/base.py#L156-L161

### 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

```python
from langchain.chains.openai_functions.base import convert_to_openai_function
from pydantic.v1 import BaseModel as BaseModelV1, Field as FieldV1
from pydantic import BaseModel as BaseModelV2, Field as FieldV2


class FuncV1(BaseModelV1):
  "Pydantic v1 model."
  output: str = FieldV1(description="A output text")


class FuncV2(BaseModelV2):
  "Pydantic v2 model."
  output: str = FieldV2(description="A output text")

print(convert_to_openai_function(FuncV1))
{'name': 'FuncV1', 'description': 'Pydantic v1 model.', 'parameters': {'title': 'FuncV1', 'description': 'Pydantic v1 model.', 'type': 'object', 'properties': {'output': {'title': 'Output', 'description': 'A output text', 'type': 'string'}}, 'required': ['output']}}

print(convert_to_openai_function(FuncV2))
{'name': 'FuncV2', 'description': 'Pydantic v2 model.', 'parameters': {'type': 'object', 'properties': {'output': {'type': 'string'}}, 'required': ['output']}}
```

### Expected behavior

Add `description` attribute appeared in Pydantic v2 model.
Issue: Enhancing Streaming and Database Integration in ConversationRetrieval with AsyncIteratorCallbackHandler
Labels: name: auto:improvement, name: area: models

### Issue you'd like to raise.

I am working on implementing streaming for my ConversationRetrieval chain calls, and I plan to leverage the AsyncIteratorCallbackHandler along with its aiter method. While reviewing the source code, I noticed that the response from the on_llm_end method is not currently added to the queue. My goal is to enhance the aiter method so that the response is also included in the queue. This way, I can stream the final response to my client and use it to update cached data in my frontend. Additionally, I intend to leverage the on_llm_end method to update my database with the received response. Could you guide me on how to modify the aiter method within the AsyncIteratorCallbackHandler to align with these requirements?

### Suggestion:

_No response_
Update records in the Xata integration
Labels: name: area: vector store, name: auto:enhancement

### Feature request

Currently (0.0.350) the Xata integration always creates new records with `XataVectorStore.from_documents`.

Provide the option to update embeddings and column content of existing record ids.

### Motivation

This will provide the capability to update Xata Vector Stores.

### Your contribution

Xata development team plans to contribute the enhancement.
Comparing the agent reply with the previous conversation
Labels: name: area: memory, name: auto:question

### System Info

Hi folks,

I am getting one error in which sometime agent  gives the exact same answer as it has output for the previous question. Here is the screen shot of my replies

![image](https://github.com/langchain-ai/langchain/assets/100353004/3e42f54b-cb48-4515-9ee8-05675156bbf1)

Since it is giving the same exact string as answer I want put a manual check that whenever it given the answer which is exactly the same , then I will again query the agent for the new response.

I want to know how I can access the messages from the chat history

 

### Who can help?

@agola11 

### Information

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

### Related Components

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

### Reproduction

It is a rare incident so no exact method to catch it

### Expected behavior

Just a code piece to check the previous replies
MultiQueryRetriever consume too much GPU mem, request to limit the maximum llm call
Labels: name: auto:improvement, name: area: models

### System Info

python 3.10
langchain 0.0.350

### 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

        output_parser = LineListOutputParser()
        QUERY_PROMPT = PromptTemplate(
            input_variables=["question"],
            template="""You are an AI language model assistant. Your task is to generate five 
            different versions of the given user question to retrieve relevant documents from a vector 
            database. By generating multiple perspectives on the user question, your goal is to help
            the user overcome some of the limitations of the distance-based similarity search. 
            Provide these alternative questions separated by newlines.
            Original question: {question}""",
        )
        llm_chain = LLMChain(llm=self.llm, prompt=QUERY_PROMPT, output_parser=output_parser)
        db = self.embeddings_dict[doc_id].as_retriever(search_kwargs={"k": 15})
        multi_query_retriever = MultiQueryRetriever.from_llm(retriever=db, llm=self.llm)
        relevant_documents = multi_query_retriever.get_relevant_documents(query)


### Expected behavior

limit the maximum number of parallel llm call, for example, 4
AIORpcError connection reset errors from Qdrant
Labels: name: area: vector store, name: auto:bug, name: integration: aws

### System Info

Python:3.11-slim-bullseye base docker image
Langchain version: 0.0.348
qdrant-client: 1.7.0
Qdrant database 1.7.1 (deployed on AWS cluster)
Reproduces regardless of prefer grpc true or false

### Who can help?

@agola11 @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
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [X] Async

### Reproduction

1. Use ConversationalRetrievalChain with Qdrant vectordb
2. Use async acall interface
3. Maybe wait some idle time (15 min?)

You will experience a lot of errors from Qdrant:
AioRpcError of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "recvmsg:Connection reset by peer" debug_error_string = "UNKNOWN:Error received from peer {created_time}" >, type: AioRpcError

It's ok after retry of the request but this causes significant delay in response






### Expected behavior

Connection recovery for the vectordb should be handled by LangChain internally and ideally understand what causes the connection issues and resolve it
docstrings `langchain_community` update
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:L

Addded missed docstrings. Fixed inconsistency in docstrings.

**Note** CC @efriis 
There were PR errors on `langchain_experimental/prompt_injection_identifier/hugging_face_identifier.py` 
But, I didn't touch this file in this PR! Can it be some cache problems?
I fixed this error.
How to connect LangChain application to a mobile app using an API
Labels: name: auto:question, name: area: models

I have developed a Flutter app with a chatroom feature and have successfully implemented chatting in the chatroom interface using the OpenAI API with ChatGPT. Now, I am looking to utilize an API to establish a connection between LangChain and my mobile app.  How or what should i do to achieve this? I am new to this, any help will be thankful.
[Partner] Update google integration test
Labels: name: auto:improvement, name: area: models, name: size:S

Gemini has decided that pickle rick is unsafe: https://github.com/langchain-ai/langchain/actions/runs/7256642294/job/19769249444#step:8:189

![image](https://github.com/langchain-ai/langchain/assets/13333726/cfbf4312-53b6-4290-84ee-6ce0742e739e)
how to increase the response size of chromadb
Labels: name: area: vector store, name: auto:question, name: integration: chroma

I am working in project, where i have to use multiple pdf docs to give respose to the user query.

I have a load method to load pdf from directory.

```
def loadFiles():
    
    loader = DirectoryLoader('./static/upload/', glob="./*.pdf", loader_cls=PyPDFLoader)
    documents = loader.load()

    text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=50)
    texts = text_splitter.split_documents(documents)
    return texts
```

I am creating chromadb by below code:

```
def createDb(load,embeddings,persist_directory):
    max_input_size = 3000
    num_output = 256
    chunk_size_limit = 1000 # token window size per document
    max_chunk_overlap = 80 # overlap for each token fragment

    vectordb = Chroma.from_documents(documents=load, embedding=embeddings, persist_directory=persist_directory)
    vectordb.persist()
    return vectordb
```

now , I am quering chromadb ,

```
qa_chain = RetrievalQA.from_chain_type(
        llm=OpenAI(temperature=0,model_name = "text-davinci-003"),
        retriever=vectordb.as_retriever(),chain_type="stuff",
        chain_type_kwargs=chain_type_kwargs,
       
        return_source_documents=True
        )
```

However, i am getting the response , but not full response in some cases, like below :
My source pdf has following contents:
[source file](https://i.stack.imgur.com/Xaz7U.png)

while my response is showing only some parts as shown below:
[chromadb response](https://i.stack.imgur.com/CY4dL.png)

I tried incresing the chunk_ovarlap size as shown in createdb(), but it does not worked. I am expecting from chromadb full response and response should be comming from given pdf.

I am new to this, any help will be thankful.
Docs `tencent` pages update
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:L

- updated `Tencent` provider page: added a chat model and document loader references; company description
- updated Chat model and Document loader pages with descriptions, links
- renamed files to consistent formats; redirected file names
Note:
I was getting this linting error on code that **was not changed in my PR**!

> Error: docs/docs/guides/safety/hugging_face_prompt_injection.ipynb:1:1: I001 Import block is un-sorted or un-formatted
> make: *** [Makefile:47: lint_package] Error 1

I've fixed this error in the notebook
Update kendra.py to avoid Kendra query ValidationException
Labels: name: lgtm, name: area: doc loader, name: auto:bug, name: integration: aws, name: size:XS

Fixing issue - https://github.com/langchain-ai/langchain/issues/14494 to avoid Kendra query ValidationException

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** Update kendra.py to avoid Kendra query ValidationException, 
  - **Issue:** the issue #https://github.com/langchain-ai/langchain/issues/14494,
  - **Dependencies:** None,
  - **Tag maintainer:** ,
  - **Twitter handle:** 

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->