delayedkarma/langchain-issues huggingface dataset:
Issue: Search query based on the geoLocation using GoogleSearchAPIWrapper or SerpAPIWrapper
Labels: name: area: agent, name: auto:question

### Issue you'd like to raise.

Hi, I want to do the query based on my location. For example, what is the restaurant near me? I have Python code using SerpAPIWrapper and GoogleSearchAPIWrapper but none of the Api works based on location. below is my snippet code. 

GoogleSearchAPIWrapper:

`  
    latitude = 37.360334
    longitude = -121.994694

    query = "Restaurant near me?"

    search = GoogleSearchAPIWrapper(k=1) #  k parameter to set the number of results

    tool = Tool(
        name="Google Search",
        description="Search Google for recent results.",
        func=search.run,
    )

    answer = tool.run(query)
    print("answer:", answer)`
    
SerpAPIWrapper:

`
     latitude =37.360334# 37.379279 #37.360334
     longitude = -121.994694 #-121.960661 #-121.994694
     params = {
        "google_domain":"google.com",
        # "engine": "google",   # Set parameter to google to use the Google API engine.
        "type": "search",
        "engine":"google_maps",
        "gl": "us",
        "hl": "en",
        "ll" : "@{},{},14z".format(latitude,longitude)
    }

    search = SerpAPIWrapper(params=params)

    tools = [
        Tool(
            name = "search",
            func=search.run,
            description="Useful for when you need to answer questions about anything to google search"
        ),
    ]

    # require argument : expects to be used with a memory component.
    memory = ConversationBufferMemory(memory_key="chat_history")

    llm=OpenAI(temperature=0)
    agent_chain = initialize_agent(tools, llm, agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION, verbose=True, memory=memory)
agent_chain.run("resturant near me ?")
`

I want my search based on my location using latitude and longitude. Thanks in advance!


### Suggestion:

_No response_
Third branch
Labels: name: area: embeddings, name: auto:documentation

<!-- 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.
 -->
Output of running `bump-pydantic` on `libs/langchain`.
Labels: name: area: agent, name: auto:refactor

<!-- 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.
 -->
feat: add support for arxiv identifier in ArxivAPIWrapper()
Labels: name: lgtm, name: auto:improvement

  - Description: this PR adds the support for arxiv identifier of the ArxivAPIWrapper. I modified the `run()` and `load()` functions in `arxiv.py`, using regex to recognize if the query is in the form of arxiv identifier (see [https://info.arxiv.org/help/find/index.html](https://info.arxiv.org/help/find/index.html)). If so, it will directly search the paper corresponding to the arxiv identifier. I also modified and added tests in `test_arxiv.py`.
  - Issue: #9047 
  - Dependencies: N/A
  - Tag maintainer: N/A
Add bucket and object key to metadata in S3 loader
Labels: name: lgtm, name: area: doc loader, name: auto:improvement

  - Description: this PR adds `s3_object_key` and `s3_bucket` to the doc metadata when loading an S3 file. This is particularly useful when using `S3DirectoryLoader` to remove the files from the dir once they have been processed (getting the object keys from the metadata `source` field seems brittle)
  - Dependencies: N/A
  - Tag maintainer: ?
  - Twitter handle: _cbornet
Airbyte loaders: Fix last_state getter
Labels: name: area: doc loader, name: auto:bug

This PR fixes the Airbyte loaders when doing incremental syncs. The notebooks are calling out to access `loader.last_state` to get the current state of incremental syncs, but this didn't work due to a refactoring of how the loaders are structured internally in the original PR.

This PR fixes the issue by adding a `last_state` property that forwards the state correctly from the CDK adapter.
'delete' function is not implemented in PGVector
Labels: name: area: vector store, name: auto:bug

### System Info

langchain version 0.0.266, using python3

### Who can help?

@eyurtsev 
@ago

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

### Reproduction

from langchain.embeddings import VertexAIEmbeddings
from langchain.vectorstores import PGVector

embeddings = VertexAIEmbeddings()

vectorstore = PGVector(
    collection_name=<collection_name>,
    connection_string=<connection_string>,
    embedding_function=embeddings,
)

vectorstore.delete(ids=[<some_id>])

### Expected behavior

the vector will be deleted, no error will be arosed
Use original_question if SelfQueryRetriever if the filter is empty
Labels: name: area: vector store, name: auto:bug

### System Info

langchain 0.0.266

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

### Reproduction

In the SelfQueryRetriever, the code try to generate a filter, and simplifies the question.
But, if the first step can not generate que specific filter, the simplified version of the question is used. This changes the answer completely.
It's possible to use `use_original_query` to force the usage of the original query.
But, I think if it's possible to generate a filter, it's a good idea to use the simplified version of the question.
Else, it's necessary to use the original question, because the filter is no longer involved.

Ask a question with a filter, but the filter is not associated with the `metadata_field_info`.
The calculated filter is empty and the simplified version is used.

### Expected behavior

I think if it's possible to generate a filter, it's a good idea to use the simplified version of the question.
Else, it's *necessary* to use the original question, because the filter is no longer involved.
Use the default query if the generated filter is empty.
Labels: name: auto:improvement

In the SelfQueryRetriever, the code try to generate a filter, and simplifies the question.
But, if the first step can not generate que specific filter, the simplified version of the question is used. This changes the answer completely.
It's possible to use `use_original_query` to force the usage of the original query.
But, I think if it's possible to generate a filter, it's a good idea to use the simplified version of the question.
Else, it's necessary to use the original question, because the filter is no longer involved.
Huggingface TextGen Inference streaming example not working
Labels: name: auto:bug, name: auto:documentation, name: area: models

### System Info

Latest Python and LangChain version.

### 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

1. Go to the documentation: https://python.langchain.com/docs/integrations/llms/huggingface_textgen_inference
2. Test the `Streaming` example:
```
from langchain.llms import HuggingFaceTextGenInference
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler


llm = HuggingFaceTextGenInference(
    inference_server_url="http://localhost:8010/",
    max_new_tokens=512,
    top_k=10,
    top_p=0.95,
    typical_p=0.95,
    temperature=0.01,
    repetition_penalty=1.03,
    stream=True
)
llm("What did foo say about bar?", callbacks=[StreamingStdOutCallbackHandler()])
```

Throws an error:
```
pydantic.error_wrappers.ValidationError: 1 validation error for HuggingFaceTextGenInference
stream
  extra fields not permitted (type=value_error.extra)
```

But `streaming=True` worked. So maybe it's a typo in the documentation.

### Expected behavior

To get working the example.
`create_csv_agent` fails due to arguments from pandas not being valid JSON.
Labels: name: area: agent, name: auto:bug

### System Info

LangChain `v0.0.264`

### Who can help?

@hwchase17 @eyurtsev 

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

### Reproduction

1. Create an agent using `create_csv_agent`. 
2. Add the attached CSV
3. Run a query: `What is my MONTHLY BUDGET SUMMARY`
[Personalbudget.csv](https://github.com/langchain-ai/langchain/files/12359540/Personalbudget.csv)

Trace:

```
raise OutputParserException(
langchain.schema.output_parser.OutputParserException: Could not parse tool input: {'name': 'python', 'arguments': "summary_row = df[df['Personal Monthly Budget'] == 'MONTHLY BUDGET SUMMARY']\nsummary_row"} because the `arguments` is not valid JSON.
```

### Expected behavior

The arguments passed to the parser should be always be valid JSON.
RecursiveCharacterTextSplitter splits even if text is smaller than chunk size
Labels: name: area: doc loader, name: auto:bug

### System Info

Python 3.10.12
Langchain  0.0.266

### Who can help?

@eyurtsev

### Information

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

### Related Components

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

### Reproduction

Import any loader or just directly use the RecursiveCharacterTextSplitter

define chunk size to lets say 3950 

Get a text that is way smaller, for example 1k tokens.

run the text splitter and recieve multiple documents.

```
from langchain.text_splitter import SentenceTransformersTokenTextSplitter
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.document_loaders.youtube import YoutubeLoader

def get_token_count(text):
    splitter = SentenceTransformersTokenTextSplitter(chunk_overlap=0)
    text_token_count = splitter.count_tokens(text=text.replace("\n"," "))
    return text_token_count

text_splitter = RecursiveCharacterTextSplitter(separators=["\n\n", "\n", " "], chunk_size=3950, chunk_overlap=100)

def summarize_youtube_video(youtube_url: str) -> str:
    """
    Useful to get the summary of a youtube video. Applies if the user sends a youtube link.
    """
    id_input = youtube_url.split("=")[1]
    splitter = text_splitter
    loader = YoutubeLoader(id_input)
    docs = loader.load_and_split(splitter)
    return docs

docs = summarize_youtube_video("https://www.youtube.com/watch?v=vXIkc40UiH0")

for item in docs:
    print(get_token_count(item.page_content))
```

![screenshot_20230816135005](https://github.com/langchain-ai/langchain/assets/72946124/249cccf3-1209-4929-b62d-cf8acaed4ff8)


### Expected behavior

If the text is smaller than the chunk size, only one document should get returned.
Add the possibility to configure boto3 in the S3 loaders
Labels: name: area: doc loader, name: auto:improvement

  - Description: this PR adds the possibility to configure boto3 in the S3 loaders. Any named argument you add will be used to create the Boto3 session. This is useful when the AWS credentials can't be passed as env variables or can't be read from the credentials file.
  - Issue: N/A
  - Dependencies: N/A
  - Tag maintainer: ?
  - Twitter handle: cbornet_
other llm api
Labels: name: auto:question, name: area: models

### Issue you'd like to raise.

Hello, I have a question, I didn't find it from the official documentation, I want to know, if I have another llm now, he provides me with a calling api, how can I do it, can it be used like openai, such as This https://python.langchain.com/docs/use_cases/sql in the official document, I want to replace openai with my API provided by others, what should I do?

### Suggestion:

_No response_
Issue: embedding rate limit error
Labels: name: area: embeddings, name: auto:question

### Issue you'd like to raise.

Retrying langchain.embeddings.openai.embed_with_retry.<locals>._embed_with_retry in 4.0 seconds as it raised RateLimitError: Rate limit reached for default-text-embedding-ada-002 in organization org-uIkxFSWUeCDpCsfzD5XWYLZ7 on tokens per min. Limit: 1000000 / min. Current: 837303 / min. Contact us through our help center at help.openai.com if you continue to have issues..

how can i fix this?

### Suggestion:

_No response_
Issue: `ApifyWrapper` was removed from the codebase breaking user's code
Labels: name: auto:bug, name: auto:improvement

### Issue you'd like to raise.

In LangChain 0.0.240, the `ApifyWrapper` class was removed. This caused a breaking change and broke any code using this class.

It was deleted in this PR https://github.com/langchain-ai/langchain/pull/8106 @hwchase17 

Could you please outline the reason it was removed?

Other issues related to this one: https://github.com/langchain-ai/langchain/issues/8201 and https://github.com/langchain-ai/langchain/issues/8307

### Suggestion:

I'd suggest adding the integration back so that code written using it will continue to work.

I'm offering to take ownership of the Apify-related code, so if any issue arises, you can just tag me and I'll resolve it.
Guide import readable json
Labels: name: auto:documentation

<!-- 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.
 -->
fix(llms): improve the ernie chat model
Labels: name: auto:improvement, name: area: models

<!-- 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: improve the ernie chat model.
   - fix missing kwargs to payload
   - new test cases
   - add some debug level log
   - improve description
- Issue: None
- Dependencies: None
- Tag maintainer: @baskaryan
Object of type SystemMessage is not JSON serializable
Labels: name: auto:bug, name: area: models

### System Info

0.0.247

### Who can help?

@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
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

run
```
messages = []
messages.append(SystemMessage(content="abc1"))
json.dumps(messages, ensure_ascii=False)
```
```
  File "C:\Users\64478\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "C:\Users\64478\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\64478\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\64478\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type SystemMessage is not JSON serializable
```

### Expected behavior
I think this might not be a bug

But Would be best if JSON output is (since I am using openai):
```
{"role": "system", "message": "abc1你好"}
```

How can I do this ?


----------
What ai says is not as expected:

```
from langchain.load.dump import dumps

message1 = SystemMessage(content="abc1你好")

message2 = HumanMessage(content="123")
messages = [message1, message1]

print(dumps(messages))
```

is printing:

```json
[{"lc": 1, "type": "constructor", "id": ["langchain", "schema", "messages", "SystemMessage"], "kwargs": {"content": "abc1\u4f60\u597d"}}, {"lc": 1, "type": "constructor", "id": ["langchain", "schema", "messages", "SystemMessage"], "kwargs": {"content": "abc1\u4f60\u597d"}}]
```

And how can I use ensure_ascii with langchain.load.dump ?
Remove summarization from VALID TASKS tuple
Labels: name: auto:bug, name: area: models

In llms.huggingface_endpoint.py, remove summarization from VALID_TASKS because docstring says that summarization is not supported. Also, when trying summarization task, we get an error `KeyError: 'summary_text'` from huggingface endpoint.


resolves #9286


  - Twitter handle: @Zorns_Lemma

@baskaryan
KeyError: 'summary_text' when trying HuggingFaceEndpoint with task = "summarization" even when the VALID_TASKS include it 
Labels: name: auto:bug, name: area: models

### System Info

LangChain 0.0.265, Mac M2 Pro Hardware. Python 3.10.0



### Who can help?

@hwchase17 
@ago

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

llm = HuggingFaceEndpoint(endpoint_url=" task = "summarization",huggingfacehub_api_token
vectorstore_multi_qa = Pinecone(index, embedding_multi_qa.embed_query, "text")
qa_chain = RetrievalQAWithSourcesChain.from_llm(
                                llm=llm,
                                #chain_type="stuff", 
                                retriever=vectorstore_multi_qa.as_retriever(),
                                return_source_documents=True)
query = "What is Blockchain?"
# Send question as a query to qa chain
result = qa_chain({"question": query})

### Expected behavior

Return something