delayedkarma/langchain-issues huggingface dataset:
@dosu-bot
Labels: name: auto:bug, name: area: models

              @dosu-bot

The issue is that the "string indices must be indices", but your transformation does not deal with that. Here is the curretn code, please see below and change to avoid this error:

```from langchain.docstore.document import Document
from typing import Dict
from langchain import PromptTemplate, SagemakerEndpoint
from langchain.llms.sagemaker_endpoint import LLMContentHandler
from langchain.chains.question_answering import load_qa_chain
import json

example_doc_1 = """
string
"""

docs = [
    Document(
        page_content=example_doc_1,
    )
]

query = """
prompt
"""

prompt_template = """Use the following pieces of context to answer the question at the end.

{context}

Question: {question}
Answer:"""
PROMPT = PromptTemplate(
    template=prompt_template, input_variables=["context", "question"]
)

class ContentHandler(LLMContentHandler):
    content_type = "application/json"
    accepts = "application/json"

    def transform_input(self, prompt: str, model_kwargs: Dict) -> bytes:
        input_dict = {"inputs": prompt, "parameters": model_kwargs}
        return json.dumps(input_dict).encode('utf-8')

    def transform_output(self, output: bytes) -> str:
        response_json = json.loads(output.read().decode("utf-8"))
        print("output: ", response_json[0])
        return response_json[0]["generation"]

content_handler = ContentHandler()

chain = load_qa_chain(
    llm=SagemakerEndpoint(
        endpoint_name="endpointname",
        credentials_profile_name="profilename",
        region_name="us-east-1",
        model_kwargs={"temperature": 1e-10, "max_length":500},
        endpoint_kwargs={"CustomAttributes": "accept_eula=true"},
        content_handler=content_handler,
    ),
    prompt=PROMPT,
)

chain({"input_documents": docs, "question": query}, return_only_outputs=True)```

_Originally posted by @maggarwal25 in https://github.com/langchain-ai/langchain/issues/10012#issuecomment-1700300547_
Azure Cognitive Search Scoring Profile does not work as documented
Labels: name: area: vector store, name: auto:bug

### System Info

langchain                0.0.277
azure-search-documents   11.4.0b8
python 3.1.0.11

### Who can help?

@baskaryan
@ruoccofabrizio


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

Repro steps:
1. I took the code in https://github.com/langchain-ai/langchain/blob/master/docs/extras/integrations/vectorstores/azuresearch.ipynb and placed it in a python file and ran the chunk under "Create a new index with a Scoring profile"
2. I executed the code and got the following scores:

![image](https://github.com/langchain-ai/langchain/assets/7763701/b256a2cb-2310-4f77-a3c3-d7dff469fee5)

3. I went into the Azure Search Index and adjusted the "scoring_profile" to have a boost of 1000 instead of 100 and got the exact same scores.

### Expected behavior

I expected all of the score to be 10 times larger than the scores I got.  After much experimentation I do not believe that scoring profiles would with a vector search if a search term is specified.  If "None" is specified the behavior is correct.  Change the last  line of the example to:

`
res = vector_store.similarity_search(query="Test 1", k=3, search_type="similarity")`

And the results respect the Scoring profile and behave as expected when the scoring profile is changed.
Issues with llama-2-7b-f
Labels: name: auto:bug, name: area: models

### System Info

latest versions for python and langchain

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

### Reproduction

I used the demo code to run Sagemaker using Langchain for llama-2-7b-f

However, I'm getting the following issues:

```
ValueError: Error raised by inference endpoint: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (424) from primary with message "{
 "code":424,
 "message":"prediction failure",
 "error":"string indices must be integers"
}
```

This is what is shown from AWS Logs:
`[INFO ] PyProcess - W-80-model-stdout: [1,0]<stdout>:TypeError: string indices must be integers`

How do I resolve this

### Expected behavior

Shown:

```
ValueError: Error raised by inference endpoint: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (424) from primary with message "{
 "code":424,
 "message":"prediction failure",
 "error":"string indices must be integers"
}
```
Add ne comparator
Labels: name: area: vector store, name: auto:improvement

Description: Adds the not comparator and operator to pinecone, chroma and deeplake.
Issue: Not a registered issue but when using a selfqueryretriever with pinecone I got this error + stacktrace when I entered a query that asked to not include specific data: 
 
>  raised following `error:`
> Received unrecognized function ne. Valid functions are [<Operator.AND: 'and'>, <Operator.OR: 'or'>, <Operator.NOT: 'not'>, <Comparator.EQ: 'eq'>, <Comparator.GT: 'gt'>, <Comparator.GTE: 'gte'>, <Comparator.LT: 'lt'>, <Comparator.LTE: 'lte'>]

I noticed that chroma and deeplake also support not equals/not filtering so I added it there as well


[pinecone](https://docs.pinecone.io/docs/metadata-filtering#metadata-query-language)
[chroma](https://docs.trychroma.com/usage-guide#filtering-by-metadata)
[deeplake](https://docs.activeloop.ai/enterprise-features/compute-engine/querying-datasets/query-syntax#and-or-not)
Google drive integration (lite)
Labels: name: lgtm, name: area: doc loader, name: auto:enhancement

My other [pull-request](https://github.com/langchain-ai/langchain/pull/5135) is too big to be acceptable.
I propose another 'lite' version.

I update only notebook to propose an integration with the external project [`langchain-googledrive`](https://github.com/pprados/langchain-googledrive).
Buckler/dynamic retriever parameters
Labels: name: auto:improvement

Description: Enhance kwargs Support in Internal Retriever Method for EnsembleRetriever and MergerRetriever Classes

This pull request introduces a valuable enhancement to the EnsembleRetriever and MergerRetriever classes by allowing the seamless flow of keyword arguments (**kwargs) to the internal _get_relevant_document method. This improvement empowers these classes with greater flexibility and customization when invoking the _get_relevant_document method.

Changes Made:

Previously, the internal _get_relevant_document method within the EnsembleRetriever and MergerRetriever classes did not directly receive keyword arguments. This enhancement addresses this limitation by enabling the propagation of **kwargs directly to the said method. This enables developers to conveniently pass additional arguments and options, extending the capabilities of these retriever classes.

Benefits:

Enhanced Flexibility: With this enhancement, users can now pass arbitrary keyword arguments when calling the _get_relevant_document method within the EnsembleRetriever and MergerRetriever classes. This facilitates customizations, configuration adjustments, and integration with other components in a more seamless manner.

  - Tag maintainer:  @baskaryan 
  - Twitter handle: Buckler89
Solve the problem of working with incomplete document chunks and multiple documents
Labels: name: area: agent, name: area: doc loader, name: auto:enhancement

### Feature request

An agent for searching iteratively multiple documents without the problem of processing incomplete document chunks.
An option to include the metadata (source references) in the prompt.

### Motivation

Normally documents are split into chunks before being added to Chroma
When the data is queried, Chroma returns these chunks of incomplete documents and feed them to the prompt.
Thus, the LLM sometimes is not provided with the complete information and will fail to answer.
This is a big problem, especially when the split occurs in the middle of a list (eg: a text listing the 10 commandments of god).
The LLM won't have a chance to know they are 10.

Besides, LangChain "stuff" retriever is just mixing all these chunks together, without even separating them nor adding the documents metadata of each chunk. Mixing different sentences could confuse the LLM.
If this can be solved using document_prompt templates, this should be added to the documentation.
I would also expect to include document souces into the prompt, so the LLM and provide the used sources (not all sources retrieved by the Chroma query).

I blieve the queries should be processed by an agent with the ability to detect when there may be missing previous and/or following chunks in order to fetch them in a subsequent iteration if required.

### Your contribution

I can help coding and testing, but I need feedback for the design and to know which other existing componentes could/should be used.
refactor(document_loaders): abstract page evaluation logic in PlaywrightURLLoader
Labels: name: lgtm, name: area: doc loader, name: auto:refactor

This PR brings structural updates to `PlaywrightURLLoader`, aiming at making the code more readable and extensible through the abstraction of page evaluation logic. These changes also align this implementation with a similar structure used in LangChain.js. 

The key enhancements include:

1. Introduction of 'PlaywrightEvaluator', an abstract base class for all evaluators. 
2. Creation of 'UnstructuredHtmlEvaluator', a concrete class implementing 'PlaywrightEvaluator', which uses `unstructured` library for processing page's HTML content.
3. Extension of 'PlaywrightURLLoader' constructor to optionally accept an evaluator of the type 'PlaywrightEvaluator'. It defaults to 'UnstructuredHtmlEvaluator' if no evaluator is provided.
4. Refactoring of 'load' and 'aload' methods to use the 'evaluate' and 'evaluate_async' methods of the provided 'PageEvaluator' for page content handling.

This update brings flexibility to 'PlaywrightURLLoader' as it can now utilize different evaluators for page processing depending on the requirement. The abstraction also improves code maintainability and readability.

Please find the reference for LangChain.js implementation [here](https://github.com/hwchase17/langchainjs/blob/29f3ffdcb34acce1f1db78078f4e7d184eaec6b5/langchain/src/document_loaders/web/playwright.ts#L59).

Maintainers for review: @rlancemartin, @eyurtsev

Twitter: @ywkim
How to pass a custom prompt in graphQA or GraphCypherQA chain
Labels: name: auto:question, name: area: models

### Feature request

```
from langchain.chat_models import ChatOpenAI
from langchain.chains import GraphCypherQAChain
from langchain.graphs import Neo4jGraph
graph = Neo4jGraph(
    url="bolt://localhost:7687", username="neo4j", password="pleaseletmein"
)
chain = GraphCypherQAChain.from_llm(ChatOpenAI(temperature=0), graph=graph, verbose=True)
print(chain.run("Question to the graph"))
```
In the above Code, How can I pass my custom prompt as promptTemplate? Please give me an example

### Motivation

Custom prompt support in Knowledge Graph QA

### Your contribution

Custom prompt support in Knowledge Graph QA
implement vectorstores by tencent vectordb
Labels: name: lgtm, name: area: vector store, name: auto:enhancement

Hi there！
I'm excited to open this PR to add support for using 'Tencent Cloud VectorDB' as a vector store.

Tencent Cloud VectorDB is a fully-managed, self-developed, enterprise-level distributed database service designed for storing, retrieving, and analyzing multi-dimensional vector data. The database supports multiple index types and similarity calculation methods, with a single index supporting vector scales up to 1 billion and capable of handling millions of QPS with millisecond-level query latency. Tencent Cloud VectorDB not only provides external knowledge bases for large models to improve their accuracy, but also has wide applications in AI fields such as recommendation systems, NLP services, computer vision, and intelligent customer service.

The PR includes:
 Implementation of Vectorstore.

I have read your [contributing guidelines](https://github.com/hwchase17/langchain/blob/72b7d76d79b0e187426787616d96257b64292119/.github/CONTRIBUTING.md). And I have passed the tests below

 make format
 make lint
 make coverage
 make test
Chroma - retrieve all documents
Labels: name: area: vector store, name: auto:enhancement

### Feature request

When using Chroma vector store, the stored documents can only be retrieved when using a search query. There is no method which allows to load all documents. 

### Motivation

The closest thing to retrieving all documents is using
`vectordb._collection.get()` for which the output is a dictionary instead of document. This prevents filtering based on other retrievers which Chroma does not support like TF-IDF and BM25.

### Your contribution

Not yet.
mportError: cannot import name 'BaseLanguageModel' from 'langchain.schema' (/usr/local/lib/python3.10/dist-packages/langchain/schema/init.py)
Labels: name: auto:bug, name: area: models

### System Info

colab notebook

### Who can help?

@hwchase17 @agola

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

```
getting error: ---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-25-74e62d788fe7> in <cell line: 9>()
      7 import openai
      8 from langchain.chains import LLMBashChain, LLMChain, RetrievalQA, SimpleSequentialChain
----> 9 from langchain.chains.summarize import load_summarize_chain
     10 from langchain.chat_models import ChatOpenAI
     11 from langchain.docstore.document import Document

/usr/local/lib/python3.10/dist-packages/langchain/chains/summarize/init.py in <module>
      9 from langchain.chains.summarize import map_reduce_prompt, refine_prompts, stuff_prompt
     10 from langchain.prompts.base import BasePromptTemplate
---> 11 from langchain.schema import BaseLanguageModel
     12 
     13 

ImportError: cannot import name 'BaseLanguageModel' from 'langchain.schema' (/usr/local/lib/python3.10/dist-packages/langchain/schema/init.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
--------------------------------------------------------------------------- 
```
```
https://colab.research.google.com/drive/1xH7coRd2AnZFdejGQ2nyJWuNrTNMdvSa?usp=sharing
```

### Expected behavior

basic issues running the libraries
Generative Agents in LangChain Tool Integration
Labels: name: area: agent, name: auto:question, name: auto:enhancement

### Feature request

The generative Agents demo shows the generic individual conversation.
There are 2 features that I need clarity on. If these exist (if yes how to implement the same) or need to be worked on:

1. Tool integration of the agents. If the agents can integrate to some tool like a calendar or a clock to get the real time actions.
2. The agents wait for the response or the action to be completed by the other agent. Currently the agents reply to the response which is mostly a text response. The requirement here being is that the agents wait for the other agent's action to be completed which is non textual. 

### Motivation

The motivation here is the autonomous world simulation that hoes beyond the textual conversation between the agents.
Tool integration can bring in more realistic solutions to come into picture.

### Your contribution

I have read the paper and know the approach.
I can contribute on the development of the feature of that does not exist yet.
GCSFileLoader need to read blob's metadata and populate it to documents metadata
Labels: name: area: doc loader, name: area: vector store, name: auto:enhancement

### Feature request

GCS blobs can have custom metadata defined either in google console or programatic way as shown below

```
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(destination_blob_name)
metadata = {'from_source': 'https://localhost', 'genre': 'sci-fi'}
blob.metadata = metadata
blob.upload_from_filename("/home/jupyter/svc-mlp-staging.json", if_generation_match=0)

```
GCSFileLoader can get  blob's metadata if present and populate the same to document's metadata before returning docs. 



### Motivation

1. This feature can help load the documents with the required custom metadata. 
2. Splits (based on splitter) and vector embeddings of splits will be identified by custom metadata in vector store

### Your contribution

Interested in taking this up
update_forward_refs for Run
Labels: name: auto:bug, name: area: models

Adds a call to Pydantic's `update_forward_refs` for the `Run` class (in addition to the `ChainRun` and `ToolRun` classes, for which that method is already called). Without it, the self-reference of child classes (type `List[Run]`) is problematic. For example:

```python
from langchain.callbacks import StdOutCallbackHandler
from langchain.chains import LLMChain
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from wandb.integration.langchain import WandbTracer

llm = OpenAI()
prompt = PromptTemplate.from_template("1 + {number} = ")

chain = LLMChain(llm=llm, prompt=prompt, callbacks=[StdOutCallbackHandler(), WandbTracer()])
print(chain.run(number=2))

```

results in the following output before the change

```
WARNING:root:Error in on_chain_start callback: field "child_runs" not yet prepared so type is still a ForwardRef, you might need to call Run.update_forward_refs().

> Entering new LLMChain chain...
Prompt after formatting:
1 + 2 = 
WARNING:root:Error in on_chain_end callback: No chain Run found to be traced

> Finished chain.

3
```

but afterwards the callback error messages are gone.
fixed  openai_functions api_response format args err
Labels: name: auto:bug

   root cause: args may not have a key (params) resulting in an error

<!-- 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.
 -->
Bagatur/add data anonymizer
Labels: name: auto:enhancement

<!-- 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.
 -->