delayedkarma/langchain-issues huggingface dataset:
Link in the Readme is invalid.
Labels: name: auto:documentation

### Issue with current documentation:

https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain
<img width="399" alt="WX20230914-113935@2x" src="https://github.com/langchain-ai/langchain/assets/34183928/1d61724a-152f-4ad2-8197-0dfc0fd44f98">


### Idea or request for content:

_No response_
Can not use QianfanLLMEndpoint
Labels: name: auto:bug, name: area: models

### System Info

Unresolved reference 'QianfanLLMEndpoint' 

Name: langchain
Version: 0.0.288


### Who can help?

@hwchase17
@agola11

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

from langchain.llms.baidu_qianfan_endpoint import QianfanLLMEndpoint

### Expected behavior

I hope to use Qianfan model but I can't import it, even though i have update my langchain, it can't work.
Issue: Agent keeps using the wrong type
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

Attempting to make a google calendar agent, however it keeps making a field that should be a datetime object a string object.

the prompt:
```prefix = """Date format: datetime(2023, 5, 2, 10, 0, 0)
Based on this event description: "Joey birthday tomorrow at 7 pm",
output a json of the following parameters: 
Today's datetime on UTC time datetime(2023, 5, 2, 10, 0, 0), it's Tuesday and timezone
of the user is -5, take into account the timezone of the user and today's date.
1. summary 
2. start 
3. end 
4. location 
5. description 
6. user_timezone
event_summary:
{{
    "summary": "Joey birthday",
    "start": "datetime(2023, 5, 3, 19, 0, 0)",
    "end": "datetime(2023, 5, 3, 20, 0, 0)",
    "location": "",
    "description": "",
    "user_timezone": "America/New_York"
}}

Date format: datetime(YYYY, MM, DD, hh, mm, ss)
Based on this event description: "Create a meeting for 5 pm on Saturday with Joey",
output a json of the following parameters: 
Today's datetime on UTC time datetime(2023, 5, 4, 10, 0, 0), it's Thursday and timezone
of the user is -5, take into account the timezone of the user and today's date.
1. summary 
2. start 
3. end 
4. location 
5. description 
6. user_timezone
event_summary:
{{
    "summary": "Meeting with Joey",
    "start": "datetime(2023, 5, 6, 17, 0, 0)",
    "end": "datetime(2023, 5, 6, 18, 0, 0)",
    "location": "",
    "description": "",
    "user_timezone": "America/New_York"
}}

"""```
the tool
```
class CalnederEventTool(BaseTool):
    """A tool used to create events on google calendar."""
    name = "custom_search"
    description = "a tool used to create events on google calendar"

    def _run(
        self,
        summary: str,
        start: datetime,
        end: Union[datetime, None],
        recurrence: Optional[str] = None,  # Changed from Optional[Recurrence] to Optional[str]
        run_manager: Optional['CallbackManagerForToolRun'] = None,
    ) -> str:


        GOOGLE_EMAIL = environ.get('GOOGLE_EMAIL')
        CREDENTIALS_PATH = environ.get('CREDENTIALS_PATH')

        calendar = GoogleCalendar(
            GOOGLE_EMAIL, 
            credentials_path=CREDENTIALS_PATH
            )

        event = Event(summary=summary, start=start, end=end)
        calendar.add_event(event)
        
    async def _arun(
        self, query: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None
    ) -> str:
        """Use the tool asynchronously."""
        raise NotImplementedError("custom_search does not support async")
 ```
 
 ```
 > Entering new AgentExecutor chain...
Action:
```
{
  "action": "custom_search",
  "action_input": {
    "summary": "Going to the bar",
    "start": "2020-09-01T17:00:00",
    "end": "2020-09-01T18:00:00",
    "recurrence": ""
  }
}
```


### Suggestion:

_No response_
implement get_num_tokens to use google's count_tokens function
Labels: name: lgtm, name: auto:improvement, name: area: models

can get the correct token count instead of using gpt-2 model

**Description:** 
Implement get_num_tokens within VertexLLM to use google's count_tokens function. (https://cloud.google.com/vertex-ai/docs/generative-ai/get-token-count). So we don't need to download gpt-2 model from huggingface, also when we do the mapreduce chain we can get correct token count.

**Tag maintainer:** 
@lkuligin 
**Twitter handle:** 
My twitter: @abehsu1992626
CassandraCache and CassandraSemanticCache can handle any "Generation"
Labels: name: area: memory, name: auto:improvement

Hello,
this PR improves coverage for caching by the two Cassandra-related caches (i.e. exact-match and semantic alike) by switching to the more general `dumps`/`loads` serdes utilities.

This enables cache usage within e.g. `ChatOpenAI` contexts (which need to store lists of `ChatGeneration` instead of `Generation`s), which was not possible as long as the cache classes were relying on the legacy `_dump_generations_to_json` and `_load_generations_from_json`).

Additionally, a slightly different init signature is introduced for the cache objects:
- named parameters required for init, to pave the way for easier changes in the future connect-to-db flow (and tests adjusted accordingly)
- added a `skip_provisioning` optional passthrough parameter for use cases where the user knows the underlying DB table, etc already exist.

Thank you for a review!
Issue: Dynamically select from multiple retrievers
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

chain = MultiRetrievalQAChain.from_retrievers(OpenAI(), retriever_infos, verbose=True)

I'm receiving this error when I try to call the above:(I'm following this doc https://python.langchain.com/docs/use_cases/question_answering/how_to/multi_retrieval_qa_router)
```

ValidationError                           Traceback (most recent call last)
Cell In[7], line 1
----> 1 chain = MultiRetrievalQAChain.from_retrievers(OpenAI(), retriever_infos)

File ~/anaconda3/lib/python3.11/site-packages/langchain/chains/router/multi_retrieval_qa.py:66, in MultiRetrievalQAChain.from_retrievers(cls, llm, retriever_infos, default_retriever, default_prompt, default_chain, **kwargs)
     64 prompt = r_info.get("prompt")
     65 retriever = r_info["retriever"]
---> 66 chain = RetrievalQA.from_llm(llm, prompt=prompt, retriever=retriever)
     67 name = r_info["name"]
     68 destination_chains[name] = chain

File ~/anaconda3/lib/python3.11/site-packages/langchain/chains/retrieval_qa/base.py:84, in BaseRetrievalQA.from_llm(cls, llm, prompt, callbacks, **kwargs)
     74 document_prompt = PromptTemplate(
     75     input_variables=["page_content"], template="Context:\n{page_content}"
     76 )
     77 combine_documents_chain = StuffDocumentsChain(
     78     llm_chain=llm_chain,
     79     document_variable_name="context",
     80     document_prompt=document_prompt,
     81     callbacks=callbacks,
     82 )
---> 84 return cls(
     85     combine_documents_chain=combine_documents_chain,
     86     callbacks=callbacks,
     87     **kwargs,
     88 )

File ~/anaconda3/lib/python3.11/site-packages/langchain/load/serializable.py:75, in Serializable.__init__(self, **kwargs)
     74 def __init__(self, **kwargs: Any) -> None:
---> 75     super().__init__(**kwargs)
     76     self._lc_kwargs = kwargs

File ~/anaconda3/lib/python3.11/site-packages/pydantic/main.py:341, in pydantic.main.BaseModel.__init__()

ValidationError: 1 validation error for RetrievalQA
retriever
  Can't instantiate abstract class BaseRetriever with abstract method _get_relevant_documents (type=type_error)


```

### Suggestion:

_No response_
ArcGISLoader: add keyword arguments, error handling, and better tests
Labels: name: area: doc loader, name: auto:improvement

* More clarity around how geometry is handled. Not returned by default; when returned, stored in metadata. This is because it's usually a waste of tokens, but it should be accessible if needed.
* User can supply layer description to avoid errors when layer properties are inaccessible due to passthrough access.
* Enhanced testing
* Updated notebook
RetrievalQA custom prompt to accept prompts other than context and question e.g. language for use in Sequential Chain
Labels: name: auto:improvement, name: area: models

### Feature request

Update RetrievalQA chain so that custom prompts can accept parameters other than input_documents and question. 
Current functionality is limited by call to StuffDocumentsChain:

answer = self.combine_documents_chain.run(
    input_documents=docs, question=question, callbacks=_run_manager.get_child()
)

Any additional parameters required aren't passed, including chat history.

2 line code update required:

inputs['input_documents'] = docs
answer = self.combine_documents_chain.run(
  inputs, callbacks=_run_manager.get_child()
)

### Motivation

Improve flexibility of the RetrievalQA chain enabling system message to be customised, chat history to be passed so GPT can reference back to previous answers. Customise language in answer in QA chain etc. 

### Your contribution

Will submit PR with above change in-line with contributing guidelines.
add mmr support to redis retriever
Labels: name: area: vector store, name: auto:improvement, name: integration: redis

<!-- 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. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
LangChain's Chroma similarity_search return results from other db
Labels: name: area: vector store, name: auto:bug, name: integration: chroma

### System Info

LangChain 0.0.281
Platform: Centos

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

### Reproduction

Hi,

I have two vector stores:

splitter = RecursiveCharacterTextSplitter(chunk_size=400, chunk_overlap=50)
splits_1 = splitter.split_documents(docs_1)
splits_2 = splitter.split_documents(docs_2)

store1 = Chroma.from_documents(documents=splits_1, embedding=HuggingFaceEmbeddings())
store2 = Chroma.from_documents(documents=splits_2, embedding=HuggingFaceEmbeddings())

Then I use store2 to do similarity search, it returns results from splits_1, that's very wired. Can someone please help?

Thanks
Tom

### Expected behavior

Different vector store should use its own pool to do the similarity search
Issue: Parsing issue
Labels: name: auto:bug

### Issue you'd like to raise.

import pandas as pd
import pandas_gpt

df = pd.read_csv('aisc-shapes-database-v16.0.csv', index_col=0, header=0, usecols = ["A:F"], names = [
   "Type", "EDI_Std_Nomenclature", "AISC_Manual_Label", "T_F", "W", "Area"])

df.ask('what is the area of W12X12?')

Need help getting this file to read with pandas.read_csv
[aisc-shapes-database-v16.0.csv](https://github.com/langchain-ai/langchain/files/12600284/aisc-shapes-database-v16.0.csv)


### Suggestion:

This is my error message

  File "c:\Users\camer\import pandas as pd.py", line 4, in <module>
    df = pd.read_csv('aisc-shapes-database-v16.0.csv', index_col=0, header=0, usecols = ["A:F"], names = [
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\camer\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\parsers\readers.py", line 948, in read_csv
    return _read(filepath_or_buffer, kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\camer\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\parsers\readers.py", line 611, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\camer\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\parsers\readers.py", line 1448, in __init__
    self._engine = self._make_engine(f, self.engine)  
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "C:\Users\camer\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\parsers\readers.py", line 1723, in _make_engine
    return mapping[engine](f, **self.options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\camer\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 93, in __init__
    self._reader = parsers.TextReader(src, **kwds)    
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^    
  File "parsers.pyx", line 579, in pandas._libs.parsers.TextReader.__cinit__
  File "parsers.pyx", line 668, in pandas._libs.parsers.TextReader._get_header
  File "parsers.pyx", line 879, in pandas._libs.parsers.TextReader._tokenize_rows
  File "parsers.pyx", line 890, in pandas._libs.parsers.TextReader._check_tokenize_status
  File "parsers.pyx", line 2050, in pandas._libs.parsers.raise_parser_error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 703: invalid start byte
Issue: Can I load THUDM/chatglm-6b?
Labels: name: auto:question, name: area: models

I've been searching for a large-context LLM with a relatively low parameter count suitable for local execution on multiple T4 GPUs or a single A100. My primary goal is to summarize extensive financial reports. While I came across FinGPT v1, it seems it isn't hosted on HuggingFace.

However, I did find chatglm-6b, which serves as the foundation for FinGPT v1. This model is accessible on HuggingFace, but I'm facing issues loading it.

Here's a snippet that successfully loads and uses the model outside Langchain:

```
from transformers import AutoModel, AutoTokenizer

model_name = "THUDM/chatglm2-6b"

tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)

# model = AutoModel.from_pretrained(model_name, trust_remote_code=True).cuda()

# 按需修改，目前只支持 4/8 bit 量化
# model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True).quantize(4).cuda()

import torch

has_cuda = torch.cuda.is_available()
# has_cuda = False  # force cpu

if has_cuda:
    #model = AutoModel.from_pretrained("THUDM/chatglm2-6b-int4",trust_remote_code=True).half().cuda()  # 3.92
    model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True).quantize(4).cuda()
else:
    model = AutoModel.from_pretrained("THUDM/chatglm2-6b-int4",trust_remote_code=True).half()  # float()

response, history = model.chat(tokenizer, f"Summarize this in a few words: {a}", history=[])

```

But, when I try the following, to use in Langchain:

```
from langchain.llms import HuggingFacePipeline

llm = HuggingFacePipeline.from_model_id(
    model_id="THUDM/chatglm-6b",
    task="text-generation",
    model_kwargs={"temperature": 0, "max_length": 64},
)
```

I encounter this error:

```
ValueError: Tokenizer class ChatGLMTokenizer does not exist or is not currently imported.
```

From what I gather, the ChatGLM model cannot be passed directly to HuggingFace's pipeline. While the Langchain documentation does mention using ChatGLM as a local model, it seems to primarily focus on using it via an API endpoint:

```
endpoint_url = "http://127.0.0.1:8000"

# direct access endpoint in a proxied environment
# os.environ['NO_PROXY'] = '127.0.0.1'

llm = ChatGLM(
    endpoint_url=endpoint_url,
    max_token=80000,
    history=[["我将从美国到中国来旅游，出行前希望了解中国的城市", "欢迎问我任何问题。"]],
    top_p=0.9,
    model_kwargs={"sample_model_args": False},
)
```

Would anyone have insights on how to correctly load ChatGLM for tasks within Langchain?

### Suggestion:

_No response_
DOC: inexistent documentation for index
Labels: name: area: doc loader, name: auto:documentation

### Issue with current documentation:

The `index` [API Reference document](https://api.python.langchain.com/en/latest/indexes/langchain.indexes._api.index.html) that is linked in the [Indexing documentation](https://python.langchain.com/docs/modules/data_connection/indexing#quickstart) returns a 404 error.

### Idea or request for content:

Please include detailed documentation for `index` to use correctly `SQLRecordManager`.
SQLRecordManager index adds documents outside existing Redis vectorstore index
Labels: name: area: vector store, name: auto:bug, name: stale, name: integration: redis

### System Info

langchain_version: "0.0.287"
library: "langchain"
library_version: "0.0.287"
platform: "Linux-6.1.0-12-amd64-x86_64-with-glibc2.36"
py_implementation: "CPython"
runtime: "python"
runtime_version: "3.11.2"

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

After following the [indexing instructions](https://python.langchain.com/docs/modules/data_connection/indexing), `index` stores the documents in a Redis vectorstore, but it does so outside the vectorstore's index.

```
import os, time, json, openai
from langchain.vectorstores.redis import Redis
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.indexes import SQLRecordManager, index
from langchain.schema import Document
from datetime import datetime
from pathlib import Path

openai.api_key  = os.environ['OPENAI_API_KEY']

VECTORS_INDEX_NAME = 'Vectors'
COLLECTION_NAME = 'DocsDB'
NAMESPACE = f"Redis/{COLLECTION_NAME}"
REDIS_URL = "redis://10.0.1.21:6379"

embeddings = OpenAIEmbeddings()

record_manager = SQLRecordManager(NAMESPACE, db_url="sqlite:///cache_Redis.sql")
record_manager.create_schema()

rds_vectorstore = Redis.from_existing_index(
    embeddings,
    index_name=VECTORS_INDEX_NAME,
    redis_url=REDIS_URL,
    schema='Redis_schema.yaml'
)

index(
    document,
    record_manager,
    rds_vectorstore,
    cleanup = "full", # None: for first document load; "incremental": for following documents
    source_id_key = "title",
)
```
When exploring the Redis vectorstore, all `documents` loaded outside the specified `VECTORS_INDEX_NAME`.

When `documents` are loaded to the vectorstore without `RecordManager` `index`, they are created inside the specified `VECTORS_INDEX_NAME` when using the following code:
```
rds = Redis.from_documents(
    document,
    embeddings,
    index_name=VECTORS_INDEX_NAME,
    redis_url=REDIS_URL,
    index_schema='Redis_schema.yaml'
)
```

### Expected behavior

`Documents` loaded into a Redis vectorstore using `index` `RecordManager` should be created inside the vectorstore's index.
MMR search_type not implemented for Google Vertex AI Matching Engine Vector Store  (new name of Matching Engine- Vector Search)
Labels: name: area: vector store, name: auto:enhancement

### Feature request

MMR search_type is not implemented for Google Vertex AI Matching Engine  Vector Store (new name of Matching Engine- Vector Search).

I am getting the error `NotImplementedError`

Below is the code that I had used

`retriever = me.as_retriever(
    search_type="mmr",
    search_kwargs={
        "k": 10,
        "search_distance": 0.6,
         "fetch_k": 15,
        "lambda_mult": 0.7 }}`

Please implement it at the earliest, request the team if they can provide ETA too

### Motivation

I am working for a client where they are using only Google Vertex AI components for creating LLM chatbot agents using various unstructured document types. We are not getting optimal results with the default `search_type="similarity"` , we understand that results can improve a  lot with MMR search. Hence kindly requesting the team to add the `search_type="mmr"`  feature

### Your contribution

Can provide feedback on the new feature performance
bump 288
Labels: name: auto:nit

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - Description: a description of the change, 
  - Issue: the issue # it fixes (if applicable),
  - Dependencies: any dependencies required for this change,
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: we announce bigger features on Twitter. If your PR gets announced and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
Fix `GoogleEnterpriseSearchRetriever`
Labels: name: auto:bug

Replace this entire comment with:
  - Description: fixed Google Enterprise Search Retriever where it was consistently returning empty results, 
  - Issue: related to [issue 8219](https://github.com/langchain-ai/langchain/issues/8219),
  - Dependencies: no dependencies,
  - Tag maintainer: @hwchase17 ,
  - Twitter handle: [Tomas Piaggio](https://twitter.com/TomasPiaggio)!