delayedkarma/langchain-issues huggingface dataset:
pip install langchain[all] takes forever to resove dependencies
Labels: name: auto:bug

### System Info

This is on `Python 3.10.6`, on a clean virtual env, on `Ubuntu 22.04` server w/o any GPU installed. 

On the other hand, `pip install langchain[llms]` installs without problem.

Here is the output of `pip install langchain[all]`, for langchain==0.0.234
[1.txt](https://github.com/hwchase17/langchain/files/12064621/1.txt)


### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

Steps to reproduce
1. Create venv
2. Source activation script to enter venv
3. pip install langchain[all]

Langchain version tested is 0.0.234.

### Expected behavior

Install w/o having to try multiple versions of dependencies
MultiQueryRetriever.from_llm has abandon param type BaseLLM
Labels: name: area: vector store, name: auto:bug

### System Info

MAC OS M2 
langchain: 0.0.234

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

MultiQueryRetriever.from_llm has abandon param type BaseLLM
```
@classmethod
    def from_llm(
        cls,
        retriever: BaseRetriever,
        llm: BaseLLM,
        prompt: PromptTemplate = DEFAULT_QUERY_PROMPT,
        parser_key: str = "lines",
    ) -> "MultiQueryRetriever":
```
when I use OpenAI, it prints warning: 
```
UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: `from langchain.chat_models import ChatOpenAI`
```
llm parameter type looks like it needs to be changed to BaseLanguageModel

### Expected behavior

llm parameter type looks like it needs to be changed to BaseLanguageModel
HuggingFaceEndpoint returns truncated answer (could this be just a first chunk of a larger reply?)
Labels: name: auto:bug

### System Info

Python 3.9.6
langchain==0.0.229
MacOS on Apple M2 hardware

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

This may be related to https://github.com/hwchase17/langchain/issues/7785 , I am not sure. When I use HuggingFaceEndpoint in regular, non-streaming mode, I see that the reply comes truncated. 

 1. Deploy Falcon-7b https://huggingface.co/tiiuae/falcon-7b
 2. Use RetrievalQA and HuggingFaceEndpoint as described in https://github.com/hwchase17/langchain/issues/7785
 3. Use the prompt described in https://github.com/hwchase17/langchain/issues/7786 (not sure if you really need this to reproduce)
 4. Call it using structured_result = my_qna({query_key: query}) 
 5. The result will come back truncated. No streaming is performed, no token callbacks run, so you will get the json from the reply:  structured_result["result"]

In my case, the question and answer in Portuguese:

```
O que é a série G?
A série G da Scania traz uma cabina com uma estética moderna e um confort
```

The last word is truncated, and the whole rest of the explanation is missing.




### Expected behavior

A complete answer, full text.  Or chunk-based callbacks via streaming, as I point out at https://github.com/hwchase17/langchain/issues/7785
In AmazonKendraRetriever, user should have access to a page_content formatter in order to format the Kendra ResultItem as desired
Labels: name: auto:enhancement

### Feature request

In AmazonKendraRetriever, user should have access to a page_content formatter in order to format a Kendra ResultItem as desired, e.g. by combining all sorts of possible document attributes with the title and excerpt of the item.

Currently, the [AmazonKendraRetriever](https://github.com/hwchase17/langchain/blob/master/langchain/retrievers/kendra.py#L30) does not expose a template or allow the user to overwrite how the value of the Document page_content is generated.

Let me know what you think. I am open to suggestions.
@3coins @baskaryan 

### Motivation

The Amazon Kendra result item provides not only the title and excerpt but all sorts of customizable document attributes that could be combined to improve the result of the LLM completion.

For instance, according to the official [Amazon Kendra documentation](https://docs.aws.amazon.com/kendra/latest/APIReference/API_RetrieveResultItem.html):

> DocumentAttributes
> An array of document fields/attributes assigned to a document in the search results. For example, the document author (_author) or the source URI (_source_uri) of the document.
> 
> Type: Array of [DocumentAttribute](https://docs.aws.amazon.com/kendra/latest/APIReference/API_DocumentAttribute.html) objects
> 
> Required: No

Different use cases could leverage on the ability to change the Document page_content final value as close to the Kendra Retriever as possible.

### Your contribution

I would be glad to work on this feature. I have already started with a simple prototype and I could issue a PR proposing that change.
HuggingFaceEndpoint returns empty string in "text-generation" mode with prompt template
Labels: name: area: agent, name: auto:bug

### System Info

Python 3.9.6
langchain==0.0.229
MacOS on Apple M2 hardware

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

### Reproduction

I provisioned [cerebras/Cerebras-GPT-2.7B](https://huggingface.co/cerebras/Cerebras-GPT-2.7B) and noticed I was getting an empty string when asking a question with my prompt, in "text-generation" mode. Upon debugging I found the issue:

```
        if self.task == "text-generation":
            # Text generation return includes the starter text.
            text = generated_text[0]["generated_text"][len(prompt) :].  # <==== HERE
        elif self.task == "text2text-generation":
            text = generated_text[0]["generated_text"]
        elif self.task == "summarization":
            text = generated_text[0]["summary_text"]
```

I had to patch it like this:

```
text = generated_text[0]["generated_text"]
```

That is so because generated_text[0]["generated_text"]  is NOT returning with the prompt text. Therefore,  [len(prompt) :] effectively discards the actual answer. Basically, from debugging I see that the logic I want is the same as is coded under "text2text-generation".  But I am using "text-generation" and the answer *does not* come with the prompt text back. Any chance the logic for these 2 are swapped?

My prompt:

'''
You are a useful and cordial assistant. Your objective is to provide precise and
relevant information about Thinksurance. You must answer the questions formulated by the
human user with attention and only based on the context provided. You should never
invent facts. If you can't find the answer using the supplied context, just say that you
are unable to answer.

Context:
{context}

Question:
{question}
'''






### Expected behavior

As described above, the expected behaviour is to get the answer back, not an empty string, when a prompt is used and in "text-generation" mode.
streaming support for LLM, from HuggingFaceEndpoint
Labels: name: auto:bug

### System Info

Python 3.9.6
langchain==0.0.229
MacOS on Apple M2 hardware

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

 I use RetrievalQA.from_chain_type(llm=llm, ...) and with these LLMs streaming works:

  - ChatOpenAI.  (I can pass streaming=True)
  - OpenAI.   (I can pass streaming=True)

However, with HuggingFaceEndpoint the streaming just does not work. It does not even take streaming=bool.



### Expected behavior

I am able to switch LLM engines via config, and would like to have the streaming feature as the output is incrementally shown to the user, which is great for slow responses (much better usability - no need to wait for the entire time to compute the entire answer). Unfortunately this is not possible with HuggingFaceEndpoint.

https://github.com/hwchase17/langchain/issues/2918 talks about HuggingFaceHub , which is not really my case (HuggingFaceEndpoint)

Is there a simple way to make it work with RetrievalQA.from_chain_type(llm=llm,...) where the llm is created like 

```
    llm = HuggingFaceEndpoint(endpoint_url=my_endpoint,
                                task="text-generation",
                                streaming=True
                                callbacks = callbacks,
                                model_kwargs={"temperature": temperature, "max_length": 1024})
```
Thanks!
ReplitLM Model_addition_in_langchain
Labels: name: auto:question, name: auto:enhancement

### Feature request

I want to integrate the MPT style code LLM, ReplitLM from Replit into the langchain.


### Motivation

I want a code LLM in langchain, as ReplitLM has been continuously providing good results either fine tuned or not.
I was working on a project for analyzing complex code patterns and structures but generalized LLMs fails on this task, so I want to add code LLMs in langchain.

### Your contribution

I want just a little guidance on how to integrate any new LLM into the framework, and then i'll start working on the PR and submit it in ASAP.
In the AmazonKendraRetriever, the Document page_content is empty for ResultItem with Type ANSWER when using the Query API
Labels: name: area: vector store, name: auto:bug

### System Info

- LangChain version: 0.0.234
- Platform: Local and AWS ECS 
- Python version: 3.9

### Who can help?

@3coins 

### 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

1. Install latest version of Langchain
2. Follow instructions here: https://python.langchain.com/docs/modules/data_connection/retrievers/integrations/amazon_kendra_retriever
3. Ask for a specific quesiton that will fall back to using the Query API that returns a ResultItem with type ANSWER and inspect the content as following

I replaced the original values with "----------------".

```json
{
  "Id": "----------------",
  "Type": "ANSWER",
  "Format": "TABLE",
  "AdditionalAttributes": [
    {
      "Key": "AnswerText",
      "ValueType": "TEXT_WITH_HIGHLIGHTS_VALUE",
      "Value": {
        "TextWithHighlightsValue": {
          "Text": "----------------",
          "Highlights": [
            {
              "BeginOffset": 70,
              "EndOffset": 81,
              "TopAnswer": false,
              "Type": "STANDARD"
            }
          ]
        }
      }
    }
  ],
  "DocumentId": "----------------",
  "DocumentTitle": {
    "Text": "",
    "Highlights": []
  },
  "DocumentExcerpt": {
    "Text": "----------------",
    "Highlights": [
      {
        "BeginOffset": 0,
        "EndOffset": 81,
        "TopAnswer": false,
        "Type": "STANDARD"
      }
    ]
  },
  ...
}
```

will result in:

```
Document(page_content='', metadata={'type': 'ANSWER', 'source': '----------------', 'title': '', 'excerpt': '----------------'})
```


### Expected behavior

The document page_content should contain at least the Amazon Kendra ResultItem excerpt. According to the [Amazon Kendra  documentation](https://docs.aws.amazon.com/kendra/latest/APIReference/API_QueryResultItem.html), the DocumentTitle is not required, therefore we should not expect it in order to return the page_content as seen on the [AmazonKendraRetriever code](https://github.com/hwchase17/langchain/blob/master/langchain/retrievers/kendra.py#L41).
Exposes Kendra result item DocumentAttributes in the document metadata
Labels: name: lgtm, name: auto:improvement

- Description: exposes the ResultItem DocumentAttributes as document metadata with key 'document_attributes' and refactors AmazonKendraRetriever by providing a ResultItem base class in order to avoid duplicate code;
- Tag maintainer: @3coins @hupe1980 @dev2049 @baskaryan
- Twitter handle: wilsonleao

### Why?
Some use cases depend on specific document attributes returned by the retriever in order to improve the quality of the overall completion and adjust what will be displayed to the user. For the sake of consistency, we need to expose the DocumentAttributes as document metadata so we are sure that we are using the values returned by the kendra request issued by langchain.

I would appreciate your review @3coins @hupe1980 @dev2049. Thank you in advance!

### References
- [Amazon Kendra DocumentAttribute](https://docs.aws.amazon.com/kendra/latest/APIReference/API_DocumentAttribute.html)
- [Amazon Kendra DocumentAttributeValue](https://docs.aws.amazon.com/kendra/latest/APIReference/API_DocumentAttributeValue.html)
Issue: Why is the KNNRetriever existed?
Labels: name: area: vector store, name: auto:question, name: auto:improvement

### Issue you'd like to raise.

The KNNRetriever calculates the cosine similarity of documents and retrieves the top 'n' documents. Its behavior is identical to `FAISS.similarity_search(query)`. What is the rationale behind creating a separate KNNRetriever?

### Suggestion:

Remove the KNNRetriever module.
add bm25 module
Labels: name: lgtm, name: auto:enhancement

  - Description: Add a BM25 Retriever that do not need Elastic search
  - Dependencies: rank_bm25(if it is not installed it will be install by using pip, just like TFIDFRetriever do)
  - Tag maintainer: @rlancemartin, @eyurtsev
  - Twitter handle: DayuanJian21687
pydantic.error_wrappers.ValidationError: 1 validation error for GPT4All
Labels: name: area: embeddings, name: auto:bug

### System Info

Python 3.8.10
gpt4all==1.0.5
langchain==0.0.234
pydantic==1.10.11
pydantic-core==2.3.0



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

### Reproduction

**Code snippet:**
from langchain import PromptTemplate, LLMChain
from langchain.vectorstores import Chroma
from langchain.chains import ConversationalRetrievalChain
from langchain.memory import ConversationBufferMemory
from langchain.embeddings import HuggingFaceInstructEmbeddings
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.llms import GPT4All


embedding_model_name = "hkunlp/instructor-large"
persist_directory = 'db'
callbacks = [StreamingStdOutCallbackHandler()]
model_path = "/home/imrohankar/gpttest/DocGPT/models/ggml-gpt4all-j-v1.3-groovy.bin"

llm = GPT4All(
    model = model_path,
    callbacks = callbacks,
    verbose = False
)

**Error:**
Traceback (most recent call last):
  File "/home/imrohankar/gpttest/DocGPT/conversation.py", line 15, in <module>
    llm = GPT4All(
  File "/home/imrohankar/gpttest/DocGPT/venv/lib/python3.8/site-packages/langchain/load/serializable.py", line 74, in __init__
    super().__init__(**kwargs)
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for GPT4All
__root__
  'type' object is not subscriptable (type=type_error)

**Note:** Tried downgrading pydantic, langchain versions but still the error. I am unable to understand why it gives type error while initializing GPT4All


### Expected behavior

I would expect it to find the model file at the model path
Add more HTTP methods supports for 'APIChain'
Labels: name: auto:improvement

  - Description: added more HTTP methods supports for APIChain, such as POST method
  - Issue:  Closes #2184
  - Dependencies: noops
  - Tag maintainer: @baskaryan, @hinthornw 
  - Twitter handle: noops

# Introduction
There are many (#2184) requirements for APIChain to support more HTTP requests, especially POST requests.
However,  current APIChain only supports GET requests, because it simply appends the request parameters to the URL path.

In this pull request, I propose defining a standard RequestParams type for all http requests, to standardize the request parameters for api docs. 

# Test
1. POST
I used the  [Moderations](https://platform.openai.com/docs/api-reference/moderations/create) interface from OPEN_AI to test sending POST requests.

2. GET
I re-executed the currently existing GET request method (in TMDB Example), and the results remained consistent.
Add LLM for ChatGLM(2)-6B API
Labels: name: lgtm, name: auto:enhancement

Description:
Add LLM for ChatGLM-6B & ChatGLM2-6B API

Related Issue: 
Will the langchain support ChatGLM? #4766
Add support for selfhost models like ChatGLM or transformer models #1780

Dependencies: 
No extra library install required. 
It wraps api call to a ChatGLM(2)-6B server(start with api.py),  so api endpoint is required to run.

Tag maintainer:  @mlot 

Any comments on this PR would be appreciated.

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: Add LLM for ChatGLM-6B & ChatGLM2-6B API
  - Issue: Will the langchain support ChatGLM? #4766
  - Dependencies: No extra library dependencies required. User need to provide endpoint url of a ChatGLM(2)-6B api server.
  - Tag maintainer: @limpo2000 in twitter
  - 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
 -->
implement GitHub toolkit and notebook example
Labels: name: area: agent, name: auto:enhancement

Hey @hinthornw,

It seems you're the guy for new toolkits.

### Description
This PR is my implementation of a CRUD toolkit for GitHub. It implements functions to create, read, update, and delete files on a GitHub repository. Also, it has 2 functions to get a list of issues and get more information on a specific issue (including comments etc.) allowing agents to interact with other collaborators.

### Dependencies
[PyGitHub](https://github.com/PyGithub/PyGithub)

### Testing

I have included a notebook which showcases an example of an agent completing an issue on a test repository which can be found in the toolkits docs.

My Twitter handle is @trevordobbertin if this is something that the team feels is cool enough for a shoutout.

Thanks!
fix: pgvector search_type of similarity_score_threshold not working
Labels: name: area: vector store, name: auto:bug

  - Description: VectorStoreRetriever->similarity_score_threshold with search_type of "similarity_score_threshold" not working with the following two minor issues, 
  - Issue: 1. In line 237 of `vectorstores/base.py`, "score_threshold" is passed to `_similarity_search_with_relevance_scores` as in the kwargs, while score_threshold is not a valid argument of this method. As a fix, before calling `_similarity_search_with_relevance_scores`, score_threshold is popped from kwargs. 2. In line 596 to 607 of `vectorstores/pgvector.py`, it's checking the distance_strategy against the string in Enum. However, self.distance_strategy will get the property of distance_strategy from line 316, where the callable function is passed. To solve this issue, self.distance_strategy is changed to self._distance_strategy to avoid calling the property method.,
  - Dependencies: No,
  - Tag maintainer: @rlancemartin, @eyurtsev,
  - Twitter handle: No
add test for knn retriever
Labels: name: lgtm, name: auto:improvement

# What
- This is to add test for knn retriever.

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: add test to knn retriever
  - Issue: None
  - Dependencies: None
  - Tag maintainer: @baskaryan
  - Twitter handle: @MlopsJ

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
 -->