delayedkarma/langchain-issues huggingface dataset:
SQLDatabaseChain.from_llm returning ValueError: Missing some input keys: {'query'} when custom template is used
Labels: name: auto:bug, name: area: models

### System Info

I'm using Langchain version '0.0.350' in Databricks
using the following libraries: 
`from langchain_experimental.sql import SQLDatabaseChain`
`from langchain import PromptTemplate`
`from langchain.sql_database import SQLDatabase`



### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

I'm using Langchain version '0.0.350'
`from langchain_experimental.sql import SQLDatabaseChain`
`from langchain import PromptTemplate`
`from langchain.sql_database import SQLDatabase`

mytemplate = """
You are a SQL expert. Given an input question, first create a syntactically correct sql query run on then look at the results of the query and return the answer.

Use the following format:

Question: Question here
SQLQuery: SQL Query to run
SQLResult: Result of the SQLQuery
Answer: Final answer here
Only use the following tables:

{question}
"""

`dbs = SQLDatabase.from_uri(conn_str)`
`db_prompt= PromptTemplate(  input_variables = [ 'question'], template = mytemplate)`

`db_chain = SQLDatabaseChain.from_llm(llm = llms ,  db = dbs, prompt = db_prompt, verbose=True)`

`db_chain.run(question = 'question here')`

ValueError: Missing some input keys: {'query'}

### Expected behavior

I expect to get results of a query
(ChatLiteLLM - Together AI) AttributeError: 'ValueError' object has no attribute 'status_code'
Labels: name: auto:bug, name: area: models

### System Info

platform: Vagrant - Ubuntu 2204
python: 3.9.18
langchain: 0.0.350
langchain-core: 0.1.1
langchain-community: 0.0.3
litellm: 1.15.1

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

### Reproduction

1. Run the code:
``` python
from langchain.chat_models import ChatLiteLLM
from langchain.schema import HumanMessage

# Initialize ChatLiteLLM
chat = ChatLiteLLM(
    model="together_ai/mistralai/Mixtral-8x7B-Instruct-v0.1",
    verbose=True,
    temperature=0.0,
)

text = "Write me a poem about the blue sky"
messages = [HumanMessage(content=text)]

print(chat(messages).content)
```

2: Error message:

``` bash
AttributeError: 'ValueError' object has no attribute 'status_code'
``` 

### Expected behavior

I can't get ChatLiteLLM to work with Together AI. I expect **ChatLiteLLM** to work correctly and to output the result.
docs: fix typo in contributing re installing integration test deps
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:XS

**Description**

The contributing docs lists a poetry command to install community for dev work that includes a poetry group called `integration_tests`. This is a mistake: the poetry group for integration tests is called `test_integration`, not `integration_tests`. See here:
https://github.com/langchain-ai/langchain/blob/master/libs/community/pyproject.toml#L119
Pathway vectorstore and rag-pathway template
Labels: name: lgtm, name: area: vector store, name: auto:enhancement, name: template, name: size:XXL

  - **Description:** Integration with pathway.com data processing pipeline acting as an always updated vectorstore
  - **Issue:** not applicable
  - **Dependencies:** optional dependency on [`pathway`](https://pypi.org/project/pathway/)
  - **Twitter handle:** pathway_com

The PR provides and integration with `pathway` to provide an easy to use always updated vector store:

```python
import pathway as pw
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import PathwayVectorClient, PathwayVectorServer

data_sources = []
data_sources.append(
    pw.io.gdrive.read(object_id="17H4YpBOAKQzEJ93xmC2z170l0bP2npMy", service_user_credentials_file="credentials.json", with_metadata=True))

text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
embeddings_model = OpenAIEmbeddings(openai_api_key=os.environ["OPENAI_API_KEY"])
vector_server = PathwayVectorServer(
    *data_sources,
    embedder=embeddings_model,
    splitter=text_splitter,
)
vector_server.run_server(host="127.0.0.1", port="8765", threaded=True, with_cache=False)
client = PathwayVectorClient(
    host="127.0.0.1",
    port="8765",
)
query = "What is Pathway?"
docs = client.similarity_search(query)
```

The `PathwayVectorServer` builds a data processing pipeline which continusly scans documents in a given source connector (google drive, s3, ...) and builds a vector store.  The `PathwayVectorClient` implements LangChain's `VectorStore` interface and connects to the server to retrieve documents.
SerpAPIWrapper doesn't work
Labels: name: auto:bug, name: area: models

### System Info

**Below is my Linux box:**
Linux  5.15.0-1014-azure #17~20.04.1-Ubuntu SMP Thu Jun 23 20:01:51 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

**Below is libraries within my conda environment:**
google-auth                              2.24.0
google-search-results                    2.4.2
googleapis-common-protos                 1.61.0
langchain                                0.0.349
langchain-cli                            0.0.19
langchain-community                      0.0.1
langchain-core                           0.0.13
langchainhub                             0.1.14
requests                                 2.31.0
requests-oauthlib                        1.3.1
types-requests                           2.31.0.10

### Who can help?

@hwchase17

### Information

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

### Related Components

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

### Reproduction


**Below is source code:**

```
import requests
import json
import os

SERPAPI_API_KEY=os.environ["SERPAPI_API_KEY"]
print(f"{SERPAPI_API_KEY=}")

url = "https://google.serper.dev/search"
payload = json.dumps({
  "q": "apple inc"
})
headers = {
  'X-API-KEY': SERPAPI_API_KEY,
  'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print("************ result from request ***************")
print(response.text)


from langchain.utilities import SerpAPIWrapper
search = SerpAPIWrapper(serpapi_api_key=SERPAPI_API_KEY)

res = search.run("apple inc")
print("************ result from langchain ***************")
print(f"{res=}")

```

### Expected behavior

if the KEY works for request API, then SerpAPIWrapper shouldn't fails with invalid KEY error.
Added more filtering options to pgvector vectorstore
Labels: name: lgtm, name: area: vector store, name: auto:improvement, name: size:M

  - **Description:** Using PGVector vector store, it was only possible to filter for values equals, in or not in metadata. Extended this feature to work with the following keywords : IN, NIN, BETWEEN, GT, LT, NE, EQ, LIKE, CONTAINS, OR, AND
Add g3n-github app to repository
Labels: name: auto:enhancement

This GitHub App is used by Google employees to monitor GitHub repositories. It sends notifications in Chrome for Reviews, updates to Pull Requests, Mentions, etc.

https://github.com/apps/g3n-github

Could it be added to the LangChain repository to make it easier for Google engineers to contribute in a timely manner? (Must be done by an organization administrator)

@baskaryan @hwchase17

Thanks!
Reproducible output feature with Azure Open AI (support for seed parameter)
Labels: name: auto:enhancement, name: area: models

### Feature request

There is a new feature with Azure Open AI to get deterministic output. 

To use this feature we need to pass extra parameters when we iniative AzureOpenAI 

https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/reproducible-output?tabs=pyton

### Motivation

Getting deterministic feature is a very important for most of the Generative AI applications. This feature would be a huge help.

https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/reproducible-output?tabs=pyton

### Your contribution

Yes, depends on the change what needed here can help
feat: Added `pre-commit-config.yaml` file and modified code accordingly.
Labels: name: auto:improvement, name: area: models, name: size:L

**Description:** Added a pre-commit configuration file (`.pre-commit-config.yaml `) to the codebase as it helps improve the code quality and maintain consistency within the project. It will allow all the developers/future contributors to maintain a consistent code style. Adding this will help us by running some automated checks before anyone tries to make a commit.

Later on the other linters currently used (`Ruff`, `codespell`, etc.) can also be integrated here. Which ensures that every-commit passes all the lint rules.
We can always skip the checks with `git commit -m "xyz"--no-verify"`

**Issue:** #14845
  - **Dependencies:** Requires pre-commit hooks that run automated checks (https://github.com/pre-commit/pre-commit-hooks)
  - **Tag maintainer:** @hwchase17,
  - **Twitter handle:** https://twitter.com/Sai_Suraj_27
Fix token text splitter duplicates
Labels: name: lgtm, name: auto:bug, name: area: models, name: size:S

  - **Description:** 
    - Add a break case to `text_splitter.py::split_text_on_tokens()` to avoid unwanted item at the end of result.
    - Add a testcase to enforce the behavior.
  - **Issue:** 
    - #14649 
    - #5897
  - **Dependencies:** n/a,
 
---

**Quick illustration of change:**

```
text = "foo bar baz 123"

tokenizer = Tokenizer(
        chunk_overlap=3,
        tokens_per_chunk=7
)

output = split_text_on_tokens(text=text, tokenizer=tokenizer)
```
output before change: `["foo bar", "bar baz", "baz 123", "123"]`
output after change: `["foo bar", "bar baz", "baz 123"]`
Community: Gradient: Embeddings-sdk-update
Labels: name: lgtm, name: area: embeddings, name: auto:improvement, name: size:XL

<!-- 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://python.langchain.com/docs/contributing/

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.
 -->

  - **Description:** Going forward, we have a own API `pip install gradientai`.  Therefore gradually removing the self-build packages in llamaindex, haystack and langchain. 
  - **Issue:** None.
  - **Dependencies:** `pip install gradientai`
  - **Tag maintainer:** @michaelfeil
Adding a `.pre-commit-config.yaml` file for maintaining consistent style and code quality
Labels: name: auto:improvement

### Feature request

I'm thinking about adding a pre-commit configuration file (`.pre-commit-config.yaml `) to the codebase as it helps improve the code quality and maintain consistency within the project. It will allow all the developers/future contributors to maintain a consistent code style. Adding this will help us by running some automated checks before anyone tries to make a commit.

1. [trailing-whitespace](https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#trailing-whitespace) (Removes trailing whitespace at the end of lines)
2. [end-of-file-fixer](https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#end-of-file-fixer) (Ensures that files end with a newline character)
3. [check-yaml](https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#check-yaml) (Attempts to load all yaml files to verify syntax)


### Motivation

These checks are very common and used in many big `Python` based organizations including [scikit-learn](https://github.com/scikit-learn/scikit-learn/blob/main/.pre-commit-config.yaml), [jax](https://github.com/Sai-Suraj-27/jax/blob/main/.pre-commit-config.yaml), [pandas](https://github.com/Sai-Suraj-27/pandas/blob/main/.pre-commit-config.yaml#L72), etc.
They help in maintaining consistent style across the repository and ensures same formatting and quality for all the contributors.

### Your contribution

I have a good experience in adding/modifying this file in large codebases (https://github.com/unifyai/ivy/pull/22220, https://github.com/unifyai/ivy/pull/22974, https://github.com/gprMax/gprMax/pull/354,  https://github.com/pandas-dev/pandas/pull/55277) 
So, if you think it is useful let me know I will make a PR, Thank you.
Update Tongyi default model_name
Labels: name: lgtm, name: auto:nit, name: area: models, name: size:XS

<img width="1305" alt="Screenshot 2023-12-18 at 9 54 01 PM" src="https://github.com/langchain-ai/langchain/assets/10000925/c943fd81-cd48-46eb-8dff-4680424d9ba9">

The current model is no longer available.
azure_ad_token variable does not work for AzureChatOpenAI and AzureOpenAIEmbeddings
Labels: name: area: embeddings, name: auto:bug

### System Info

langchain: 0.0.350
Python: 3.8.8

### Who can help?

@hwchase17 @agola11 

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [X] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Run code below,

```python

from langchain.embeddings.azure_openai import AzureOpenAIEmbeddings
from azure.identity import AzureCliCredential

credential = AzureCliCredential()
token = credential.get_token("https://cognitiveservices.azure.com/.default")

embeddings = AzureOpenAIEmbeddings(
    deployment=model_name_retriever,
    chunk_size=16,
    azure_endpoint=azure_endpoint,
    azure_ad_token=token,
    openai_api_version=api_version,
    http_client=http_client
)
```

Then,

```
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-b617513b6ef1> in <module>
----> 6 embeddings = AzureOpenAIEmbeddings(
      7     deployment=model_name_retriever,
      8     chunk_size=16,

/opt/conda/lib/python3.8/site-packages/pydantic/main.cpython-38-x86_64-linux-gnu.so in pydantic.main.BaseModel.__init__()

/opt/conda/lib/python3.8/site-packages/pydantic/main.cpython-38-x86_64-linux-gnu.so in pydantic.main.validate_model()

/opt/conda/lib/python3.8/site-packages/langchain_community/embeddings/azure_openai.py in validate_environment(cls, values)
     82             "AZURE_OPENAI_ENDPOINT"
     83         )
---> 84         values["azure_ad_token"] = values["azure_ad_token"] or os.getenv(
     85             "AZURE_OPENAI_AD_TOKEN"
     86         )

KeyError: 'azure_ad_token'
```

This error also happens in AzureChatOpenAI. These behavior do not match with [current API](https://api.python.langchain.com/en/stable/chat_models/langchain_community.chat_models.azure_openai.AzureChatOpenAI.html#langchain_community.chat_models.azure_openai.AzureChatOpenAI)

### Expected behavior

Defining class successfully.
Improve prompt injection detection
Labels: name: lgtm, name: auto:improvement, name: area: models, name: size:L

 - **Description:** This is addition to [my previous PR](https://github.com/langchain-ai/langchain/pull/13930) with improvements to flexibility allowing different models and notebook to use ONNX runtime for faster speed. Since the last PR, [our model](https://huggingface.co/laiyer/deberta-v3-base-prompt-injection) got more than 660k downloads, and with the [public benchmark](https://huggingface.co/spaces/laiyer/prompt-injection-benchmark) showed much fewer false-positives than the previous one from deepset. Additionally, on the ONNX runtime, it can be running 3x faster on the CPU, which might be handy for builders using Langchain. 
 **Issue:** N/A
 - **Dependencies:** N/A
 - **Tag maintainer:** N/A 
- **Twitter handle:** `@laiyer_ai`
safety_settings argument is missing with the ChatVertexAI mode
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

safety_settings argument is missing with the `ChatVertexAI` model

### Suggestion:

Should be able to define the safety settings. For example:

```
safety_settings = {
  HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
  HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
  HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
  HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
}

llm = ChatVertexAI(safety_settings=safety_settings)
```
docs: fixed tiktoken link error
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:XS

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** fixed tiktoken link error, 
  - **Issue:** no,
  - **Dependencies:** no,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** no!

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://python.langchain.com/docs/contributing/

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.
 -->
- **Description:** fixed tiktoken link error, 
- **Issue:** no,
- **Dependencies:** no,
- **Tag maintainer:** @baskaryan,
- **Twitter handle:** SignetCode!
added jaguar vector store
Labels: name: area: vector store, name: auto:enhancement, name: size:XXL

Description: A new vector store Jaguar is being added. Class, test scripts, and documentation is added.
Issue: None -- This is the first PR contributing to LangChain
Dependencies: This depends on "pip install -U jaguardb-http-client" client http package
Tag maintainer: @baskaryan, @eyurtsev, @hwchase1
Twitter handle: @workbot
Issue: Is there any method in Langchain to fetch all the content of its Sub URL by giving its base URL only
Labels: name: area: doc loader, name: auto:question

### Issue you'd like to raise.


I am working on a project where i need to fetch the content of sub URL by giving its base URL only.
Is there any method in Langchain to fetch all the content of its Sub URL by giving its base URL only ?

### Suggestion:

_No response_
Async PGVector to make LangChain with Postgres more performant
Labels: name: area: vector store, name: auto:enhancement

### Feature request

Currently we use PGVector as our Vector Database and do in combination with FastAPI. One issue is that in the indexing process, which happens over an API Endpoint, we found out that the current implementation of PgVector is blocking due to its synchronous implementation. FastAPI offers async/await and SQLAlchemy also allows using async sessions. I would like to add an Async Alternative for PGVector. 

### Motivation

Non-Blocking code execution prevents blocking the main thread of our execution and provides far superior performance compared to synchronous execution

### Your contribution

I already coded a prototype, which works so far and does not block the main thread of the API. I would fully implement this async solution. Currently I only have to discuss this with my boss, since I did this during worktime.
fix: ak and sk are not essential in qianfan endpoint
Labels: name: lgtm, name: auto:improvement, name: area: models, name: size:M

  - **Description:** The Qianfan SDK offers multiple authentication methods, but in the `QianfanEndpoint` of Langchain, it currently only supports authentication through AK and SK. In order to accommodate users who wish to use alternative authentication methods, this pull request makes AK and SK optional. This change should not impact existing users, while allowing users to configure other authentication methods as per the Qianfan SDK documentation.
  - **Issue:** /
  - **Dependencies:** No
  - **Tag maintainer:** No
  - **Twitter handle:**
OPENAI_PROXY not working
Labels: name: lgtm, name: auto:bug, name: area: models, name: size:XS

Replace this entire comment with:
  - **Description:** OPENAI_PROXY is not working for openai==1.3.9, The `proxies` argument is deprecated. The `http_client` argument should be passed instead,
  - **Issue:** OPENAI_PROXY is not working,
  - **Dependencies:** None,
  - **Tag maintainer:** @hwchase17 ,
  - **Twitter handle:** timothy66666
Add an OpentelemetryTracer in LangChain
Labels: name: auto:enhancement, name: area: models

### Feature request

There's already many tracers in LangChain (https://github.com/langchain-ai/langchain/tree/master/libs/langchain/langchain/callbacks/tracers).
I would like to ask for adding an OpentelemetryTracer.

### Motivation

Community tracing

### Your contribution

Would like to contribute
[Bugfix] Ensure tool output is a str, for OAI Assistant
Labels: name: area: agent, name: lgtm, name: auto:bug, name: size:XS

Tool outputs have to be strings apparently. Ensure they are formatted correctly before passing as intermediate steps.
 

```
BadRequestError: Error code: 400 - {'error': {'message': '1 validation error for Request\nbody -> tool_outputs -> 0 -> output\n  str type expected (type=type_error.str)', 'type': 'invalid_request_error', 'param': None, 'code': None}}
```