delayedkarma/langchain-issues huggingface dataset:
tables names are not case insensitive in the Snowflake Client

### System Info

langchain==0.0.195
python 3.9

the client doesn't recognize 'MY_TABLE' and 'my_table' as the same table.


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

### Reproduction

when initializing the sql client, add the param `include_tables` and set the strings in upper case fashion.
`sql_database = SQLDatabase(engine,view_support=True, include_tables=["MY_TRADE"])`

you should see this error:
`ValueError: include_tables {'MY_TRADE'} not found in database`

However, everything should go through with:
`sql_database = SQLDatabase(engine,view_support=True, include_tables=["my_trade"])`

### Expected behavior

`sql_database = SQLDatabase(..., include_tables=["MY_TRADE"])`
to be equal to 
`sql_database = SQLDatabase(..., include_tables=["my_trade"])`
Mitigate issue #5923 (Prompt injection -> SQL injection in SQLChain)
Labels: name: auto:bug

Add validation controls to the SQL chain to mitigate SQL injection issues.
Using sqlfluff to perform static analysis:
1. Disallow non select statement (INSERT, DROP)
2. Disallow wildcard select statement

Some dialects that are supported by langchain are not supported by sqlfluff. It is possible to disallow usage of such dialects as well.

Also fixed the SQL integration tests which were not working as expected

Fixes #5923 

BTW, looks like there is a huge diff on poetry.lock which doesn't look OK to me, would appreciate any advice on how to resovle it (I was following the instructions found here https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md)

#### Who can review?

@hwchase17
Implement RDF Graph and RDF QA Chain
Labels: name: enhancement

This pull request adds support for RDF Graph-based QA Chain. It uses the same signature and provides similar functionalities as the current Neo4j and Nebula implementations.

In theory, any RDF stores that support the W3C SPARQL Query Language 1.1 standard can be used, although only a few were tested during the development. 

https://github.com/lifan0127/langchain/blob/rdf-graph/docs/modules/chains/examples/graph_rdf_qa.ipynb

This approach will not scale well for large, public RDF databases such as Wikidata, but that is a more general problem that requires more research.

cc @hwchase17
Add embaas document extraction api endpoints 
Labels: name: area: doc loader

# Introduces embaas document extraction api endpoints

In this PR, we add support for embaas document extraction endpoints to Text Embedding Models (with LLMs, in different PRs coming). We currently offer the MTEB leaderboard top performers, will continue to add top embedding models and soon add support for customers to deploy thier own models. Additional Documentation + Infomation can be found [here](https://embaas.io).

While developing this integration, I closely followed the patterns established by other langchain integrations. Nonetheless, if there are any aspects that require adjustments or if there's a better way to present a new integration, let me know! :)

Additionally, I fixed some docs in the embeddings integration.

Related PR: #5976 

#### Who can review?
  DataLoaders
  - @eyurtsev
similarity_search_with_score witn Chroma DB keeps higher score for less relevant documents. 

### System Info

Python 3.10.6
chromadb==0.3.22
langchain==0.0.194

### Who can help?

similarity_search_with_score witn Chroma DB keeps higher score for less relevant documents. 

```
embeddings = OpenAIEmbeddings(
    model="text-embedding-ada-002",
    openai_api_key = openai.api_key,
    chunk_size=1
)

db = Chroma(collection_name="docs", embedding_function=embeddings, persist_directory=vector_db_path)

question = """What is the rate of arthralgia in the combined RCP and OLP inebilizumab population?"""
[d[1] for d in db.similarity_search_with_score(question, k=5 )]
```

```
[0.3035728335380554,
 0.3159480392932892,
 0.3345768451690674,
 0.3543674945831299,
 0.36075425148010254]
```

```
[d[1] for d in db.similarity_search_with_score(question, k=10 )]

[0.3035728335380554,
 0.3159480392932892,
 0.3345768451690674,
 0.3543674945831299,
 0.36075425148010254,
 0.36337000131607056,
 0.3656774163246155,
 0.36993658542633057,
 0.37518084049224854,
 0.3755079507827759]
```

Seems more like i should be doing (1-score) , to filter more relevant documents.  So i tried to test with similarity threshold of .35 , but then it returns the least similar docs  ( as .30 was more similar ) 

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

### Reproduction

question = """What is the rate of arthralgia in the combined RCP and OLP inebilizumab population?"""
[d[1] for d in db.similarity_search_with_score(question, k=5 )]
[d[1] for d in db.similarity_search_with_score(question, k=10 )]

### Expected behavior

I would expect higher similarity score for the documents that are earlier in the retruned list ( which the document is more related but has a lower score )
Issue: langchain + pgvector fail to create new tables in postgresql db

### Issue you'd like to raise.

I am trying to load llama-ccp embeddings into a postgresql with the vector extension. The db has the vector extension installed. I am using a user that has the correct privileges to create a new table and insert the embeddings. The code runs smoothly without any errors, but the collection is not being created as a new table in the db. The db name is `embeddings` and the schema name is `vector_store`.

From pgadmin I can see that the there is the following query, which means the embeddings are created and are ready to be loaded:
`INSERT INTO langchain_pg_embedding (collection_id, embedding, document, cmetadata, custom_id, uuid) VALUES ('d10c0cd8-300f-4592-aa2a-42f827...`

However, it seems that no new table is created and the table names do not correspond to the collection name I am setting - `vector_store.test_table`. Any help will be appreciated.

packages:
pgvector                       0.1.8
psycopg2-binary         2.9.6
langchain                      0.0.149

This is my code:
```
from langchain import PromptTemplate, LLMChain
from langchain.llms import GPT4All
from langchain.callbacks.base import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.document_loaders import TextLoader
from langchain.document_loaders import UnstructuredPDFLoader
from langchain.document_loaders import PyPDFLoader
from langchain.document_loaders import DirectoryLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.embeddings import LlamaCppEmbeddings
from langchain.vectorstores.faiss import FAISS
import os
import datetime

from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores.pgvector import PGVector
from langchain.docstore.document import Document

gpt4all_path = '../models/gpt4all-converted.bin' 
llama_path = '../models/ggml-model-q4_0.bin' 

embeddings = LlamaCppEmbeddings(model_path=llama_path)

loader = TextLoader('../data/test.txt')
documents = loader.load()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
docs = text_splitter.split_documents(documents)

import os
CONNECTION_STRING = PGVector.connection_string_from_db_params(
    driver=os.environ.get("PGVECTOR_DRIVER", "psycopg2"),
    host=os.environ.get("PGVECTOR_HOST", "xxxxxxxxxxx"),
    port=int(os.environ.get("PGVECTOR_PORT", "5432")),
    database=os.environ.get("PGVECTOR_DATABASE", "embeddings"),
    user=os.environ.get("PGVECTOR_USER", "xxxxxxxx"),
    password=os.environ.get("PGVECTOR_PASSWORD", "xxxxxxxxxxx"),
)

db = PGVector.from_documents(
    embedding=embeddings,
    documents=docs,
    collection_name="vector_store.test_table",
    connection_string=CONNECTION_STRING,
    pre_delete_collection=True
)
```

### Suggestion:

_No response_
chore: spedd up integration test by using smaller model

Adds a new parameter `relative_chunk_overlap` for the `SentenceTransformersTokenTextSplitter` constructor. The parameter sets the chunk overlap using a relative factor, e.g. for a model where the token limit is 100, a `relative_chunk_overlap=0.5` implies that `chunk_overlap=50` 

Tag maintainers/contributors who might be interested:

 @hwchase17, @dev2049
qdrant: search by vector
Labels: name: lgtm

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Added support to `search_by_vector` to Qdrant Vector store.

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->


### Who can review
VectorStores / Retrievers / Memory
- @dev2049
<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @hwchase17



 -->
Emiting events during processing of intermediate steps

### Feature request

Langchain agent performs multiple intermediate steps before returning a response. We want to emit an event for every intermediate step during processing, so that the client-side can be updated about what's being processed at any given time. 

For example, if an intermediate steps involves searching Google, we can then emit an event that informs the client about the search taking place. 

This could massively improve UX. 

### Motivation

The motivation comes from wanting to improve UX. We're developing a langchain-based app and this feature is sorely missed.

### Your contribution

We could definitely submit a PR if you give a little bit of guidance on how to go about with it.
make modelname_to_contextsize as a staticmethod
Labels: name: lgtm

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes ##6039

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:
@hwchase17　@agola11
<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
Make modelname_to_contextsize as a staticmethod to use it without create an object

### Feature request

Make [modelname_to_contextsize](https://github.com/hwchase17/langchain/blob/289e9aeb9d122d689d68b2e77236ce3dfcd606a7/langchain/llms/openai.py#L503) as staticmethod to use it without create an object.

### Motivation

While using ChatOpenAI or AzureChatOpenAI, to use modelname_to_contextsize we need to create OpenAI or AzureOpenAI object whether we don't use it.
For example, llama-index using [modelname_to_contextsize](https://github.com/jerryjliu/llama_index/blob/f614448a045788c9c5c9a774f407a992ae1f7743/llama_index/llm_predictor/base.py#L42) to get context size, but it raise an error if we using AzureOpenAI without setting OPENAI_API_TOKEN.


### Your contribution

#6040
Validation error for gpt4all 

### System Info

I followed the steps to install gpt4all based on this repo
https://github.com/nomic-ai/gpt4all/tree/main/gpt4all-bindings/python
I have the latest version of langchain

### Who can help?

@hwchase17 

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [X] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction
```
 def mainllm():
 template = """Question: {question}

prompt = PromptTemplate(template=template, input_variables=["question"])
local_path = './models/gpt4all-converted.bin'
llm = gpt4all.GPT4All("ggml-gpt4all-j-v1.3-groovy.bin")
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "What NFL team won the Super Bowl in the year Justin Bieber was born?"
llm_chain.run(question)
    
if __name__ == '__main__':
mainllm()
```
This is the error I get related to this lines on code:

```
Traceback (most recent call last):
  File "gpt4all.py", line 174, in <module>
    mainllm()
  File "gpt4all.py", line 166, in mainllm
    llm = gpt4all.GPT4All("ggml-gpt4all-j-v1.3-groovy.bin")
TypeError: Serializable.__init__() takes 1 positional argument but 2 were given
```

### Expected behavior

Could you help me understand what is wrong?
Thanks
Report:Discussion about the bug mentioned in the documentation

### Issue with current documentation:

Report

I am currently reading the documentation for version 0.0.197 and testing step by step. When I ran into the "agents-with-chat-models" section, I encountered a type error in the code. The specific situation is as follows:

[doc link](https://python.langchain.com/en/latest/getting_started/getting_started.html#agents-with-chat-models)

```python
# this is my code
llm = AzureOpenAI(
    model_name = os.environ["GPT_ENGINE"],
    deployment_name = os.environ["GPT_ENGINE"],
    openai_api_key = os.environ["API_KEY"],
    temperature = 0,
    max_tokens = 1000,
    top_p = 0.95,
    frequency_penalty = 0,
    presence_penalty = 0
)
chat = AzureChatOpenAI(
    model_name = os.environ["GPT_ENGINE"],
    deployment_name = os.environ["GPT_ENGINE"],
    openai_api_key = os.environ["API_KEY"],
    openai_api_base = os.environ["API_BASE"],
    openai_api_version= os.environ["API_VERSION"],
    temperature = 0,
    max_tokens = 1000
)
tools = load_tools(["serpapi", "llm-math"], llm=llm)
# Finally, let's initialize an agent with the tools, the language model, and the type of agent we want to use.
agent = initialize_agent(tools, chat, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
# Now let's test it out!
agent.run("Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?").format
```

```log-output
> Entering new AgentExecutor chain...
Thought: I need to use a search engine to find Olivia Wilde's boyfriend and a calculator to raise his age to the 0.23 power.
Action:

{
  "action": "Search",
  "action_input": "Olivia Wilde boyfriend"
}


Observation: Looks like Olivia Wilde and Jason Sudeikis are starting 2023 on good terms. Amid their highly publicized custody battle – and the actress' ...
Thought:Now I need to use a calculator to raise Jason Sudeikis' age to the 0.23 power.
Action:

{
  "action": "Calculator",
  "action_input": "pow(47, 0.23)"
}
```

```error-output
ValueError: LLMMathChain._evaluate("
pow(47, 0.23)
") raised error: 'VariableNode' object is not callable. Please try again with a valid numerical expression

```

### Idea or request for content:

_No response_
Resolve the issue with the asynchronous function generate_concurrentl…
Labels: name: area: doc loader, name: auto:documentation

…y in async_chain.ipynb

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes # (issue)
Doc code err!

#### Before submitting
```
async def generate_concurrently():
    llm = OpenAI(temperature=0.9)
    prompt = PromptTemplate(
        input_variables=["product"],
        template="What is a good name for a company that makes {product}?",
    )
    chain = LLMChain(llm=llm, prompt=prompt)
    tasks = [async_generate(chain) for _ in range(5)]
    await asyncio.gather(*tasks)

s = time.perf_counter()
# If running this outside of Jupyter, use asyncio.run(generate_concurrently())
await generate_concurrently()
```
#### After submitting
```
async def generate_concurrently():
    llm = OpenAI(temperature=0.9)
    prompt = PromptTemplate(
        input_variables=["product"],
        template="What is a good name for a company that makes {product}?",
    )
    chain = LLMChain(llm=llm, prompt=prompt)
    tasks = [async_generate(chain) for _ in range(5)]
    await asyncio.gather(*tasks)

s = time.perf_counter()
# If running this outside of Jupyter, use asyncio.run(generate_concurrently())
asyncio.run(generate_concurrently())
```

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
Allow GoogleDrive to authenticate via application default credentials on Cloud Run/GCE etc without service key
Labels: name: lgtm

@eyurtsev

The existing GoogleDrive implementation always needs a service account to be available at the credentials location.  When running on GCP services such as Cloud Run, a service account already exists in the metadata of the service, so no physical key is necessary.  This change adds a check to see if it is running in such an environment, and uses that authentication instead.
TypeError("Requests.apost() missing 1 required positional argument: 'data'")

### System Info

langchain = "^0.0.197"

### Who can help?

@agola11

### 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
- [X] Async

### Reproduction

``` python
import asyncio

from langchain.utilities import TextRequestsWrapper

requests = TextRequestsWrapper()


async def fun():
    ret = await requests.apost("http://127.0.0.1:8080", data={"data": 123})


if __name__ == '__main__':
    asyncio.run(fun())

```

### Expected behavior

![image](https://github.com/hwchase17/langchain/assets/7575944/e4ff4dc1-54e2-43ce-999e-9c233c2a6752)
Add clearer API for defining `k` (number of documents retrieved) in VectorStore/retriever defining functions

### Feature request

Let users easily define the value of `k`, which is the number of documents retrieved, when specifying a VectorStore.

### Motivation

When working with documents, users typically need to specify VectorStore, and users may often want to define the specific number of documents being retrieved, i.e., the `k`, when similarity search runs behind the scene. For example, I am doing
```
docsearch = Chroma.from_documents(texts1 + texts3, embeddings)
retriever=docsearch.as_retriever(search_kwargs = {'k':1})
```
However, there is no easy way or clear documentation for this. I have to go through the source code all the ways to find that I can do it with adding `search_kwargs = {'k':1}` when I specify the retriever. This is not user-friendly, especially noticing that this is a common feature that users need.

### Your contribution

I would love to open a PR for this. I am willing to either change the code or writing a clearer documentation for this feature.