delayedkarma/langchain-issues huggingface dataset:
Fix minor typos (casing)
Labels: name: lgtm, name: auto:documentation, name: size:XS

Fix casing of API and LangChain in the description text for the LangServe example server.

<!-- 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.
 -->
Removing extra `StdOutCallbackHandler` overridden methods
Labels: name: lgtm, name: auto:nit, name: size:M

Unnecessarily overridden methods:

- Give the idea the subclass is doing something special (when it isn't)
- Block CTRL-click to the actual method

This PR removes some unnecessarily overridden methods in `StdOutCallbackHandler`

Supercedes https://github.com/langchain-ai/langchain/pull/12858
Bug: LCEL prompt template not logging
Labels: name: auto:bug, name: area: models

### System Info

Python 3.11, `langchain==0.0.340`

### Who can help?

@hwchase17 

### Information

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

### Related Components

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

### Reproduction

Before LCEL, there is lots of logging:

```python
from langchain.chains import LLMChain
from langchain.chat_models import ChatOpenAI
from langchain.prompts import PromptTemplate
from langchain.schema.callbacks.stdout import StdOutCallbackHandler

prompt = PromptTemplate.from_template(
    "What is a good name for a company that makes {product}?"
)
chain = LLMChain(prompt=prompt, llm=ChatOpenAI(), callbacks=[StdOutCallbackHandler()])
chain.run(product="colorful socks")
```

```none
> Entering new LLMChain chain...
Prompt after formatting:
What is a good name for a company that makes colorful socks?

> Finished chain.
```

After LCEL, there is less logging:

```python
from langchain.chat_models import ChatOpenAI
from langchain.prompts import PromptTemplate
from langchain.schema.callbacks.stdout import StdOutCallbackHandler

prompt = PromptTemplate.from_template(
    "What is a good name for a company that makes {product}?"
)
runnable = prompt | ChatOpenAI()
runnable.invoke(
    input={"product": "colorful socks"}, config={"callbacks": [StdOutCallbackHandler()]}
)
```

Leads to this output:

```none
> Entering new RunnableSequence chain...


> Entering new PromptTemplate chain...

> Finished chain.

> Finished chain.
```

### Expected behavior

To migrate from `LLMChain` to LCEL, I want the logging statements/verbosity to remain in tact
DOC: documenting callbacks with LCEL
Labels: name: area: doc loader, name: auto:documentation

### Issue with current documentation:

https://python.langchain.com/docs/modules/callbacks/

This doc doesn't mention how to use callbacks with LCEL. It would be good to add that, to help with the migration from `LLMChain` to `LCEL`.

### Idea or request for content:

https://python.langchain.com/docs/modules/chains/ does a nice job of showing code pre-LCEL and code post-LCEL.

https://github.com/langchain-ai/langchain/discussions/12670 shows how to pass the callback to `invoke`, but ideally the example shows how to `bind` the callback once (as opposed to passing to each `invoke`).
OpenSearchVectorSearch fails to detect AOSS is enabled when using RequestAWS4SignerAuth from opensearch-py
Labels: name: area: vector store, name: auto:bug, name: integration: aws

### System Info

langchain 0.0.335
macOS 14.1.1 / Windows 10.0.19045
Python 3.11.6 / 3.10.9


### Who can help?

@naveentatikonda 

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Install dependencies
```shell
pip install langchain opensearch-py boto3
```
Import packages
```python
import boto3
from langchain.embeddings import FakeEmbeddings
from langchain.vectorstores.opensearch_vector_search import OpenSearchVectorSearch
from opensearchpy import RequestsAWSV4SignerAuth, RequestsHttpConnection
```
Create AOSS auth
```python
boto_session = boto3.Session()
aoss_auth = RequestsAWSV4SignerAuth(credentials=boto_session.get_credentials(), region=boto_session.region_name, service="aoss")
```
Create AOSS vector search class
```python
embeddings = FakeEmbeddings(size=42)
database = OpenSearchVectorSearch(
    opensearch_url="https://some_aoss_endpoint:443",
    http_auth=aoss_auth,
    connection_class=RequestsHttpConnection,
    index_name="test",
    embedding_function=embeddings,
```
Check if AOSS vector search identifies itself as AOSS
```python
database.is_aoss
```
Returns **False**

### Expected behavior

AOSS should correctly identify itself as AOSS given the configuration above, which means that `database.is_aoss` should return **True** in this case.

The issue is related to how the internal `_is_aoss_enabled` method works:
```python
def _is_aoss_enabled(http_auth: Any) -> bool:
    """Check if the service is http_auth is set as `aoss`."""
    if (
        http_auth is not None
        and hasattr(http_auth, "service")
        and http_auth.service == "aoss"
    ):
        return True
    return False
```
The `RequestsAWSV4SignerAuth` does not expose the _service_ property directly, but via the _signer_ attribute. In order to respect that, `is_aoss_enabled` should be adapted as following:
```python
def _is_aoss_enabled(http_auth: Any) -> bool:
    """Check if the service set via http_auth equals `aoss`."""
    if http_auth is not None:
        if hasattr(http_auth, "service") and http_auth.service == "aoss":
            return True
        elif hasattr(http_auth, "signer") and http_auth.signer.service == "aoss":
            return True
        else:
            return False
    return False
```
Improve indexing performance for Postgres (remote database) for refresh
Labels: name: lgtm, name: auto:improvement, name: size:S

**Description:** By combining the document timestamp refresh within a single call to update(), this enables batching of multiple documents in a single SQL statement. This is important for non-local databases where tens of milliseconds has a huge impact on performance when doing document-by-document SQL statements. 
**Issue:** #11935 
**Dependencies:** None
**Tag maintainer:** @eyurtsev
Support of custom hugging face inference endpoints url
Labels: name: lgtm, name: area: embeddings, name: auto:improvement, name: size:XS

  - **Description:** to support not only publicly available Hugging Face endpoints, but also protected ones (created with "Inference Endpoints" Hugging Face feature), I have added ability to specify custom api_url. But if not specified, default behaviour won't change
  - **Issue:** #9181,
  - **Dependencies:** no extra dependencies
Specify a custom tokenizer for the ConversationSummaryBufferMemory
Labels: name: area: memory, name: auto:improvement, name: area: models

### Feature request

Currently, the ConversationSummaryBufferMemory only supports the GPT2TokenizerFast and there is no option to pass a custom tokenizer. Different models have different corresponding tokenizers, so it makes sense to allow the option to specify a custom tokenizer.

The tokenizer fetching is implemented in langchain/schema/language_model.py:

@lru_cache(maxsize=None)  # Cache the tokenizer
def get_tokenizer() -> Any:
    try:
        from transformers import GPT2TokenizerFast
    except ImportError:
        raise ImportError(
            "Could not import transformers python package. "
            "This is needed in order to calculate get_token_ids. "
            "Please install it with `pip install transformers`."
        )
    # create a GPT-2 tokenizer instance
    return GPT2TokenizerFast.from_pretrained("gpt2")
    
  

### Motivation

Using the exact tokenizer which the model uses will help in being more accurate in the context summarization cutoff.

### Your contribution

I could suggest a solution.
How can we add Prompt in RetrievalQA
Labels: name: auto:question, name: area: models



 qa = RetrievalQA.from_chain_type(llm=llm,  retriever=docsearch.as_retriever(
            search_kwargs={"k": 1}), verbose=True)
   
How can we add the prompts like systemPromptTemplate and humanPromptTemplate  in the above code.

### Suggestion:

_No response_
fix: set maxsplit when parse python function docstring
Labels: name: lgtm, name: auto:bug, name: size:XS

Description

when the desc of arg in python docstring contains ":", the `_parse_python_function_docstring` will raise **ValueError: too many values to unpack (expected 2)**.

A sample desc would be:
"""
Args: 
    error_arg: this is an arg with an additional ":" symbol
"""

So, set `maxsplit` parameter to fix it.
Expose Amazon Bedrock amazon-bedrock-invocationMetrics in response
Labels: name: auto:improvement, name: area: models, name: integration: aws

### Feature request

Amazon Bedrock now provides some useful metrics when it has finished:

`"completion":"Response from Bedrock...","stop_reason":"stop_sequence","stop":"\n\nHuman:","amazon-bedrock-invocationMetrics":{"inputTokenCount":16,"outputTokenCount":337,"invocationLatency":4151,"firstByteLatency":136}}`

It would be good to expose these via LangChain, similar to how OpenAI API provides them.



### Motivation

To make it easier to calculate the cost of Amazon Bedrock queries.

### Your contribution

I'm happy to test any solution. I'd look to existing developers to guide us how best to expose them.
Trouble Connecting Langchain Chroma to Existing ChromaDB on Port 8001
Labels: name: area: vector store, name: auto:bug, name: integration: chroma

I am currently operating a chroma docker on port 8001 and using it for my node js application with the URL CHROMA_URI=http://localhost:8001/, which allows me to read the vectors.

However, when I try to use the same chroma_URI with langchain chroma, I encounter an error message. The error message reads: **{"lc":1,"type":"not_implemented","id":["langchain","vectorstores","chroma","Chroma"]}**.

![image](https://github.com/langchain-ai/langchain/assets/26340363/795dc113-a2ec-4a89-9da6-6dd75542d967)

![image](https://github.com/langchain-ai/langchain/assets/26340363/0cca4d46-2af0-4627-a2a1-0ea3713fd286)

![image](https://github.com/langchain-ai/langchain/assets/26340363/59715764-1abe-4493-be0e-0a18a37fc00a)

The above screenshots are my codes. 

does anyone face this issue?
ignore the first turn to apply "history" mechanism
Labels: name: auto:improvement, name: area: models, name: size:XS

This will generate a meaningless string "system: " for generating condense question; this increases the probability to make an improper condense question and misunderstand user's question. Below is a case
- Original Question: Can you explain the arguments of Meilisearch?
- Condense Question
  - What are the benefits of using Meilisearch? (by CodeLlama)
  - What are the reasons for using Meilisearch? (by GPT-4)

The condense questions (not matter from CodeLlam or GPT-4) are different from the original one.

By checking the content of each dialogue turn, generating history string only when the dialog content is not empty.
Since there is nothing before first turn, the "history" mechanism will be ignored at the very first turn.

Doing so, the condense question will be "What are the arguments for using Meilisearch?".

<!-- 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.
 -->
Cost doesnt work when used inside Tool
Labels: name: auto:bug, name: area: models

### System Info

- Python 3.9.13
- langchain==0.0.344
- langchain-core==0.0.8

### Who can help?

@agola11
@hwchase17
@agola11


### Information

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

### Related Components

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

### Reproduction

1. Define a Custom Tool which useses some sort of OpenAI Model. For example GPT 3.5
2. Define a Tool agent which uses this Tool
3. Call the Agent inside a with Block with `get_openai_callback()`
4. The agent should now call the tool which uses an OpenAI Model
5. Calculate the Total Cost. By using the `get_openai_callback` variable. The cost does only include tokens used by the tool agent

### Expected behavior

It should Include all Cost. Including the one from the tool
Google Cloud Vertex AI Throws AttributeError: partially initialized module 'vertexai' has no attribute 'init'
Labels: name: auto:bug, name: area: models

### System Info

I was just trying to run the LLMs tutorial.

```
from langchain.llms import VertexAI

llm = VertexAI()
print(llm("What are some of the pros and cons of Python as a programming language?"))
```

I got this error.

```
File "C:\Users\******\anaconda3\envs\vertex-ai\Lib\site-packages\langchain_core\load\serializable.py", line 97, in __init__
    super().__init__(**kwargs)
  File "C:\Users\******\anaconda3\envs\vertex-ai\Lib\site-packages\pydantic\v1\main.py", line 339, in __init__
    values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\******\anaconda3\envs\vertex-ai\Lib\site-packages\pydantic\v1\main.py", line 1102, in validate_model
    values = validator(cls_, values)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\******\anaconda3\envs\vertex-ai\Lib\site-packages\langchain\llms\vertexai.py", line 249, in validate_environment
    cls._try_init_vertexai(values)
  File "C:\Users\******\anaconda3\envs\vertex-ai\Lib\site-packages\langchain\llms\vertexai.py", line 216, in _try_init_vertexai
    init_vertexai(**params)
  File "C:\Users\******\anaconda3\envs\vertex-ai\Lib\site-packages\langchain\utilities\vertexai.py", line 42, in init_vertexai
    import vertexa
```

I try to install an older version of pydantic like pip install pydantic == 1.10 or 1.10.10, but still error about "validation_error" .


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

Anaconda Navigator
1.Python version == 3.12.0
2.Langchain version == 0.0.344
3.Google-cloud-aiplatform version == 1.36.4
4.Pydantic version == 2.5.2

### Expected behavior

Running code without any issues.
fix: use async_embed_with_retry in _aget_len_safe_embeddings
Labels: name: lgtm, name: area: embeddings, name: auto:bug, name: size:XS

**Description**

`embed_with_retry` is for sync operations and not for async operations.
Use `async_embed_with_retry` for appropriate async operations.


I'm using `OpenAIEmbedding(http_client=httpx.AsyncClient())` with only async operations.
However, I got an error when I use `embedding.aembed_documents` because `embed_with_retry` uses sync OpenAI client with async http client.
DOC: Link to subscribe to the "newsletter" on Community page is no longer valid
Labels: name: auto:documentation

### Issue with current documentation:

The link to subscribe to the "newsletter" at the bottom of Community page (`/docs/docs/community.md`) is no longer available.

![image](https://github.com/langchain-ai/langchain/assets/4020306/66fdefef-af05-4397-8ecf-14e45043e061)

As the image above indicates, the "form has moved to a new address", and the new address (https://form.typeform.com/to/KjZB1auB?typeform-source=6w1pwbss0py.typeform.com) gives "This typeform is now closed", as the image shown below:
![image](https://github.com/langchain-ai/langchain/assets/4020306/00c65a2c-89f8-4147-a8f5-2d2f47d11a54)


### Idea or request for content:

If the newsletter is still operating, replace the current link with a new one where people can subscribe to it.
If the newsletter is no longer running, replace the text with something else (eg. the link to langchain blogs).
Issue: openai.ChatCompletion is no longer supported in openai>=1.0.0 
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

i am using load_qa_chain() 
chain=load_qa_chain(OpenAI(temperature=0.25,model_name="gpt-3.5-turbo-1106"),  chain_type="stuff", prompt=PROMPT)


i got the following error

"""
     APIRemovedInV1: 
    You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at 
    https://github.com/openai/openai-python for the API.

    You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

    Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

   A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
"""

and the line that raised the error is 

anaconda3/envs/Doc2/lib/site-packages/langchain/llms/openai.py:115


### Suggestion:

_No response_
Update invalid link
Labels: 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.
 -->
docs[patch]: Update facebook.ipynb
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:M

### Description

Openai version 1.0.0 and later no longer supports the usage of camel case, So [the APIs](https://github.com/openai/openai-python/blob/main/api.md#finetuning) needs to be modified.

### Twitter handle

[lin_bob57617](https://twitter.com/lin_bob57617)
Support passing parameters to `llms.Databricks` and `llms.Mlflow`
Labels: 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://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.
 -->

Before, we need to use `params` to pass extra parameters:

```python
from langchain.llms import Databricks

Databricks(..., params={"temperature": 0.0})
```

Now, we can directly specify extra params:

```python
from langchain.llms import Databricks

Databricks(..., temperature=0.0)
```
docs[patch]: Update discord.ipynb
Labels: name: area: doc loader, name: auto:documentation, name: size:S

### Description

Now if `example` in Message is False, it will not be displayed. Update the output in this document.

```python
In [22]: m = HumanMessage(content="Text")

In [23]: m
Out[23]: HumanMessage(content='Text')

In [24]: m = HumanMessage(content="Text", example=True)

In [25]: m
Out[25]: HumanMessage(content='Text', example=True)
```

### Twitter handle

[lin_bob57617](https://twitter.com/lin_bob57617)