delayedkarma/langchain-issues huggingface dataset:
Nc/why lcel
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/langchain-ai/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.
 -->
Cost calculation is always zero with fine-tuned OpenAI models
Labels: name: auto:bug, name: area: models

### System Info

LangChain 0.0.240

but code on latest master has same issue

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

### Reproduction

Use a fine-tuned OpenAI model, named like "ft:gpt-2.5-turbo-0613:orgname@12abCDEF"

`with get_openai_callback() as openai_callback:`

`openai_callback.total_cost`

The cost is zero.

### Expected behavior

The cost is returned.

The issue is in https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/callbacks/openai_info.py#L67

which expects fine-tuned models' names' to start with "ft-" (dash, should be colon)
New add Baichuan Model
Labels: name: needs documentation

Motivation and Context
At present, the Baichuan Large Language Model is relatively popular and efficient in performance. Due to widespread market recognition, this model has been added to enhance the scalability of Langchain's ability to access the big language model, so as to facilitate application access and usage for interested users.

System Info
langchain： 0.0.295
python：3.8.3
IDE：vs code

Description
Add the following files:

1. Add baichuan_baichuaninc_endpoint.py in the libs/langchain/langchain/chat_models
2. Modify the __init__.py file,which is located in the libs/langchain/langchain/chat_models/__init__.py：
    a. Add "from langchain.chat_models.baichuan_baichuaninc_endpoint import BaichuanChatEndpoint"
    b. Add "BaichuanChatEndpoint" In the file's __ All__  method

Your contribution
I am willing to help implement this feature and submit a PR, but I would appreciate guidance from the maintainers or community to ensure the changes are made correctly and in line with the project's standards and practices.
Add deploy command to repos generated by cli template
Labels: name: auto:improvement

<!-- 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/langchain-ai/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.
 -->
Issue: Invalid prompt schema: Missing value for input  [GraphCypherQAChain][cypherPrompt]
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

Having issue with cypherPrompt in GraphCypherQAChain . 
I am trying to use GraphCypherQAChain and Bedrock to generate an answer from Neo4j database.
I am using local Neo4j Movies database and the code example from: https://js.langchain.com/docs/modules/chains/additional/cypher_chain

Here is the code: 

```
const { PromptTemplate } = require("langchain/prompts");
const { GraphCypherQAChain } = require("langchain/chains/graph_qa/cypher");
const { Neo4jGraph } = require("langchain/graphs/neo4j_graph");
const { Bedrock } = require("langchain/llms/bedrock");

const url = "bolt://localhost:7687";
const username = "neo4j";
const password = "***";
const aiModelId = "ai21.j2-mid-v1";

module.exports.chainRun = async (event) => {
  const graph = await Neo4jGraph.initialize({ url, username, password });
  const model = new Bedrock({
    model: aiModelId,
    region: "***",
    maxTokens: 200,
    temperature: 0.5,
    stopSequences: ["\n\nHuman:"],
    credentials: {
      accessKeyId: "***",
      secretAccessKey: "***",
    },
  });

  await graph.query(
    "CREATE (a:Actor {name:'Bruce Willis'})" +
      "-[:ACTED_IN]->(:Movie {title: 'Pulp Fiction'})"
  );

  const cypherTemplate = `Task:Generate Cypher statement to query a graph database.
    Instructions:
    Use only the provided relationship types and properties in the schema.
    Do not use any other relationship types or properties that are not provided.
    Schema:
    {schema}
    Note: Do not include any explanations or apologies in your responses.
    Do not respond to any questions that might ask anything else than for you to construct a Cypher statement.
    Do not include any text except the generated Cypher statement.
    Follow these Cypher example when Generating Cypher statements:
    # How many actors played in Top Gun?
    MATCH (m:Movie {title:"Top Gun"})<-[:ACTED_IN]-()
    RETURN count(*) AS result 

    The question is:
    {question}`;

  const cypherPrompt = new PromptTemplate({
    template: cypherTemplate,
    inputVariables: ["schema", "question"],
  });

  const chain = GraphCypherQAChain.fromLLM({
    llm: model,
    graph,
    cypherPrompt,
  });

  const res = await chain.run("Who played in Pulp Fiction?");
  return {
    statusCode: 200,
    body: JSON.stringify(res),
  };
};
```


The error that I am getting:

<img width="926" alt="Screenshot 2023-10-12 at 2 08 52 PM" src="https://github.com/langchain-ai/langchain/assets/42175061/3f40f1e1-09fa-4ebf-ae29-35f6dc28e0b3">



If I run that query directly it returns result, also if I remove that part from cypher prompt there are no issues.

Can you help me to find what is the issue?






### Suggestion:

_No response_
SingleStoreDBChatMessageHistory: Add singlestoredb support for ChatMessageHistory
Labels: name: area: memory, name: auto:enhancement

**Description**

- Added the `SingleStoreDBChatMessageHistory` class that inherits `BaseChatMessageHistory` and allows to use of a SingleStoreDB database as a storage for chat message history.
- Added integration test to check that everything works (requires `singlestoredb` to be installed)
- Added notebook with usage example
- Removed custom retriever for SingleStoreDB vector store (as it is useless)
Add YandexGPT LLM and Chat model
Labels: name: auto:enhancement, 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/langchain-ai/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.
 -->
  - **Description:** Introducing an ability to work with the [YandexGPT](https://cloud.yandex.com/en/services/yandexgpt) language model.
Fix default impl of aparse_result
Labels: name: auto:bug

Should delegate to parse_result, not to aparse, as parse_result is a method that some output parsers override

<!-- 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/langchain-ai/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.
 -->
Allow API_KEY to be optional when API_BASE is selected for OpenAI.
Labels: name: auto:improvement, name: area: models

### Feature request

I propose a feature that allows the **API key** to be set as an optional **parameter** when changing the `openai_api_base` in LangChain's implementation of OpenAI. This feature would make it possible to set the API key to an empty string or any arbitrary string, similar to how it's done in **LiteLLM**. 

Relevant resources:
- LangChain OpenAI: [GitHub Repo](https://github.com/langchain-ai/langchain)
- LiteLLM Proxy: [Documentation](https://docs.litellm.ai/docs/proxy_server#create-a-proxy-for-multiple-llms)

### Motivation

The motivation for this proposal is to facilitate testing and development scenarios where the `openai_api_base` is pointed to a local or mock server that doesn't require an API key. Currently, when the API key is set to empty or an arbitrary string, LangChain OpenAI throws an `AuthenticationError`. This behavior is frustrating when trying to test or develop without a valid OpenAI API key.

### Your contribution

I am willing to help implement this feature and submit a PR, but I would appreciate guidance from the maintainers or community to ensure the changes are made correctly and in line with the project's standards and practices.
Agent stopped due to iteration limit or time limit.
Labels: name: area: agent, name: auto:question

### Issue you'd like to raise.

![run](https://github.com/langchain-ai/langchain/assets/129041904/931e32c0-ef57-470f-9834-81d2da6f2be4)
如何获取打印的日志呢？不知道怎么关闭这些打印的日志

### Suggestion:

_No response_
LocalAI embeddings require OpenAI key
Labels: name: area: embeddings, name: auto:bug

### System Info

Current master, all python versions

### Who can help?

@hwchase17 

### Information

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

### Related Components

- [ ] 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

The LocalAI embeddings class required the openai api key to be set even though this might not be required by the locally hosted server: https://github.com/langchain-ai/langchain/blob/44da27c07b2bd0ccac355c8236a3ab1dd26870eb/libs/langchain/langchain/embeddings/localai.py#L200

Initializing the class like this fails:
```
from langchain.embeddings.localai import LocalAIEmbeddings
LocalAIEmbeddings(openai_api_key=None)
#   Did not find openai_api_key, please add an environment variable `OPENAI_API_KEY` which contains it, or pass 
 `openai_api_key` as a named parameter. (type=value_error)
```

### Expected behavior

it should work fine, the key is not required for the class to function.
Understanding the Role and Functionality of Metadata and Page_Content in Langchain
Labels: name: area: embeddings, name: area: vector store, name: auto:question

### Issue you'd like to raise.

Dear Langchain Developers,

Thank you very much for developing Langchain.

I am writing to seek clarification on a few aspects of Langchain that I find intriguing. Specifically, I am interested in understanding more about the role and functionality of 'metadata' and 'page_content' within the system.

Could you kindly explain what the purpose of these two components is within Langchain? I am curious to know how they contribute to the overall functionality of the system. Additionally, I am interested in understanding how these elements are stored in vectors.

Furthermore, when a user question is used to match the most suitable text chunk, how does the system process this? After the user question is converted into a vector, does the system search the 'metadata' or the 'page_content'?

Your insights would be greatly appreciated. I am sure that understanding these aspects will enhance my appreciation of Langchain even more. Thank you in advance for your time and assistance.

Best regards,

### Suggestion:

_No response_
Issue: GPT4AllEmbeddings - dont compare with - OpenAIEmbeddings
Labels: name: area: embeddings, name: auto:question

### Issue you'd like to raise.

How to get the same values of the Float numbers generated as embeddings - 
1/ Am comparing values generated from OpenAI - from langchain.embeddings.openai import OpenAIEmbeddings
embedding = OpenAIEmbeddings()
2/ comparing with the values generated from -- gpt4all
  from langchain.embeddings import GPT4AllEmbeddings
    gpt4all_embd = GPT4AllEmbeddings()

```python

def get_embeddings_gpt4all():
    """
    """
    from langchain.embeddings import GPT4AllEmbeddings
    gpt4all_embd = GPT4AllEmbeddings()
    #text = "This is a test document."
    text = "i like dogs"
    query_result = gpt4all_embd.embed_query(text)
    print("--query_result-",type(query_result))
    print("--query_result-",len(query_result))
    print("--query_result-",query_result[0:10])
    print("--query_result-",query_result[11])
    print("--query_result-",query_result[15])

    doc_result = gpt4all_embd.embed_documents([text])
    print("--doc_result-",type(doc_result)) # List of LIST -- 
    print("--doc_result-",len(doc_result)) # 1
    print("--doc_result-",type(doc_result[0])) # List of Floats -- 
    print("--doc_result-",len(doc_result[0])) # 384
```

- terminal prints as below -- 
```
Found model file at  C:\\\\Users\\\\rohit.dhankar\\\\.cache\\\\gpt4all\\ggml-all-MiniLM-L6-v2-f16.bin
--query_result- <class 'list'>
--query_result- 384
--query_result- [-0.04856949672102928, -0.04622294753789902, 0.060556311160326004, 0.043546244502067566, -0.05463598296046257, -0.004457559902220964, 0.05100328475236893, -0.02644169144332409, 0.08410052955150604, 0.05480821430683136]
--query_result- -0.07515878230333328
--query_result- 0.05370383337140083
--doc_result- <class 'list'>
--doc_result- 1
--doc_result- <class 'list'>
--doc_result- 384
```



### Suggestion:

_No response_
fix: incorrect arguments in clickhouse docstring
Labels: name: lgtm, name: area: vector store, name: auto:documentation

  - **Description:** fix docstring for clickhouse, 
  - **Issue:** N/A,
  - **Dependencies:** none,
  - **Tag maintainer:** N/A,
  - **Twitter handle:** 


<!-- 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.
 -->
Adds GetByID Elasticsearch store strategy
Labels: name: area: vector store, name: auto:improvement

  - **Description:** 
     - Add GetByID strategy to allow retrieving exact documents when needed

     - Update ElasticsearchStore to allow loading data from an index that does not follow the Langchain index structure by 
        remapping them.

     - Fix store to return None for page_content when the field is missing, preventing hardfails if a specific document is 
       malformed.

  - **Dependencies:** None
  
  - **Twitter handle:** Void
Feat: Add support for OpenAI function call
Labels: name: area: agent, name: auto:improvement

  - **Description:** This PR proposes a simple implementation to add support for the Open AI `function_call` parameter and modifies the `with_function` for the `plan` method of the `ChatOpenAI`class accordingly.
  - **Issue:** Right now, there is no way to force the model to generate a function call as enabled by the Open AI API.
  
@baskaryan
A way to use csv_agent to simply return JSON
Labels: name: area: agent, name: auto:improvement

### Feature request

At the moment the agent spends additional rounds of agent <> LLM to format the JSON data I request to be in a sentence format. Is there a way to avoid this?

### Motivation

If the user is asking for JSON the agent should provide JSON and not a properly formatted sentence(that costs more token>money)

### Your contribution

Test, Deploy to production workload
include_df_in_prompt should be True or False and not None
Labels: name: area: agent, name: auto:bug


Replace this entire comment with:
  - **Description:** `include_df_in_prompt` does now also work with `False` instade of `None` 
  - **Issue:**   #11677
  - **Dependencies:** None
  - **Tag maintainer:**
  - **Twitter handle:** 
  
<!-- 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/langchain-ai/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.
 -->
include_df_in_prompt should be compared as boolean value and not None
Labels: name: area: agent, name: auto:bug

### System Info

Version `0.0.312`

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

# Description

The parameter `include_df_in_prompt` on the method `create_pandas_dataframe_agent` is a boolean value which should be eigther `True` or `False`.

If you specify your own suffix in the create_pandas_dataframe_agent method it results in an error saying that the variable include_df_in_prompt should be False.

## For example

```python
 agent = create_pandas_dataframe_agent(ChatOpenAI(temperature=0),df, AgentType.OPENAI_FUNCTIONS, suffix=sufix)
```
Results in 
```
ValueError: If suffix is specified, include_df_in_prompt should not be.
``` 

This is also the correct behavior. However, if you set `include_df_in_prompt` to `False`, the error still occurs. 

## For example
```python
 agent = create_pandas_dataframe_agent(ChatOpenAI(temperature=0),df, AgentType.OPENAI_FUNCTIONS, suffix=sufix, include_df_in_prompt=False)
```

But everything just works fine if I use `None` instade of `False`

## For example
```python
 agent = create_pandas_dataframe_agent(ChatOpenAI(temperature=0),df, AgentType.OPENAI_FUNCTIONS, suffix=sufix, include_df_in_prompt=None)
``

### Expected behavior

It should also work when I use `False` instade of `None`
Integrating `create_citation_fuzzy_match_chain` with `ConversationalRetrievalChain`
Labels: name: auto:enhancement, name: area: models

### Feature request

Similar to the discussion in this thread https://github.com/langchain-ai/langchain/issues/7239, I would like to have a way to show inline citations in QA tasks.

Specially, I haven't had a whole lot of success integrating `create_citation_fuzzy_match_chain` with `ConversationalRetrievalChain`

### Motivation

The point of this change is to enable QA based chains (e.g. ConversationalRetrievalChain) to easily do inline citations, and surface the citations as part of metadata fields

### Your contribution

TBD
DELETE

### Issue you'd like to raise.

Similar to the discussion in this thread https://github.com/langchain-ai/langchain/issues/7239, I would like to have a way to show inline citations in QA tasks.

Specially, I haven't had a whole lot of success integrating `create_citation_fuzzy_match_chain` with `ConversationalRetrievalChain`

### Suggestion:

_No response_