delayedkarma/langchain-issues huggingface dataset:
Issue: Question about Deletion of Embeddings for Confluence Spaces
Labels: name: area: embeddings, name: auto:bug, name: integration: chroma

### Issue you'd like to raise.


I'm currently working on a project and have encountered an issue with the deletion functionality for Confluence 
Spaces. I've implemented a function delete_embeddings that is supposed to delete embeddings based on the Confluence space key, but it doesn't seem to be working as expected.
Here's the relevant code snippet:
def delete_embeddings(file_path, persist_directory):
    chroma_db = chromadb.PersistentClient(path=persist_directory)
    collection = chroma_db.get_or_create_collection(name="langchain")
    ids = collection.get(where={"source": file_path})['ids']
    collection.delete(where={"source": file_path},ids=ids)
    # chroma_db.delete_collection(name="langchain")
    print("delete successfully")
    And I'm calling this function as follows:
    delete_embeddings(names, persist_directory)
I want to delete embeddings of Confluence Spaces when user request deletion confluence space.


### Suggestion:

_No response_
Advance metadata filtering for PGVector
Labels: name: area: vector store, name: auto:improvement, name: integration: pinecone

### Feature request

PGVector in Langchain does not support advance metadata filtering such as "OR" clause.
For now, there is no way to perform filters such as:

```
{
"$or": [
     {"uploaded_by": {"$eq": "USER1"}},
     {"org": {"$eq": "ORG"}},
  ]
}
```

### Motivation

Our team is unable to use langchain with PGVector due to its lack of support for "OR" filter.
Having advanced metadata filtering like that in Pinecone/Qdrant would really help

https://docs.pinecone.io/docs/metadata-filtering

### Your contribution

For now, I see existing PR: https://github.com/langchain-ai/langchain/pull/12977
This could possibly solve the issue.
Issue: Question about Deletion Functionality for Confluence Spaces
Labels: name: area: embeddings, name: area: vector store, name: auto:bug, name: integration: chroma

### Issue you'd like to raise.


I'm currently working on a project and have encountered an issue with the deletion functionality for Confluence Spaces. I've implemented a function `delete_embeddings` that is supposed to delete embeddings based on the Confluence space key, but it doesn't seem to be working as expected.
Here's the relevant code snippet:

```python
def delete_embeddings(file_path, persist_directory):
    chroma_db = chromadb.PersistentClient(path=persist_directory)
    collection = chroma_db.get_or_create_collection(name="langchain")
    ids = collection.get(where={"source": file_path})['ids']
    collection.delete(where={"source": file_path},ids=ids)
    # chroma_db.delete_collection(name="langchain")
    print("delete successfully")
    And I'm calling this function as follows:
delete_embeddings(names, persist_directory)

### Suggestion:

_No response_
DOC: Dropbox document loader functionality
Labels: name: area: doc loader, name: auto:question, name: auto:documentation

### Issue with current documentation:

I was hoping to use the Dropbox document loader for a large number of pdf and some docx documents, however I am not sure whether this loader supports these file types. I followed the instructions on https://python.langchain.com/docs/integrations/document_loaders/dropbox and installed the "unstructured[all-docs]" package but I keep getting the message that the loader skips these files. 

> xxx.docx could not be decoded as text. Skipping.
> yyy.pdf could not be decoded as text. Skipping.

Does this loader only support .txt files? Is there an alternative? I see the Unstructured loader only works for individual files, is that the best alternative? 

Many thanks!

### Idea or request for content:

File formats the loader supports needs to be clarified
unstructured package was given as a prerequisite for pdf files but I was getting missing package/method errors until I installed the "unstructured[all-docs]" package and still not able to load pdf files
PineconeProtocolError: Failed to connect; did you specify the correct index name?
Labels: name: area: vector store, name: auto:bug, name: integration: pinecone

### System Info

To train data in Pinecone, I used the function.
_pinecone = Pinecone.from_documents(docs, self.embeddings, index_name=self.index_name)

all the parameters have values always:
![image](https://github.com/langchain-ai/langchain/assets/47790805/da013cf4-a082-44d0-9505-0013835c4b90)

![image](https://github.com/langchain-ai/langchain/assets/47790805/6764a84c-a59c-43a5-9dfe-4ecea69e68ef)

But, this error occurs often like this: 
![image](https://github.com/langchain-ai/langchain/assets/47790805/9aee7fed-49c4-4e6e-941f-94c3f442244c)

 @hwchase17 , I am looking forward to fixing this issue asap. Thank you.


### Who can help?

_No response_

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

class PineConeIndexer:
    
    def __init__(self):
        self.embeddings = OpenAIEmbeddings()

        # initialize pinecone
        pinecone.init(
            api_key=os.environ.get('PINECONE_API_KEY'), 
            environment=os.environ.get('PINECONE_ENV') 
        )

        self.index_name = os.environ.get('PINECONE_INDEX_NAME')

   def upsert_index_from_task(self, task):
        try:
           # get doc
            ....
            _pinecone = Pinecone.from_documents(docs, self.embeddings, index_name=self.index_name)
            return {"success": True, "error": None}
        except Exception as e:
            return {"success": False, "error": str(e)}

### Expected behavior

sometimes, this error occurs: 

PineconeProtocolError
Failed to connect; did you specify the correct index name?

ProtocolError
('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
Fix Mathpix PDF loader integration
Labels: name: lgtm, name: area: doc loader, name: auto:bug, name: size:S

  - **Description:** Fixes the Mathpix PDF loader API integration. Specifically, ensures that Mathpix auth headers are provided for every request, and ensures that we recognize all errors that can occur during a request. Also, the option to provide API keys as kwargs never actually worked before, but now that's fixed too.
  - **Issue:** #11249
  - **Dependencies:** None
Tmp
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.
 -->
'HTTPClient' object has no attribute 'configuration'
Labels: name: auto:bug, name: area: models

### System Info

machine: mackbook pro Sonoma 14.1.1
package:
python = "3.10.13"
openai = "^0.28.1"
pandas = "^2.1.1"
ipython = "^8.16.0"
langchain = "^0.0.306"
python-dotenv = "^1.0.0"
seaborn = "^0.13.0"
tqdm = "^4.66.1"
torch = "^2.1.0"
transformers = "^4.35.2"
accelerate = "^0.24.1"
sentencepiece = "^0.1.99"
openllm = "^0.4.27"

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

follow the instruction https://python.langchain.com/docs/integrations/llms/openllm
1)openllm start dolly-v2
2)
from langchain.llms import OpenLLM
server_url = "http://localhost:3000"  # Replace with remote host if you are running on a remote server
llm = OpenLLM(server_url=server_url)
llm("what is the meaning of life")

error:
line 229 /langchain/llms/openllm.py 220
AtrributionError: "HttpClient" object has not attribute 'configuration'

### Expected behavior

return a response from LLM
add volcengine endpoint for LLM
Labels: name: auto:enhancement, name: area: models, name: size:XL

  - **Description:** Volc Engine MaaS serves as an enterprise-grade, large-model service platform designed for developers. You can visit its homepage at https://www.volcengine.com/docs/82379/1099455 for details. This change will facilitate developers to integrate quickly with the platform.
  - **Issue:** None
  - **Dependencies:** volcengine
  - **Tag maintainer:** @baskaryan 
  - **Twitter handle:** @he1v3tica
To support open v1 SDK proxy setting
Labels: name: area: embeddings, name: auto:improvement, name: area: models

### System Info

langchain 0.0.340

### Who can help?

@hwchase17 @agola11 

### Information

- [ ] 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

After openai v1 sdk the previous method openai.proxy = {xxx} is no longer supported. But langchain is still using it.
It seems openai v1 sdk only support to set proxy on client level. see this issue on open ai sdk repo https://github.com/openai/openai-python/issues/825#issuecomment-1826047567
 

### Expected behavior

Should implement the way openai sdk required to set proxy
Issue: create agent takes multiple variables 
Labels: name: area: agent, name: auto:improvement

### Issue you'd like to raise.

It seems like that the agent can only take one variable "input".
I would like to create an agent with a custom prompt template that takes multiple variables whenever a user types something. like agent_executor.invoke({"input": "what is my name", "example":example, "user_profile":user_profile})
the custom prompt template looks like """
user input: {input}
example: {example}
user_profile : {user_profile}


### Suggestion:

_No response_
devcontainer fail to built
Labels: name: auto:bug

### Issue you'd like to raise.

trying building devcontainer following steps in doc ~/langchain/.devcontainer/README.md, but stuck at step10/11
<img width="876" alt="Screen Shot 2023-11-27 at 7 56 30 PM" src="https://github.com/langchain-ai/langchain/assets/97558871/3b8c803c-bdce-410d-8b7a-19fb0d1bc692">


### Suggestion:

_No response_
Added DGraphQAChain for DGraph databases
Labels: name: auto:enhancement, name: size:XXL

**Description:**
Added DGraphQAChain, a question answering chain for DGraph, a GraphQL powered database, extending LangChain's outreach to DGraph clients, and the DGraph community overall.

This pull request seamlessly integrates DGraph and DGraphQAChain, offering functionality similar to the other graph database integrations. Noteworthy differentiators include the introduction of an "experimental_dql_syntax_injection" flag. When activated, this feature injects text extracted from the DGraph Query Syntax guidelines page, providing valuable context to enhance the performance of less proficient Language Models and increase the likelihood of generating valid queries.

This pull requests also contains some sample queries which can be injected into the DGraphQAChain, with the use_generic_query_examples flag.

**issue**
https://github.com/langchain-ai/langchain/issues/11533

**Dependencies:**
[pydgraph](https://pypi.org/project/pydgraph/1.0.0a2/)

**Tag maintainer:**
@baskaryan 

Apart of UofT's CSCD01: Engineering Large Software Course 😄
Extend serpapi tools
Labels: name: area: agent, name: auto:enhancement, name: size:XXL

  - **Description:** Added some of the more endpoints supported by serpapi that are not suported on langchain at the moment, like google trends, google finance, google jobs, and google lens
  - **Issue:** [Add support for many of the querying endpoints with serpapi #11811](https://github.com/langchain-ai/langchain/issues/11811)
Added DGraphQAChain for DGraph databases
Labels: name: auto:enhancement, name: size:XXL

**Description:**
Added DGraphQAChain, a question answering chain for DGraph, a GraphQL powered database, extending LangChain's outreach to DGraph clients, and the DGraph community overall.

This pull request seamlessly integrates DGraph and DGraphQAChain, offering functionality similar to the other graph database integrations. Noteworthy differentiators include the introduction of an "experimental_dql_syntax_injection" flag. When activated, this feature injects text extracted from the DGraph Query Syntax guidelines page, providing valuable context to enhance the performance of less proficient Language Models and increase the likelihood of generating valid queries.

**issue**
https://github.com/langchain-ai/langchain/issues/11533

**Dependencies:**
[pydgraph](https://pypi.org/project/pydgraph/1.0.0a2/)

**Tag maintainer:**
@baskaryan
Issue: create_sql_agent omits and limits actual information retrieved from SQL tables
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

When utilizing the create_sql_agent module by LangChain to interact with a SQL database and generate SQL queries from natural language, I've encountered an issue with the responses. Currently, when I execute queries, the SQL Agent responds with placeholder information, citing security reasons for omitting the actual data. However, for my use case, it is crucial to receive the real information retrieved from the SQL database tables.

Also, it limits the information as well even with `top_k=50`. The database return 50 records but in the output it only shows 10-12 with the following output: Please note that this is a partial list. There are more ...

langchain == 0.0.313
langchain-experimental == 0.0.32

```
dbmssql = SQLDatabase.from_uri(
        connection_url,
        include_tables=[
            "table_1",
            "table_2",
            "table_3",
            "table_4",
        ],
        view_support=False
    )

chat_llm = ChatOpenAI(
    model="gpt-4",
    temperature=0,
    verbose=True,
    openai_api_key=openai_api_key,
    request_timeout=600
)

def create_mssql_db_agent(dbmssql):

    few_shot_docs = [
        Document(page_content=question, metadata={
            "sql_query": few_shots[question]})
        for question in few_shots.keys()
    ]
    vector_db = FAISS.from_documents(few_shot_docs, embeddings)
    retriever = vector_db.as_retriever()

    tool_description = """
    This tool will help you understand similar examples to adapt them to the user question.
    Input to this tool should be the user question.
    """

    retriever_tool = create_retriever_tool(
        retriever, name="sql_get_similar_examples", description=tool_description
    )
    custom_tool_list = [retriever_tool]

    custom_suffix = """
    I should first get the similar examples I know.
    If the examples are enough to construct the query, I can build it.
    Otherwise, I can then look at the tables in the database to see what I can query.
    Then I should query the schema of the most relevant tables
    """

    agent = create_sql_agent(
        agent_executor_kwargs={"return_intermediate_steps": True},
        llm=chat_llm,
        toolkit=SQLDatabaseToolkit(db=dbmssql, llm=chat_llm),
        verbose=True,
        agent_type=AgentType.OPENAI_FUNCTIONS,
        extra_tools=custom_tool_list,
        suffix=custom_suffix,
        top_k=50,
        # return_intermediate_steps=True
    )
    return agent
```

### Suggestion:

_No response_
Update prompt injection model
Labels: name: auto:improvement, name: area: models, name: size:M

  - **Description:** Existing model used for Prompt Injection is quite outdated but we fine-tuned and open-source a new model based on the same model deberta-v3-base from Microsoft - [laiyer/deberta-v3-base-prompt-injection](https://huggingface.co/laiyer/deberta-v3-base-prompt-injection). It supports more up-to-date injections and less prone to false-positives.
  - **Dependencies:** No
  - **Tag maintainer:** -
  - **Twitter handle:** @alex_yaremchuk
Allow intercepting agents' final answers and reporting feedback to them
Labels: name: area: agent, name: auto:enhancement, name: area: models

### Feature request
Allow intercepting agents' final answers and reporting any feedback on the final answers to the agents without ending the agent execution chain.

This will enable users to, for example, run validations on the final answer (e.g. whether the answer contains some keywords) or agent's state (whether agent has used a particular tool) and report issues to the agent so that it can fix the problems before ending the chain.

### Motivation

Today, we don't have a way to run an analysis on final answers and report problems (if any) to the agents so that they can fix the problems without losing the thoughts and observations of the current chain (if there's a way to achieve that today, please feel free to point me to it and close this issue). This feature will allow self-correction of final answers, further enhancing the capabilities of agents.

Some use cases I have in mind include
1. Validate the final answer to ensure that it conforms to some instructions, e.g. by making an LLM call.
2. Make sure the agent has used a set of tools to come up with the answer.
3. Apply some rules on the answer to determine whether answer is correct or not, e.g. whether the answer contains certain keywords.

### Your contribution

I'm not able to contribute currently, however, I might be able to pick this up in coming weeks if it seems useful to others as well.
Adding `infinity` embedding integration. 
Labels: name: needs documentation, name: area: embeddings, name: auto:enhancement, name: size:XL

This adds integation to https://github.com/michaelfeil/infinity. Users requested it in https://github.com/michaelfeil/infinity/issues/36 @saatvikshah

Follows my implementation of gradient.ai.

Feedback 1: Well done -  I love your CI / repo / poetry setup - I adapted a lot in https://github.com/michaelfeil/infinity.
Feedback 2: Not so good: The openai integration contains to much reverse engineering - in general projects such as michaelfeil/infinity and huggingface/text-embeddings-inference are compatible to the `pip install openai` package. 

Reverse engineering like this one is really hindering the use for me:
https://github.com/langchain-ai/langchain/blob/8e88ba16a88affc272da4bb99bd515b714781179/libs/langchain/langchain/embeddings/openai.py#L347
https://github.com/langchain-ai/langchain/blob/8e88ba16a88affc272da4bb99bd515b714781179/libs/langchain/langchain/embeddings/openai.py#L351 - it is about preventing 3rd party providers to use the same url + uses interfaces of openai, that are not publically documented. 


<!-- 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.
 -->
Filtering Issue with ConversationRetrievalChain
Labels: name: area: vector store, name: auto:bug, name: auto:question, name: area: models

Hi everyone,

I'm trying to do something and I haven´t found enough information on the internet to make it work properly with Langchain. Here it is:

I want to develop a QA chat using pdfs as knowledge source, using as relevant documents the ones corresponding to a certain pdf that the user will choose with a select box. To achieve that:

1. I've built a Azure Search vector store in which all the embeddings of different documents are stored.

Each document's metadata looks something like this: 
{
  "@odata.context": "https://blublu.search.windows.net/indexes('embeddings')/$metadata#docs(*)",
  "@search.nextPageParameters": {
    "search": "*",
    "top": null,
    "skip": 50
  },
  "value": [
    {
      "@search.score": 1,
      "id": "doc_embeddings_7102233d903cd1ac7475a60c373a716b57bf1586",
      "title": "https://blahblah.blob.core.windows.net/documents/converted/100.pdf.txt",
      "content": " Officer | Immediate line manager | Region/Division head or VP of the corresponding vertical | KFSL HR |  | CEO | \n|Assistant Manager |  | \n|Manager | CEO.\nv",
      "content_vector": [
        -0.0014578825,
        -0.0058897766],
      "tag": "",
      "metadata": "{\"source\": \"[https://ask}"
    },...}
    
    3.With all this I'm using a ConversationalRetrievalChain to retrieve info from the vector store and using an llm to answer questions entered via prompt:
class FilteredRetriever:
            def __init__(self, retriever, filter_prefix):
                self.retriever = retriever
                self.filter_prefix = filter_prefix

            def retrieve(self, *args, **kwargs):
                results = self.retriever.retrieve(*args, **kwargs)
                return [doc for doc in results if doc['value']['title'].startswith(self.filter_prefix)]

        source='https://blahblah.blob.core.windows.net/documents/converted/100.pdf.txt'
        filtered_retriever = FilteredRetriever(self.vector_store.as_retriever(), source)
        
        chain = ConversationalRetrievalChain(       
            retriever=filtered_retriever,
            question_generator=question_generator,
            combine_docs_chain=doc_chain,
            return_source_documents=True,
            # top_k_docs_for_context= self.k
        )
        
        But this is raising: instance of BaseRetriever expected (type=type_error.arbitrary_type; expected_arbitrary_type=BaseRetriever)




### Suggestion:

Have already referred [Filtering retrieval with ConversationalRetrievalChain](https://github.com/langchain-ai/langchain/issues/7474#top)
#7474