delayedkarma/langchain-issues huggingface dataset:
Documentation Issue - Page Not Found
Labels: name: area: doc loader, name: auto:documentation

### Issue with current documentation:

While navigating the documentation, I came across an issue that I wanted to bring to your attention. It seems that `Python Guide` link on this page 

[https://docs.langchain.com/docs/components/agents/agent](https://docs.langchain.com/docs/components/agents/agent)

is returning `Page Not Found`

Thank you for your dedication to creating an exceptional project. 

### Idea or request for content:

_No response_
Add async call for LlamaCpp
Labels: name: auto:improvement, name: area: models

<!-- 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.
 -->
**Add async call and async stream for LlamaCpp.** 
This allows it to use async callback handler to return a stream response.
@hwchase17, @rlancemartin
Unable to add PromptTemplate/FewShotPromptTemplate to LangChain Agents
Labels: name: area: agent, name: auto:question, name: area: models

### System Info

Langchain Version - 0.0.261
Python Version - 3.9.6
OS -MacOS


### Who can help?

@hwchase17 @ago

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

### Reproduction

Here is how I am initialising the agent
`sys_msg = """
The custom system message of the chatbot goes here. 
"""
tools = [CustomTool()]
agent = initialize_agent(
    agent='chat-conversational-react-description',
    tools=tools,
    llm=llm,
    verbose=True,
    max_iterations=4,
    early_stopping_method='generate',
    memory=conversational_memory,
    handle_parsing_errors=True,
)

new_prompt = agent.agent.create_prompt(
    system_message=sys_msg,
    tools=tools
)

agent.agent.llm_chain.prompt = new_prompt`

### Expected behavior

I want to be able to align the output content and format of the chatbot better with my expectations. Right now I just give those instructions using system message. I believe the Final Output can be aligned better using a few shot examples. How can I possibly do that with an Agent?
Caching (SQLiteCache/InMemoryCache etc.) is not working with ConversationalRetrievalChain
Labels: name: area: memory, name: area: vector store, name: auto:bug, name: area: models

### System Info

LangChain Version- 0.0.260, platform- Windows, Python Version-3.9.16

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

I am trying to use SQLiteCache  along with ConversationalRetrievalChain, but never getting results from cache, always executing LLMs.

My code is as follows:

langchain.llm_cache = SQLiteCache(database_path=".langchain.db")

langchain.llm_cache = SQLiteCache(database_path=".langchain.db")
from langchain.cache import InMemoryCache

langchain.llm_cache = InMemoryCache()
# Embeddings
embeddings = HuggingFaceEmbeddings(
    model_name=EMBEDDING_MODEL, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs
)
# langchain.llm_cache = RedisSemanticCache(
#     redis_url="redis://localhost:6379", embedding=embeddings
# )


dimension = 768
index = faiss.IndexFlatL2(dimension)

vectorstore = FAISS(
    HuggingFaceEmbeddings().embed_query, index, InMemoryDocstore({}), {}
)

history_retriever = vectorstore.as_retriever(search_type="mmr", search_kwargs=dict(k=3))

memory = VectorStoreRetrieverMemory(
    retriever=history_retriever,
    memory_key="chat_history",
    return_docs=False,
    return_messages=True,
)

chroma = Chroma(
    collection_name="test_db",
    embedding_function=embeddings,
    persist_directory=persist_directory,
)

llm = ChatOpenAI(temperature=0, model=GPT_MODEL)

retriever = MultiQueryRetriever.from_llm(
    retriever=chroma.as_retriever(search_type="mmr", search_kwargs=dict(k=3)), llm=llm
)

qa_chain = ConversationalRetrievalChain.from_llm(
    llm,
    retriever=retriever,
    memory=memory,
    return_source_documents=True,
    get_chat_history=lambda h: h,
)

responses = qa_chain({"question": user_input})

### Expected behavior

Should be return results from cache if the query is same
Passing SQL error in QuerySQLCheckerTool
Labels: name: area: agent, name: auto:improvement

### Feature request

The SQL Database Agent utilizes the SQLDatabaseToolkit. This toolkit encompasses four distinct tools:

1. InfoSQLDatabaseTool
2. ListSQLDatabaseTool
3. QuerySQLCheckerTool
4. QuerySQLDataBaseTool

The QuerySQLCheckerTool is designed to identify and rectify errors within SQL code. It employs the QUERY_CHECKER prompt, which is structured as:

```
QUERY_CHECKER = """
{query}
Double check the {dialect} query above for common mistakes, including:
- Using NOT IN with NULL values
- Using UNION when UNION ALL should have been used
- Using BETWEEN for exclusive ranges
- Data type mismatch in predicates
- Properly quoting identifiers
- Using the correct number of arguments for functions
- Casting to the correct data type
- Using the proper columns for joins

If there are any of the above mistakes, rewrite the query. If there are no mistakes, just reproduce the original query.

Output the final SQL query only.

SQL Query: """
```

To enhance this, an augmented prompt named CUSTOM_QUERY_CHECKER has been crafted, which incorporates SQL errors returned by the SQLDatabase post-query execution. 
The revised prompt reads:

```
CUSTOM_QUERY_CHECKER = """
Upon executing {query} on the {dialect} database, the following SQL error was encountered, delineated by triple backticks:

```
{sql_error}
```

Furthermore, please scrutinize the {dialect} query for typical mistakes, such as:
- Incorporating NOT IN with NULL values
- Preferring UNION over UNION ALL
- Using BETWEEN for non-overlapping ranges
- Witnessing data type inconsistencies in predicates
- Ensuring identifiers are aptly quoted
- Validating the precise number of function arguments
- Guaranteeing the appropriate data type casting
- Employing the correct columns during joins
- Abstaining from appending a semi-colon at the query's conclusion for {dialect}
- Imposing a restriction to yield a maximum of {top_k} results, employing LIMIT, ROWNUM, or TOP as mandated by the database variety. Note that the database type is {dialect}.

Kindly modify the SQL query suited for the {dialect} database. Return only the modified SQL query.
"""

---

With the implementation of this revised prompt, the SQLDatabase can now flawlessly execute the refined SQL without encountering errors.

### Motivation

With the implementation of this revised prompt, the SQLDatabase can now flawlessly execute the refined SQL without encountering errors.

### Your contribution

revised prompt
add multi query test; change run_manager optional for unnecessary args
Labels: name: auto:improvement

# What
- add multi query test
- change run_manager optional for unnecessary args

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - Description: add multi query test; change run_manager optional for unnecessary args
  - Issue: None
  - Dependencies: None
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: @MLOpsj

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.
 -->
add missing test for tools
Labels: name: auto:improvement

# What
- add missing test for tools

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - Description: add missing test for tools
  - Issue: None
  - Dependencies: None
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: @MLopsj

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.
 -->
Add dashvector vectorstore
Labels: name: lgtm, name: area: vector store, name: auto:enhancement

## Description
Add `Dashvector` vectorstore for langchain

- [dashvector quick start](https://help.aliyun.com/document_detail/2510223.html)
- [dashvector package description](https://pypi.org/project/dashvector/)

## How to use
```python
from langchain.vectorstores.dashvector import DashVector

dashvector = DashVector.from_documents(docs, embeddings)
```
add maximal_marginal_relevance_with_score
Labels: name: area: vector store, name: auto:improvement

# What
- add maximal_marginal_relevance_with_score as utility

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - Description: add maximal_marginal_relevance_with_score as utility
  - Issue: None
  - Dependencies: None
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: @MLopsj

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.
 -->
Add dashvector vectorstore
Labels: name: area: vector store, name: auto:enhancement

## Description
Add `Dashvector` vectorstore for langchain

- [dashvector quick start](https://help.aliyun.com/document_detail/2510223.html)
- [dashvector package description](https://pypi.org/project/dashvector/)

## How to use
```python
from langchain.vectorstores.dashvector import DashVector

dashvector = DashVector.from_documents(docs, embeddings)
```
add test for sklearn; add mmr with score for sklearn vector store
Labels: name: area: vector store, name: auto:improvement

# What
- add test for sklearn
- add mmr with score for sklearn vector store

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - Description: add test for sklearn; add mmr with score for sklearn vector store
  - Issue: None
  - Dependencies: None
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: @MLOpsj

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.
 -->
Able to query contents of a PG vector table, ever after dropping the table.
Labels: name: area: vector store, name: auto:bug

### System Info

Hello,

Thanks for the wonderful extension on PG. I am using on DigitialOcean for my SAAS app where i have different schemas for each tenant. I had installed PG vector in public schema, so that all the tenants could make use of them.
My app is built on OpenAI api and I am using the default method from langchain to define the db

**from langchain.vectorstores.pgvector import DistanceStrategy
db = PGVector.from_documents(
documents= docs,
embedding = embeddings,
collection_name= "schema.unique_value",
distance_strategy = DistanceStrategy.COSINE,
connection_string=CONNECTION_STRING)**

This create two files in the public scema and i could see and query the contents. below are the tables

langchain_pg_colllection
langchain_pg_embedding

But when i wish to rewrite the contents by deleteing and even dropping the tables, i could still query the content using the below code:

**db = PGVector(
    collection_name=collection_name,
    connection_string=CONNECTION_STRING,
    embedding_function=embeddings,
)
retriever = db.as_retriever(
    search_kwargs={"k": 5}
)**

The deleted table gets automatically restored while query. This feature is strange and not sure what creates it. Also when i pass a non existent value, instead of failing, it creates a new record in the collection table.

I raise this issue with PG_VECTOR but was rightly directed  to reach out to you.
Would seek any inputs to resolve this plase.





### Who can help?

@eyurtsev

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

### Reproduction

**db = PGVector(
    collection_name=collection_name,
    connection_string=CONNECTION_STRING,
    embedding_function=embeddings,
)
retriever = db.as_retriever(
    search_kwargs={"k": 5}
)**

### Expected behavior

The retriever should get only the contents from the table. If not in the table (or table not available) it should fail. Thanks in anticipation
Custom Parameter/ Json Payload for from_llm_and_api_docs() function
Labels: name: auto:enhancement, name: area: models

### Feature request

I am trying to use the from_llm_and_api_docs() function with an API that only supports parameters via the "params" parameter in the request library: 
The from_llm_and_api_docs works well with apis that encode parameters in the URl. Eg: https://api.open-meteo.com/v1/forecast/latitude=123&longitude=123

I would need langchain to generate a json_payload and input it into the "params" parameter in the request header. I looked into the Langchain code and it seems like that this line:
requests_wrapper = TextRequestsWrapper(headers=headers)
needs to be augmented with a "params" parameter.

Example:
r = requests.get('https://www.domain.com/endpoint',params=params,cookies=cookies, headers=headers,json=json_data)

json_data = {
        'field_ids': field_ids,
        'order': [
            {
                'field_id': 'rank_org_company',
                'sort': sort_order,
            },
        ],
        'query': [
                {
                    'type': 'predicate',
                    'field_id': 'founded_on',
                    'operator_id': 'gte',
                    'values': [
                        '01/01/2018',
                    ],
                },
                {
                    'type': 'predicate',
                    'field_id': 'equity_funding_total',
                    'operator_id': 'lte',
                    'values': [
                        {
                            'value': 15000000,
                            'currency': 'usd',
                        },
                    ],
                },
                {
                    'type': 'predicate',
                    'field_id': 'location_identifiers',
                    'operator_id': 'includes',
                    'values': [
                        '6106f5dc-823e-5da8-40d7-51612c0b2c4e',
                    ],
                }
            ],
        'field_aggregators': [],
        'collection_id': 'organization.companies',
        'limit': 1000,
    }

How do I need to change the from_llm_and_api_docs() accordingly?

### Motivation

Many APIs are controlled via a json payload and not solely via parameters in the URL.

### Your contribution

I could look into changing the request wrapper but maybe there is a more elegant way of doing so.
Error in AimCallbackHandler.on_chain_start callback: 'input'
Labels: name: auto:bug, name: area: models

### System Info

langchain==0.0.262
aim==3.17.5
aim-ui==3.17.5
aimrecords==0.0.7
aimrocks==0.4.0

python: 3.11.4
env: MacOS


### Who can help?

@agola11 

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

### Reproduction

The AIM Callback example: https://python.langchain.com/docs/integrations/providers/aim_tracking

Running only with the LLM works fine.  However when using any CHAIN example it fails with the error:
> Entering new LLMChain chain...
Error in AimCallbackHandler.on_chain_start callback: 'input'

> Finished chain.
Error in AimCallbackHandler.on_chain_end callback: 'output'

No further exceptions are displayed

And the trace recorded in AIM is also incomplete.


### Expected behavior

Trace should be recorded completely.  And no errors should occur on callback for chain start and chain end
Update debugging image link for LangSmith Run
Labels: name: auto:documentation

<!-- 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.
 -->
Langchain text_generation client hits: pydantic.error_wrappers.ValidationError: 1 validation error for Response
Labels: name: auto:bug, name: area: models

### System Info

langchain                              0.0.262
text_generation_server.     https://github.com/huggingface/text-generation-inference


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

start text_generation_inference server on local host, verify it is working 

===============
from langchain import PromptTemplate, HuggingFaceTextGenInference

llm = HuggingFaceTextGenInference(
    inference_server_url="http://127.0.0.1:80",
    max_new_tokens=64,
    top_k=10,
    top_p=0.95,
    typical_p=0.95,
    temperature=1,
    repetition_penalty=1.03,
)
output = llm("What is Machine Learning?")
print(output)

=================

root@0b801769b7bd:~/langchain_client# python langchain-client.py
Traceback (most recent call last):
  File "/root/langchain_client/langchain-client.py", line 59, in <module>
    output = llm("What is Machine Learning?")
  File "/usr/local/lib/python3.10/dist-packages/langchain/llms/base.py", line 802, in __call__
    self.generate(
  File "/usr/local/lib/python3.10/dist-packages/langchain/llms/base.py", line 598, in generate
    output = self._generate_helper(
  File "/usr/local/lib/python3.10/dist-packages/langchain/llms/base.py", line 504, in _generate_helper
    raise e
  File "/usr/local/lib/python3.10/dist-packages/langchain/llms/base.py", line 491, in _generate_helper
    self._generate(
  File "/usr/local/lib/python3.10/dist-packages/langchain/llms/base.py", line 977, in _generate
    self._call(prompt, stop=stop, run_manager=run_manager, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/langchain/llms/huggingface_text_gen_inference.py", line 164, in _call
    res = self.client.generate(prompt, **invocation_params)
  File "/usr/local/lib/python3.10/dist-packages/text_generation/client.py", line 150, in generate
    return Response(**payload[0])
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Response
details -> tokens -> 6 -> logprob
  none is not an allowed value (type=type_error.none.not_allowed)

### Expected behavior

output text from text generation inference server.