delayedkarma/langchain-issues huggingface dataset:
fix: rename the invalid function name of GoogleSerperResults Tool for OpenAIFunctionCall
Labels: name: auto:bug

- Description: rename the invalid function name of GoogleSerperResults Tool for OpenAIFunctionCall
- Tag maintainer: @hinthornw

When I use the GoogleSerperResults in OpenAIFunctionCall agent, the following error occurs:
```shell
openai.error.InvalidRequestError: 'Google Serrper Results JSON' does not match '^[a-zA-Z0-9_-]{1,64}$' - 'functions.0.name'
```

So I rename the GoogleSerperResults's property "name" from "Google Serrper Results JSON" to "google_serrper_results_json" just like GoogleSerperRun's name: "google_serper", and it works.
I guess this should be reasonable.
saving and loading embedding from Chroma 
Labels: name: auto:question, name: auto:documentation

### Issue with current documentation:

```
# import
from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import Chroma
from langchain.document_loaders import TextLoader

# load the document and split it into chunks
loader = TextLoader("../../../state_of_the_union.txt")
documents = loader.load()

# split it into chunks
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)

# create the open-source embedding function
embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")

# load it into Chroma
db = Chroma.from_documents(docs, embedding_function)

# query it
query = "What did the president say about Ketanji Brown Jackson"
docs = db.similarity_search(query)

# print results
print(docs[0].page_content)
```

```
# save to disk
db2 = Chroma.from_documents(docs, embedding_function, persist_directory="./chroma_db")
db2.persist()
docs = db.similarity_search(query)

# load from disk
db3 = Chroma(persist_directory="./chroma_db")
docs = db.similarity_search(query)
print(docs[0].page_content)
```

### Idea or request for content:

In above code, I find it difficult to understand this paragraph:

```
# save to disk
db2 = Chroma.from_documents(docs, embedding_function, persist_directory="./chroma_db")
db2.persist()
docs = db.similarity_search(query)

# load from disk
db3 = Chroma(persist_directory="./chroma_db")
docs = db.similarity_search(query)
print(docs[0].page_content)
```
Although `db2 `and `db3 `do demonstrate the saving and loading of Chroma,
But Two pieces of code( `docs = db.similarity_search(query) `) have nothing to do with saving and loading, 
and it still searches for answers from the `db`
Is this an error?
Fixed typos in MongoDB Atlas Vector Search documentation
Labels: name: lgtm, name: auto:documentation

Fix for typos in MongoDB Atlas Vector Search documentation
<!-- Thank you for contributing to LangChain!

Replace this 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!

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
StreamlitCallbackHandler doesn't double escape dollar signs, so two dollar signs makes everything between an equation
Labels: name: auto:bug

### System Info

langchain = 0.0.220
python = 3.11.4


### Who can help?

@hwchase17 @agola11 

### Information

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

### Related Components

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

### Reproduction

1. Open the chat with search langchain/streamlit app[here](https://llm-examples.streamlit.app/Chat_with_search) and go to the "Chat with search" page
2. Ask "current meta and tesla stock price?" in the chat 
3. You should see in the response the formatting get messed up because it interprets two dollar signs as a latex equation. Normally I use a function to escape the dollar signs but you may want to do this on your callback. 

![Screenshot 2023-07-04 222201](https://github.com/hwchase17/langchain/assets/7920285/4a343791-5351-4914-937f-c6b61e3178c7)


### Expected behavior

Expect text instead of latex equation. I've attached an example I used with escapes. 
![Screenshot 2023-07-04 190042](https://github.com/hwchase17/langchain/assets/7920285/02cb3cf7-db4e-441d-ac50-4654df8a1083)
Update JSON parser to work w/ multiple JSON objects in markdown
Labels: name: auto:improvement

JSON output parser did not work on cases w/ multiple JSON objects.

Schema - 
```
response_schemas = [
    ResponseSchema(name="question", description="question derived from the text"),
    ResponseSchema(name="answer", description="answer to the question derived from the text"),
    ResponseSchema(name="index", description="approximate location in the text (charecter count) that the question is drawn from")
]
output_parser = StructuredOutputParser.from_response_schemas(response_schemas)
```

Answer - 
```
'\n```json\n{\n\t"question": "What is a black hole from a theoretical perspective?", \n\t"answer": "A black hole is defined theoretically as a region of space-time from which light can never escape, therefore it\'s black.",\n\t"index": "1230" \n}\n```\n\n```json\n{\n\t"question": "What is light?", \n\t"answer": "Light is the stuff that comes out of the sun, that stuff that goes into your eyes. Light is one of the stuff that disappears when the lights go off. This is stuff that appears when the lights come on.",\n\t"index": "1350"\n}\n```\n\n```json \n{\n\t"question": "What is the holographic principle?",\n\t"answer": "The holographic principle says that all the information that is in some volume of space-time can be stored on the boundary of that region.",\n\t"index": "11000"\n} \n```\n\n```json\n{\n\t"question": "What is a photon ring?",\n\t"answer": "A photon ring are the photons that orbit around a black hole.", \n\t'
```

Result we new see -
```
output_parser.parse(answer)
[{'question': 'What is a black hole from a theoretical perspective?',
  'answer': "A black hole is defined theoretically as a region of space-time from which light can never escape, therefore it's black.",
  'index': '1230'},
 {'question': 'What is light?',
  'answer': 'Light is the stuff that comes out of the sun, that stuff that goes into your eyes. Light is one of the stuff that disappears when the lights go off. This is stuff that appears when the lights come on.',
  'index': '1350'},
 {'question': 'What is the holographic principle?',
  'answer': 'The holographic principle says that all the information that is in some volume of space-time can be stored on the boundary of that region.',
  'index': '11000'}]
```
Implement delete interface of vector store on AnalyticDB
Labels: name: auto:improvement

Hi, there
  This pull request contains two commit:
     **1. Implement delete interface with optional ids parameter on AnalyticDB.**
     **2. Allow customization of database connection behavior by exposing engine_args parameter in interfaces.**
        - This commit adds the `engine_args` parameter to the interfaces, allowing users to customize the behavior of the database connection. The `engine_args` parameter accepts a dictionary of additional arguments that will be passed to the create_engine function. Users can now modify various aspects of the database connection, such as connection pool size and recycle time. This enhancement provides more flexibility and control to users when interacting with the database through the exposed interfaces.

This commit is related to VectorStores @rlancemartin @eyurtsev 

Thank you for your attention and consideration.
fix: Chroma filter symbols not supporting LIKE and CONTAIN
Labels: name: lgtm, name: auto:bug

Fixing issue with SelfQueryRetriever due to unsupported LIKE and CONTAIN comparators in Chroma's WHERE filter statements. This pull request introduces a redefined set of comparators in Chroma to address the problem and make it compatible with SelfQueryRetriever. For information on the comparators supported by Chroma's filter, please refer to https://docs.trychroma.com/usage-guide#using-where-filters.
<img width="495" alt="image" src="https://github.com/hwchase17/langchain/assets/22267652/34789191-0293-4f63-9bdf-ad1e1f2567c4">
RetrievalQA.from_chain_type‘s parameter retriever can not use ContextualCompressionRetriever
Labels: name: auto:bug

### System Info

Based on the official doc, I created two type of retriever:
1. `faiss_retriever = FAISS.from_documents(texts, OpenAIEmbeddings()).as_retriever()`serving as a`VectorStoreRetriever`(referenced from the API doc)
2. `compression_retriever = ContextualCompressionRetriever(base_compressor=relevant_filter, base_retriever=retriever)`functioning as a`ContextualCompressionRetriever` （also referenced from the API doc）

Then I ran the RetrievalQA to get relative content by Chain by code below:
```python
qa = RetrievalQA.from_chain_type(llm=OpenAI( verbose=True), chain_type="stuff", retriever=compression_retriever,return_source_documents=True, chain_type_kwargs=chain_type_kwargs)
# or
qa = RetrievalQA.from_chain_type(llm=OpenAI( verbose=True), chain_type="stuff", retriever=faiss_retriever,return_source_documents=True, chain_type_kwargs=chain_type_kwargs)
```

The result was that the qa with compression_retriever failed to return context for the prompt(return with empty array), whereas the qa with faiss_retriever successfully returned the context.



### Who can help?

@hwchase17 @eyurtsev 

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

```python
loader = UnstructuredFileLoader("NER.txt")
document = loader.load()
separators = ["。", " "]
text_splitter = RecursiveCharacterTextSplitter(separators=separators, chunk_size=500, chunk_overlap=0)
texts = text_splitter.split_documents(document)
embeddings = OpenAIEmbeddings()
relevant_filter = EmbeddingsFilter(embeddings=embeddings, similarity_threshold=0.81)
retriever = FAISS.from_documents(texts, OpenAIEmbeddings()).as_retriever() # base retriever
compression_retriever = ContextualCompressionRetriever(base_compressor=relevant_filter, base_retriever=retriever) # document compression retriver

from langchain.prompts import PromptTemplate
prompt_template1 = """plase use context to answer question.

{context}

question: {question}
anwser:"""
PROMPT = PromptTemplate(
    template=prompt_template1, input_variables=["context", "question"]
)
chain_type_kwargs = {"prompt": PROMPT,'verbose': True}
qa = RetrievalQA.from_chain_type(llm=OpenAI( verbose=True), chain_type="stuff", retriever=compression_retriever,return_source_documents=True, chain_type_kwargs=chain_type_kwargs)

query = "balabalabala" # replace it with question
result = qa({"query": query})
print(result)```

### Expected behavior

While using `ContextualCompressionRetriever` for `RetrievalQA` could output a not-null context., aka not [].
fix AmazonAPIGateway _identifying_params
Labels: name: auto:bug

- correct `endpoint_name` to `api_url`
- add `headers`

<!-- Thank you for contributing to LangChain!

Replace this 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!

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
DOC: The Quickstart tutorial for Agents has an error
Labels: name: auto:bug, name: auto:documentation

### Issue with current documentation:

https://python.langchain.com/docs/get_started/quickstart.html
On the above link, I have tried following along on google colab and ran into an issue as following:

Observation: Olivia Wilde started dating Harry Styles after ending her years-long engagement to Jason Sudeikis — see their relationship timeline.
Thought:I have found information about Olivia Wilde's boyfriend. Now I need to calculate his current age raised to the 0.23 power.

Action:
```
{
  "action": "Calculator",
  "action_input": "age ^ 0.23"
}
```

As you can see, instead of getting information about Harry Styles' age, it just puts in the string 'age' and raises value error.
This is quite weird seeing the tutorial for agents work well:
https://python.langchain.com/docs/modules/agents.html
What could be the issue?

### Idea or request for content:

_No response_
Support for SPARQL
Labels: name: auto:enhancement, name: auto:documentation

# [SPARQL](https://www.w3.org/TR/rdf-sparql-query/) for [LangChain](https://github.com/hwchase17/langchain)

## Description
LangChain support for knowledge graphs relying on W3C standards using RDFlib: SPARQL/ RDF(S)/ OWL with special focus on RDF \
* Works with local files, files from the web, and SPARQL endpoints
* Supports both SELECT and UPDATE queries
* Includes both a Jupyter notebook with an example and integration tests

## Contribution compared to related PRs and discussions
* [Wikibase agent](https://github.com/hwchase17/langchain/pull/2690) - uses SPARQL, but specifically for wikibase querying
* [Cypher qa](https://github.com/hwchase17/langchain/pull/5078) - graph DB question answering for Neo4J via Cypher
* [PR 6050](https://github.com/hwchase17/langchain/pull/6050) - tries something similar, but does not cover UPDATE queries and supports only RDF
* Discussions on [w3c mailing list](mailto:semantic-web@w3.org) related to the combination of LLMs (specifically ChatGPT) and knowledge graphs

## Dependencies
* [RDFlib](https://github.com/RDFLib/rdflib)

## Tag maintainer
Graph database related to memory -> @hwchase17
OpenAIFunctionsAgent + ConversationalChatAgent?
Labels: name: auto:enhancement

### Feature request

I'd like to make the user experience more conversational while supporting OpenAI functions. However, OpenAIFunctionsAgent implementation doesn't accept "memory" to make it more conversational. I'd like to have ReACT planning capability + functions as tools. I think the minimal implementation is to just add a memory to OpenAIFunctionsAgent.

### Motivation

While answering and executing tools is a great feature supported by OpenAIFunctionsAgent, more streamlined user experiences like chat are often desired as well.

### Your contribution

Happy to make a PR with a guideline if this is something desired in langchain.
Jinja2 validation changed to issue warnings rather than issuing exceptions.
Labels: name: lgtm, name: auto:improvement

  - Description: If their are missing or extra variables when validating Jinja 2 template then a warning is issued rather than raising an exception. This allows for better flexibility for the developer as described in  #7044.  Also changed the relevant test so pytest is checking for raised warnings rather than exceptions.
  - Issue: #7044 
  - Tag maintainer: @hwchase17, @baskaryan
SelfQuering Retrieval no support $contain operator
Labels: name: auto:bug

### System Info

I'm using the following on Windows:

Python 3.11.3
langchain 0.0.222
lark 1.1.5

With a Pinecone index:

Environment: us-east4-gcp
Metric: cosine
Pod Type: p1.x1
Dimensions: 1536

### Who can help?

@hwchase17  @angola

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

### Reproduction

from langchain.retrievers.self_query.base import SelfQueryRetriever

retriever = SelfQueryRetriever.from_llm(llm, vectorstore, document_content_description, metadata_description, verbose=True)
embeddings = OpenAIEmbeddings()
vectorstore= Pinecone.from_existing_index(index_name="index1",embedding=embeddings,namespace="metamovies")

# This example specifies a query and composite filter
relevantdocs=retriever.get_relevant_documents(
     "What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated")

### Expected behavior

a list of selected Documents

I get a runtime error:

query='toys' filter=Operation(operator=<Operator.AND: 'and'>, arguments=[Comparison(comparator=<Comparator.GT: 'gt'>, attribute='year', value=1990), Comparison(comparator=<Comparator.LT: 'lt'>, attribute='year', value=2005), Comparison(comparator=<Comparator.CONTAIN: 'contain'>, attribute='genre', value='animated')]) limit=None

HTTP response body: {"code":3,"message":"$contain is not a valid operator","details":[]}
Added ability to add extra fields to AzureSearch VectorStore when ad…
Labels: name: auto:improvement

  - Description: Added ability to add extra fields to AzureSearch VectorStore when adding documents, 
  - Issue:  https://github.com/hwchase17/langchain/issues/6134,
  - Dependencies: None,
  - Tag maintainer: @rlancemartin, @eyurtsev,
Update landing page for "question answering over documents"
Labels: name: auto:documentation

Improve documentation for a central use-case, qa / chat over documents.

This will be merged as an update to `index.mdx` [here](https://python.langchain.com/docs/use_cases/question_answering/).

Testing w/ local Docusaurus server:

```
From `docs` directory:
mkdir _dist
cp -r {docs_skeleton,snippets} _dist
cp -r extras/* _dist/docs_skeleton/docs
cd _dist/docs_skeleton
yarn install
yarn start
```
Add a callback handler for Context (https://getcontext.ai)
Labels: name: lgtm, name: auto:enhancement, name: auto:documentation

### Description

Adding a callback handler for Context. Context is a product analytics platform for AI chat experiences to help you understand how users are interacting with your product.

I've added the callback library + an example notebook showing its use.

### Dependencies

Requires the user to install the `context-python` library. The library is lazily-loaded when the callback is instantiated.

### Announcing the feature

We spoke with Harrison a few weeks ago about also doing a blog post announcing our integration, so will coordinate this with him. Our Twitter handle for the company is @getcontextai, and the founders are @_agamble and @HenrySG.

Tagging @agola11 for callbacks.

Thanks in advance!
Make "embedding" an optional parameter in VectorStore interface
Labels: name: auto:improvement

### Feature request

Some vectorstores (e.g. Vectara) internally create their own embeddings. The request is to generalize the VectorStore base class to allow for embeddings to be optional. 

### Motivation

Currently users have to send "None" or FakeEmbeddings instead, which creates additional work and is not needed.

### Your contribution

Happy to help with a PR (with guidance from the main project team)
docs: update Jina ecosystem
Labels: name: auto:documentation

Documentation update for [Jina ecosystem](https://python.langchain.com/docs/ecosystem/integrations/jina) and `langchain-serve` in the deployments section to latest features.

@hwchase17 

<!-- Thank you for contributing to LangChain!

Replace this 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!

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Issue: The API call keeps getting timed out
Labels: name: auto:bug, name: auto:question

### Issue you'd like to raise.

I keep getting this error for the past couple of days for gpt-3.5-turbo-16k:
Timeout: Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Read timed out. (read timeout=120.0)

The OpenAI API seems to be working fine by itself. Can someone please tell me if they are facing the same issue? Or any suggestions on how to resolve this?

### Suggestion:

_No response_