delayedkarma/langchain-issues huggingface dataset:
Issue with ChatPromptTemplate
Labels: name: auto:bug, name: area: models

### System Info

I'm using the latest version of langchain.

When my system prompt is longer than 23 lines, i get this error:
KeyError: "Input to ChatPromptTemplate is missing variable ''.  Expected: ['', 'description'] Received: ['description']"
It's being generated from this snippet:
```
def generate_output(user_input: str) -> str:
    '''This function will generate the output.scad file.'''
    chain = chat_prompt | chat_model
    print(chain)
    # similarity_search(user_input)
    llm_output = str(chain.invoke({"description": user_input})) ``` ( Error occurs on this line)


This error does not occur when my system prompt is shorter than 23 lines. Here is the code im using:

  ` 

    chat_model = ChatOpenAI(openai_api_key=api_key(), model_name="gpt-4-1106-preview", temperature=0.2, model_kwargs= 
    {"frequency_penalty": 0, "presence_penalty": 0, "top_p": 1})
    
    System_Message = Systemprompt("hello.txt")
    
    Human_Message = "generate python code to {description} "
    print("hi")
    print(Human_Message)
    chat_prompt = ChatPromptTemplate.from_messages([
    ("system", System_Message),
    ("human", Human_Message),
])  `

Here is my SystermPrompt functions:
  `def Systemprompt(file_path: str) -> str:
      '''This function will return system prompt.'''
      try:
          with open(file_path, "r") as file:
              text = file.read()
          return text
      except FileNotFoundError:
          return FileNotFoundError
      except IOError as e:
          return IOError`
        
  How can i fix this?

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] 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

chat_model = ChatOpenAI(openai_api_key=api_key(), model_name="gpt-4-1106-preview", temperature=0.2, model_kwargs= 
{"frequency_penalty": 0, "presence_penalty": 0, "top_p": 1})

System_Message = Systemprompt("hello.txt")

Human_Message = "generate python code to {description} "
print("hi")
print(Human_Message)
chat_prompt = ChatPromptTemplate.from_messages([
("system", System_Message),
("human", Human_Message),

### Expected behavior

Expected behavious is that this shoudn't happen, and i should get python code
DOC: Documentation Update Needed for 'Return Source Documents' Functionality 
Labels: name: area: doc loader, name: auto:documentation

### Issue with current documentation:


#### Issue Description
- **Overview**: The current documentation for the 'Return Source Documents' functionality seems to be outdated or incorrect. The provided code snippet results in errors when executed.

https://python.langchain.com/docs/integrations/providers/vectara/vectara_chat#conversationalretrievalchain-with-question-answering-with-sources

- **Details**: 
    - The current code:
        ```python
        chat_history = []
        query = "What did the president say about Ketanji Brown Jackson"
        result = bot({"question": query, "chat_history": chat_history})
        ```
      produces the following error:
        ```
        /python3.9/site-packages/langchain/memory/chat_memory.py", line 29, in _get_input_output
        raise ValueError(f"One output key expected, got {outputs.keys()}")
        ValueError: One output key expected, got dict_keys(['answer', 'source_documents'])
        ```
- **Examples**: This issue occurs when trying to use the 'Return Source Documents' as outlined in the current documentation.



#### Additional Information
- **Related Issue**: This documentation update is related to the issue raised in https://github.com/langchain-ai/langchain/issues/2256.




### Idea or request for content:

#### Suggested Fix
- Update the documentation with the correct code snippet:
    ```python
    memory = ConversationBufferMemory(memory_key="chat_history", input_key='question', output_key='answer', return_messages=True)
    bot = ConversationalRetrievalChain.from_llm(llm, retriever, memory=memory, return_source_documents=True)
    result = bot({"question": query,})
    
    ```
- This revision correctly handles the output and does not produce the aforementioned error.
Improve graph repr for runnable passthrough and itemgetter
Labels: name: lgtm, name: auto:improvement, name: area: langserve, name: size:M

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified 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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Update regex in output parser
Labels: name: area: agent, name: auto:improvement, name: size:M

The regex used to match "Action" and "Action Input" in the output parser has been updated. Previously, the regex did not correctly handle multi-line inputs for "Action Input". The updated code uses the 're.DOTALL' flag to ensure multi-line inputs are correctly captured.

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified 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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Random length base example selector
Labels: name: auto:improvement, name: area: models, name: size:M



    Description: The length example selector always retrieves the same examples, going from top to bottom. In the case you have a lot of examples, there will not be any variation. I just copied and modified this length selector to do a random length base examples selector, so for each prompt, the examples selected will be random

    Dependencies: Added the random import, not dependencies changed

    Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
core:  update json output parser
Labels: name: lgtm, name: auto:improvement, name: area: langserve, name: size:M

  - **Description:** changed json.py to handle additional cases of partial json string to be parsed,  basically by dropping the last character in the string until a valid json string is found or the string is empty. Also added additional test cases.
  
  - **Issue:** function parse_partial_json could not parse cases where the key is present but the value is not.
Nc/dec22/runnable graph lambda
Labels: name: auto:improvement, name: area: langserve, name: size:L

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified 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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
SQLDatabaseChain raising TypeError exception with SQLite
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

SQLDatabaseChain is throwing a TypeError when executing the .run or .invoke functions. All arguments or kwargs passed to the class are valid, but the error persists. I have trapped back to the database and there is a valid connection. My code and error are below:

```python

 sqlite_db = SQLDatabase.from_uri(
                  "sqlite:///./sqlite/ibdss.sqlite3",
                   sample_rows_in_table_info=2,
                   include_tables=["colts"]
                   )
db_chain = SQLDatabaseChain.from_llm(
                               llm,
                               sqlite_db,
                               return_direct=True,
                               use_query_checker=True,
                               return_intermediate_steps=True,
                               verbose=True
                                                                  )
 sqlite_response = db_chain.invoke({"query": "How many generators have over 10,000 hours of operation?"})
```
The issue happens when using .run as well.

Error Output:

TypeError: must be real number, not str

The traceback points to the invocation of the chain as the error area. 

### Suggestion:

_No response_
Feature request: Vertex AI Function Calling
Labels: name: auto:enhancement, name: area: models

### Feature request

Google's `gemini-pro` supports function calling. It would be nice to be able to use langchain to support function calling when using the `VertexAI` class similar to OpenAI and OpenAI's version of function calling: https://cloud.google.com/vertex-ai/docs/generative-ai/multimodal/function-calling

### Motivation

Here's a notebook where to access this functionality you have to use the `vertexai` library directly which means we lose the langchain standardization of input and output schemas: https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/function-calling/intro_function_calling.ipynb

### Your contribution

Possibly can help.
Refactor: use SecretStr for jina embeddings
Labels: name: lgtm, name: area: embeddings, name: auto:refactor, name: size:S

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified 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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Fix: fix partners name typo in tests
Labels: name: lgtm, name: auto:nit, name: area: models, name: size:S, name: partner

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified 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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
send context of docs through Chroma().as_retriever multiple times in the same conversation
Labels: name: auto:question, name: area: models, name: integration: chroma

in retrievalQa from langchain, we have a retriever that retrieves docs from a vector db and provides a context to the llm, let's say i'm using gpt3.5 whose max tokens is 4096... how do i handle huge context to be sent to it ? any suggestions will be appreciated
Using SQLDatabaseSequentialChain, discrepancy between Answer and SQLResult
Labels: name: auto:bug, name: area: models

### Discussed in https://github.com/langchain-ai/langchain/discussions/15060

<div type='discussions-op-text'>

<sup>Originally posted by **ShehneelAhmedKhan** December 22, 2023</sup>
This is my code:
     llm = OpenAI(temperature=0, model_name="gpt-3.5-turbo")
     db_chain = SQLDatabaseSequentialChain.from_llm(llm=llm, database=db, verbose=True, top_k=0) # Can use top_k if face error
     return db_chain.run(message)
     
Output:
![image](https://github.com/langchain-ai/langchain/assets/151520970/15d1c869-5e08-4c6b-bb3e-44ff3d0e4022)

The answer is denying although the sqlresult gets the answer.

Note: This is happening only in this table, other tables are being answered correctly.

using langchain==0.0.175

Any suggestion?</div>
Make it possible to give credentials directly via parameter on GoogleDriveLoader
Labels: name: area: doc loader, name: auto:improvement

### Feature request

The `GoogleDriveLoader` currently supports 3 different ways to authenticate a user.
1. Via a Service Account File
2. Via a Token File
3. Via a Live server

All those ways work perfectly, but I'm missing a way to authenticate the user via an existing JWT. There is a workaround by saving the JWT into a token file and providing this file via the `token_path` parameter. But there should also be a way to provide exactly these credentials via a parameter.

### Motivation

Maybe there is a use case where multiple accounts are required, or the user wants to authenticate over a third-party website running on an external server (not localhost). I think it would be useful to have a parameter that allows the functionality to pass a JWT without having to store it first in a file.

### Your contribution

I'm willing to submit a PR.
Add external browser authentication for Snowflake.
Labels: name: area: doc loader, name: auto:enhancement

### Feature request

The [Snowflakeconnector](https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#functions) supports authentication via browser. It would be nice if the [Langchain Snowflake Loader](https://python.langchain.com/docs/integrations/document_loaders/snowflake) also supports this feature

### Motivation

Basic authentication works in most cases. But there might be a use case where the user wants to use OAuth to log into his Snowflake instance.



### Your contribution

I'm willing to submit a PR
[community]: Elasticsearch chat history encoding
Labels: name: lgtm, name: auto:improvement, name: integration: elasticsearch, name: area: langserve, name: size:XS

- Added ensure_ascii property to ElasticsearchChatMessageHistory

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified 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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
corrected outdated link
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:XS

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified 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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
ContextualCompressionRetriever for non-english languages 
Labels: name: auto:question, name: area: models

### Issue you'd like to raise.

Hi,

I want to use the ContextualCompressionRetriever and wondering how the prompt looks like or if you can use it for non-english languages (e.g. German)?
I am using ContextualCompressionRetriever at the moment and realized that my LLM responses often switch to English, so I am assuming that the prompt for ContextualCompressionRetriever is in English language and the model gets confused which language to use.

Any recommendations?

### Suggestion:

_No response_
oracle db when use sql agent can't find table name[Error: table_names]
Labels: name: area: agent, name: auto:bug

### System Info

when i use sql agent, i want get table desc , but agent can't work , i am sure REPICA.ICA_PERSON_DATA_ALL table is existed

Question: Describe the REPICA.ICA_PERSON_DATA_ALL table
Thought: I should query the schema of the REPICA.ICA_PERSON_DATA_ALL table to get information about its columns and data types.
Action: sql_db_schema
Action Input: REPICA.ICA_PERSON_DATA_ALL
Observation: Error: table_names {'REPICA.ICA_PERSON_DATA_ALL'} not found in database


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

llm = ChatOpenAI(
    openai_api_base=openai_api_base,
    temperature=llm_temp,
    openai_api_key=openai_api_key,
    model_name=llm_model_name,
)
toolkit = SQLDatabaseToolkit(db=db, llm=llm)
agent_executor = create_sql_agent(llm = llm, toolkit=toolkit, prefix=prefix, verbose=True, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, top_k=10)
agent_executor.run("Describe the REPICA.ICA_PERSON_DATA_ALL table")




### Expected behavior

i need get REPICA.ICA_PERSON_DATA_ALL desc info
add Microsoft/Phi support
Labels: name: auto:enhancement, name: area: models

### Feature request

Microsoft's new model called [Phi](https://www.microsoft.com/en-us/research/blog/phi-2-the-surprising-power-of-small-language-models/) seems interesting...

### Motivation

Performance of smaller models 2-3B params can compare to models with 7B params.

### Your contribution

i don't know enough to so, otherwise i would submit a PR...
When I use the agent tool, I need to verify whether there are parameters in the problem. If there are no parameters, I will remind the user to input them. How can I implement this?
Labels: name: area: agent, name: auto:question

### Issue you'd like to raise.

When I use the agent tool, I need to verify whether there are parameters in the problem. If there are no parameters, I will remind the user to input them. How can I implement this?

### Suggestion:

_No response_