delayedkarma/langchain-issues huggingface dataset:
Language parameter in OpoenAI() is not working anymore!
Labels: name: auto:bug, name: area: models

### System Info

All latest versions

### Who can help?

@agola

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] 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

The parameter language="es" in OpenAI() is not working anymore. And I have to present it tomorrow at the university! I can't find any solution for this. Nowhere. 

Pretty simple code that was working perfectly and now not anymore:

`model= OpenAI(temperature=0, language="es")`

Now I'm getting this error message:  

`C:\Users\zaesa\anaconda3\Lib\site-packages\langchain\utils\utils.py:155: UserWarning: WARNING! language is not default parameter.
                language was transferred to model_kwargs.
                Please confirm that language is what you intended.
  warnings.warn(  `

How to solve it?

### Expected behavior

It should just search in spanish pages and answer in spanish. It was pretty simple. Now it just doesn't work anymore. Any help will be really apprecaited.
adding language as parameter to NLTK text splitter
Labels: name: lgtm, name: auto:improvement

<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->

  - Description: 
  Adding language as parameter to NLTK, by default it is only using English. This will help using NLTK splitter for other languages. Change is simple, via adding language as parameter to NLTKTextSplitter and then passing it to nltk "sent_tokenize".
  
  - Issue: N/A
  
  - Dependencies: N/A
pydantic.v1.error_wrappers.ValidationError: 1 validation error for LlamaCpp __root__   Could not load Llama model from path: D:\model.safetensors. Received error  (type=value_error)
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

Trying to load the llama 2 7b model which is in D drive, but I'm constantly getting errors. 

This is my code 

`
from langchain.llms import LlamaCpp
from langchain import PromptTemplate, LLMChain
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

MODEL_PATH = "D:\model.safetensors"


def load_model():
    """Loads Llama model"""
    callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
    Llama_model = LlamaCpp(
        model_path=MODEL_PATH,
        temperature=0.5,
        max_tokens=2000,
        top_p=1,
        callback_manager=callback_manager,
        verbose=True

    )
    return Llama_model


llm = load_model()

model_prompt = """
Question:What is the largest planet discovered so far?

"""

response = llm(model_prompt)

print(response)

`

This is the error 

"
PS D:\Python Projects\python> python learn.py
gguf_init_from_file: invalid magic number 00029880
error loading model: llama_model_loader: failed to load model from D:\model.safetensors

llama_load_model_from_file: failed to load model
Traceback (most recent call last):
  File "D:\Python Projects\python\learn.py", line 24, in <module>
    llm = load_model()
  File "D:\Python Projects\python\learn.py", line 12, in load_model
    Llama_model = LlamaCpp(
  File "C:\Users\krish\anaconda3\envs\newlang\lib\site-packages\langchain\load\serializable.py", line 75, in __init__
    super().__init__(**kwargs)
  File "C:\Users\krish\anaconda3\envs\newlang\lib\site-packages\pydantic\v1\main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for LlamaCpp
__root__
  Could not load Llama model from path: D:\model.safetensors. Received error  (type=value_error)

"
Please help.

### Suggestion:

_No response_
create_sql_agent has incorrect behaviour when it queries agaisnt Google BigQuery
Labels: name: area: agent, name: auto:bug

### System Info

OS: Ubuntu 22.04.3 LTS

SQLAlchemy==1.4.49
langchain==0.0.281



### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction


```
from langchain.agents import create_sql_agent
from langchain.agents.agent_toolkits import SQLDatabaseToolkit
from langchain.llms import VertexAI
from langchain.sql_database import SQLDatabase

project = "AAAA"
dataset = "HHHH"
sqlalchemy_url = f'bigquery://{project}/{dataset}'

db = SQLDatabase.from_uri(sqlalchemy_url)

llm = VertexAI(
    model_name="text-bison@001",
    max_output_tokens=256,
    temperature=0.1,
    top_p=0.8,
    top_k=40,
    verbose=True,
)
toolkit = SQLDatabaseToolkit(db=db, llm=llm)

agent_executor = create_sql_agent(
    llm=llm,
    toolkit=toolkit,
    verbose=True, 
    max_execution_time=60,
)

question = "What is the total <numbers> in 2023?" #replace number to the target metric

response = agent_executor.run(question)

```
The agent will return "(Background on this error at: https://sqlalche.me/e/14/4xp6) Error: (google.cloud.bigquery.dbapi.exceptions.DatabaseError) 400 Syntax error: Expected end of input but got identifier "Thought" at [4:1]"
And when I check the project history on GCP, I found the agent included the thought and action inside the query, so the executed query was like that:
```
SELECT SUM(AAA) AS total_AAA, SUM(BBB) AS total_BBB
FROM YOU_CANT_SEE_ME
WHERE Year = 2023
Thought: I should check the query before executing it.
Action: sql_db_query_checker
Action Input: 
SELECT SUM(AAA) AS total_AAA, SUM(BBB) AS total_BBB
FROM YOU_CANT_SEE_ME
WHERE Year = 2023
```

It was stunning. Or was there anything I did wrong?


### Expected behavior

It should phrase a correct query, execute it and return a legit result. It works fine when I do not specify the year.
Fix usage of AsyncHtmlLoader with an already running event loop
Labels: name: area: doc loader, name: auto:bug

<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
Please add support URL parse for BaijiaHao
Labels: name: area: doc loader, name: auto:bug

### System Info

windows

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

```python
  from langchain.document_loaders import UnstructuredURLLoader
    from langchain.chains import LLMRequestsChain
    from langchain.chains.llm_requests import DEFAULT_HEADERS
    from langchain.requests import TextRequestsWrapper
    from bs4 import BeautifulSoup


    # loader = UnstructuredURLLoader(
    #     urls=["https://baijiahao.baidu.com/s?id=1776165472932985664"],
    #     show_progress_bar=True,
    # )
    # data = loader.load()
    # print(data)

    url = "https://baijiahao.baidu.com/s?id=1776165472932985664"
    a = TextRequestsWrapper(headers=DEFAULT_HEADERS)
    res = a.get(url)
    # extract the text from the html
    soup = BeautifulSoup(res, "html.parser")
    res = soup.get_text()
    print(res)
```

I can not get the content from this url, while all other urls are OK.

### Expected behavior

Please take a look at this url
Issue: Timeout parameter in the AzureMLEndpointClient cannot be modified
Labels: name: auto:bug

### Issue you'd like to raise.

class AzureMLEndpointClient(object):
    """AzureML Managed Endpoint client."""

    def __init__(
        self, endpoint_url: str, endpoint_api_key: str, deployment_name: str = ""
    ) -> None:
        """Initialize the class."""
        if not endpoint_api_key or not endpoint_url:
            raise ValueError(
                """A key/token and REST endpoint should 
                be provided to invoke the endpoint"""
            )
        self.endpoint_url = endpoint_url
        self.endpoint_api_key = endpoint_api_key
        self.deployment_name = deployment_name

    def call(self, body: bytes, **kwargs: Any) -> bytes:
        """call."""

        # The azureml-model-deployment header will force the request to go to a
        # specific deployment. Remove this header to have the request observe the
        # endpoint traffic rules.
        headers = {
            "Content-Type": "application/json",
            "Authorization": ("Bearer " + self.endpoint_api_key),
        }
        if self.deployment_name != "":
            headers["azureml-model-deployment"] = self.deployment_name

        req = urllib.request.Request(self.endpoint_url, body, headers)
        response = urllib.request.urlopen(req, timeout=kwargs.get("timeout", 50))
        result = response.read()
        return result


I am using this class in order to call a AzureML Endpoint and i am not able to pass the timeout as a parameter anywhere in the function call.

### Suggestion:

_No response_
Errors about ErnieBotChat using agent
Labels: name: area: agent, name: auto:bug, name: area: models

### System Info

LangChain version：0.0271
python version：3.9
transformers：4.30.2
linux


### Who can help?

_No response_

### 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
- [X] Agents / Agent Executors
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

model = ErnieBotChat(model="ERNIE-Bot")

tools = load_tools(["llm-math", "wikipedia"], llm=model)

agent = initialize_agent(
tools,
model,
agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
handle_parsing_errors=True)

result = agent("300的25%是多少？")
print(result)

### Expected behavior

Error：
ValueError: Got unknown type content='Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nWikipedia: A wrapper around Wikipedia. Useful for when you need to answer general questions about people, places, companies, facts, historical events, or other subjects. Input should be a search query.\n\nThe way you use the tools is by specifying a json blob.\nSpecifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).\n\nThe only values that should be in the "action" field are: Calculator, Wikipedia\n\nThe $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multiple actions. Here is an example of a valid $JSON_BLOB:\n\n```\n{\n  "action": $TOOL_NAME,\n  "action_input": $INPUT\n}\n```\n\nALWAYS use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction:\n```\n$JSON_BLOB\n```\nObservation: the result of the action\n... (this Thought/Action/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin! Reminder to always use the exact characters `Final Answer` when responding.' additional_kwargs={}


When I was running ErnieBotChat and trying to join agent, an error occurred, as shown above. How to solve this? thank you!
add where_document filter for chroma
Labels: name: lgtm, name: area: vector store, name: auto:improvement, name: integration: chroma

  - Description: add where_document filter parameter in Chroma
  - Issue: [10082](https://github.com/langchain-ai/langchain/issues/10082)
  - Dependencies: no
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: no

@hwchase17
Fixed incorrect prompt formatting for chat based ReAct agent
Labels: name: area: agent, name: auto:bug

# Fixed incorrect prompt formatting for chat based ReAct agent

Fixes #5390
Created two new classes (ReActStringPromptValue and ReActPromptTemplate) in order to handle correct prompt formatting for chat based models. Unit tests are also included.
Format/lint/tests already run.

My twitter handle: @gultepeoguz
update(llms/TGI): Allow None as temperature value
Labels: name: auto:improvement, name: area: models

Text Generation Inference's client permits the use of a None temperature as seen [here](https://github.com/huggingface/text-generation-inference/blob/033230ae667101d2d8d8bcd4952442fa348ef951/clients/python/text_generation/client.py#L71C9-L71C20). While I haved dived into TGI's server code and don't know about the implications of using None as a temperature setting, I think we should grant users the option to pass None as a temperature parameter to TGI.


<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
Param name change
Labels: name: area: embeddings, name: auto:nit

 - Description: Changed parameter name 'model_name' to 'model_name_or_path' of HuggingFaceEmbeddings / HuggingFaceInstructEmbeddings / HuggingFaceBgeEmbeddings modules since it can take and process local model files as input, without any change of code! 
 - Issue: Prevent confusion of users 
 - Dependencies: Not at all!
Pydantic issue
Labels: name: area: embeddings, name: area: doc loader, name: area: vector store, name: auto:bug

### System Info

Kaggle notebook

### Who can help?

@agola11 @hw

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

'''
I installed:
```
pip install -qq -U langchain tiktoken pypdf chromadb faiss-gpu unstructured openai
pip install -qq -U transformers InstructorEmbedding sentence_transformers pydantic==1.9.0
pip uninstall pydantic-settings
pip uninstall inflect
pip install pydantic-settings
pip install inflect
```
but getting error:
```
PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.3/migration/#basesettings-has-moved-to-pydantic-settings for more details.
```
Even though i have chromadb installed:
```
ImportError: Could not import chromadb python package. Please install it with `pip install chromadb`.
```
```
from langchain.document_loaders import PyPDFLoader, DirectoryLoader, PDFMinerLoader 
from langchain.text_splitter import RecursiveCharacterTextSplitter 
from langchain.embeddings import SentenceTransformerEmbeddings 
from langchain.vectorstores import Chroma, FAISS
import os 


persist_directory = "db"

def main():
    for root, dirs, files in os.walk("docs"):
        for file in files:
            if file.endswith(".pdf"):
                print(file)
                loader = PyPDFLoader(os.path.join(root, file))
    documents = loader.load()
    print("splitting into chunks")
    text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=100)
    texts = text_splitter.split_documents(documents)
    #create embeddings here
    print("Loading sentence transformers model")
    embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
    #create vector store here
    print(f"Creating embeddings. May take some minutes...")
    db = Chroma.from_documents(texts, embeddings, persist_directory=persist_directory)
    db.persist()
    db=None 

    print(f"Ingestion complete! You can now run privateGPT.py to query your documents")

if __name__ == "__main__":
    main()
```

### Expected behavior

shows results
Fixed Import Error type in base.py
Labels: name: area: vector store, name: auto:bug

I have revamped the code to ensure uniform error handling for ImportError. Instead of the previous reliance on ValueError, I have adopted the conventional practice of raising ImportError and providing informative error messages. This change enhances code clarity and clearly signifies that any problems are associated with module imports.

CC: @baskaryan, @eyurtsev, @rlancemartin.
Update image_captions.py
Labels: name: area: doc loader, name: auto:improvement

enabled ImageCaptionLoader to accept bytes or filepath as input, if you input bytes the metadata states that bytes were input or if file path it shows the file path, pretty straightforward

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - Description: enabled ImageCaptionLoader to accept bytes or filepath as input, if you input bytes the metadata states that bytes were input or if file path it shows the file path, 
  - Issue: n/a
  - Dependencies: n/a,
  - 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
langchain/vectorstores/milvus.py _load function need timeout parameter
Labels: name: area: vector store, name: auto:improvement

### System Info

0.0.274

### 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

    def _load(self) -> None:
        """Load the collection if available."""
        from pymilvus import Collection

        if isinstance(self.col, Collection) and self._get_index() is not None:
            self.col.load(timeout=5)

### Expected behavior

https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/vectorstores/milvus.py#L387C3-L387C3
<img width="563" alt="ab96a8450969eaeae4eb91cf582828cf" src="https://github.com/langchain-ai/langchain/assets/16218592/2976b0de-fc41-46aa-88eb-fd807e3b6b57">
<img width="350" alt="26f720d9fa837900f91c8ff59d6fd815" src="https://github.com/langchain-ai/langchain/assets/16218592/740e0f7d-da60-4903-8d46-30e5e6c3faa2">
<img width="576" alt="02eee59006291866c52eda92921c9281" src="https://github.com/langchain-ai/langchain/assets/16218592/4de8f6dd-b154-4407-9153-b860a1f9a332">