delayedkarma/langchain-issues huggingface dataset:
Implement better reprs for Runnables
Labels: name: auto:improvement, name: area: models

```
ChatPromptTemplate(messages=[SystemMessagePromptTemplate(prompt=PromptTemplate(input_variables=[], template='You are a nice assistant.')), HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['question'], template='{question}'))])
| RunnableLambda(lambda x: x)
| {
    chat: FakeListChatModel(responses=["i'm a chatbot"]),
    llm: FakeListLLM(responses=["i'm a textbot"])
  }
```

<!-- 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.
 -->
Issue: <Please write a comprehensive title after the 'Issue: ' prefix>
Labels: name: auto:question, name: stale, name: area: models

### Issue you'd like to raise.

    full_chain = {
        "source1": {"question": lambda x: x["question"]} | query_chain | db.run,
        "source2": (lambda x: x['question']) | vectorstore.as_retriever(),
        "question": lambda x: x['question'],

    } | qa_prompt | ChatOpenAI(streaming=True, callbacks=[QueueCallback(q)], temperature=0, model_name='gpt-4')
    
    how can I add chat history to this?

### Suggestion:

_No response_
how to add chat history to runnablesequence instance
Labels: name: auto:question, name: stale, name: area: models

### Issue you'd like to raise.

    full_chain = {
        "source1": {"question": lambda x: x["question"]} | query_chain | db.run,
        "source2": (lambda x: x['question']) | vectorstore.as_retriever(),
        "question": lambda x: x['question'],

    } | qa_prompt | ChatOpenAI(streaming=True, callbacks=[QueueCallback(q)], temperature=0, model_name='gpt-4')
    
    how can I add chat history to this please?

### Suggestion:

_No response_
norm_eps parameters in LlamaCpp
Labels: name: auto:question, name: stale, name: area: models

### Feature request

When I use llama cpp for my case, I have [problems](https://github.com/ggerganov/llama.cpp/issues/2619). I've tried use "-esp 1e-5". It works well for me.

But when I use ```from langchain.llms import LlamaCpp``` I get the same problems. However I dont know the way to pass parameters

Thank you~~


### Motivation

Relevant with encode - decode 

### Your contribution

[Llama cpp](https://github.com/ggerganov/llama.cpp)
[BUG] OutputParserException when using CSV agent as a tool for another agent
Labels: name: area: agent, name: auto:bug, name: area: models

### System Info

langchain==0.0.299
Python 3.10.13
OS: Windows 10

### 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
- [x] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```python
from langchain.agents import initialize_agent
from langchain.agents.agent_types import AgentType
from langchain.chat_models import AzureChatOpenAI
from langchain.agents.tools import Tool
from langchain.agents import load_tools
from langchain.agents import create_csv_agent
from langchain.memory import ConversationBufferMemory


llm = AzureChatOpenAI(
    model="gpt-4",
    temperature=0,
    openai_api_version="2023-05-15",
    verbose=True,
)

tools = load_tools(["wikipedia", "llm-math"], llm=llm)

csv_agent = create_csv_agent(
    llm=llm,
    path=["sample_02.csv"],  #  some sales data
    verbose=True,
    handle_parsing_errors=True,
    agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    memory=ConversationBufferMemory(),
)
csv_tool = Tool(
    name="CSV Agent",
    func=csv_agent.run,
    description="Useful for interacting with CSV data.",
)
tools.append(csv_tool)

agent = initialize_agent(
    llm=llm,
    tools=tools,
    agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
    handle_parsing_errors=True,
    memory=ConversationBufferMemory(),
)

agent.run("What is the sum of sales")
```

### Expected behavior

I am getting exception:

```
File "C:\Users\X\lib\site-packages\langchain\agents\mrkl\output_parser.py", line 52, in parse          raise OutputParserException( langchain.schema.output_parser.OutputParserException: Could not parse LLM output: 'some info about data comes here'
```

Expected: No exception and agent should have same behaviour as if I would use the CSV agent standalone
Runtime Exception in create_extraction_chain_pydantic (RuntimeError: no validator found)
Labels: name: auto:bug, name: stale, name: area: models

### System Info

Langchain 0.0.302
Pydantic 2.4.1

reproducing code:


```

from langchain.chains import create_extraction_chain_pydantic
from langchain.chat_models import ChatOpenAI
from pydantic import BaseModel, model_validator
from typing import Any



class TestData(BaseModel):
    company_name: str


llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo")
chain = create_extraction_chain_pydantic(pydantic_schema=TestData, llm=llm)
extracted_subsidiary_list = chain.run('')
```


Exception:
**RuntimeError: no validator found for <class '__main__.TestData'>, see `arbitrary_types_allowed` in Config**

Tried adding: (didn't help)
```

    @model_validator(mode='after')
    def dummy_validator(self):
        return self

    @model_validator(mode='before')
    @classmethod
    def dummy_validator1(cls, data: Any) -> Any:
        return data
```


### Who can help?

@agola11

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

### Reproduction


```

from langchain.chains import create_extraction_chain_pydantic
from langchain.chat_models import ChatOpenAI
from pydantic import BaseModel, model_validator
from typing import Any



class TestData(BaseModel):
    company_name: str


llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo")
chain = create_extraction_chain_pydantic(pydantic_schema=TestData, llm=llm)
extracted_subsidiary_list = chain.run('')
```

### Expected behavior

Doesn't throw exception
Argument 'value' has incorrect type (expected str, got SecretStr) (type=type_error) in chatAnthropic- Induced in 0.0.301
Labels: name: auto:bug, name: area: models

### System Info

Hi Team,
The issue is while calling the ChatAnthropic function with the right anthropic secret key. The type SecretStr is not getting resolved. Discussed over here:https://github.com/langchain-ai/langchain/pull/10724

### Who can help?

@josh

### Information

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

### Related Components

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

### Reproduction

To recreate the error :
from langchain.chat_models import ChatAnthropic
claude_chat = ChatAnthropic(anthropic_api_key="xy-key")

### Expected behavior

It should initialize the claude chat
Add `hierarchy` key to Document metadata in `ConfluenceLoader`
Labels: name: area: doc loader, name: auto:improvement, name: stale

### Feature request

Add `hierarchy` key to Document metadata returned by `ConfluenceLoader`.

So, for example if a page is located under the pages Page A/Page B, the `hierarchy` should be equal to `Page A/Page B`

This could be achieved by calling the confluence endpoint using `expand = "ancestors"`.

For example [this](https://github.com/langchain-ai/langchain/blob/cfa2203c626a2287d60c1febeb3e3a68b77acd77/libs/langchain/langchain/document_loaders/confluence.py#L282) would become

```python
pages = self.paginate_request(
    self.confluence.get_all_pages_from_space,
    space=space_key,
    limit=limit,
    max_pages=max_pages,
    status="any" if include_archived_content else "current",
    expand=f"{content_format.value},ancestors",
)
```



### Motivation

Page Hierarchy is very important in a confluence-like space and it would definitely be relevant when searching for documents in the Vector Store.

### Your contribution

I am willing to submit a PR to add this feature.
chore: add support for TypeScript code splitting
Labels: name: lgtm, name: needs documentation, 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/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.
 -->

- **Description:** Adds typescript language to `TextSplitter`
Raise a warning when using OpenAI and Azure OpenAI Completion API
Labels: name: auto:improvement, name: stale, name: area: models

### Feature request

It looks like most of the models of the `Completion` API have been marked as legacy and will be discontinued in early 2024. 
On Azure OpenAI I already no longer have access to non-chat models and I can't use the completion API with the newest get-35-turbo and gpt4 (0613).

Shall we raise a warning to the user when instantiating `langchain.llms.OpenAI` and `langchain.llms.AzureOpenAI` with deprecated models?

References: 
- https://openai.com/blog/gpt-4-api-general-availability
- https://platform.openai.com/docs/deprecations


### Your contribution

I can contribute to this if the feature makes sense.
[ElasticsearchStore] Improve migration text to ElasticsearchStore
Labels: name: lgtm, name: area: vector store, name: auto:improvement

We noticed that as we have been moving developers to the new `ElasticsearchStore` implementation, we want to keep the ElasticVectorSearch class still available as developers transition slowly to the new store.

To speed up this process, I updated the blurb giving them a better recommendation of why they should use ElasticsearchStore.
ISSUE: how can i get answer only based on vector store? If the context is not available in vector store
Labels: name: area: vector store, name: auto:question, name: area: models, name: integration: pinecone

 template = """Use the following pieces of context to answer the question at the end. If the answer can't be determined using only the information in the provided context simply output "NO ANSWER", just say that you don't know, don't try to make up an answer. Use three sentences maximum. Keep the answer as concise as possible. 
    {context}
    Question: {question}
    Helpful Answer:"""
    QA_CHAIN_PROMPT = PromptTemplate.from_template(template)

    qa = RetrievalQA.from_chain_type(
        llm=streaming_llm,
        chain_type="stuff",
        retriever=compression_retriever,
        callback_manager=manager,
        chain_type_kwargs={
            "prompt": QA_CHAIN_PROMPT
        }
    )
Issue: load_agent_executor returning ConfigError
Labels: name: area: agent, name: auto:bug, name: stale, name: area: models

### Issue you'd like to raise.

I am trying to run a PlanAndExecute agent. The load_agent_executor method call returns: 
"pydantic.v1.errors.ConfigError: field "retry_chain" not yet prepared so type is still a ForwardRef, you might need to call OutputFixingParser.update_forward_refs()."

This is my code:
`import os
import dotenv
from langchain.chat_models import ChatOpenAI
from langchain_experimental.plan_and_execute import PlanAndExecute, load_agent_executor, load_chat_planner
from langchain.llms import OpenAI
from langchain.agents.tools import Tool
from langchain.chains.llm_math.base import LLMMathChain
from langchain.tools import DuckDuckGoSearchRun
from langchain.output_parsers import OutputFixingParser


dotenv.load_dotenv()

apikey = os.getenv("OPEN_AI_API_KEY", default="")

search = DuckDuckGoSearchRun()
llm = OpenAI(temperature=0, openai_api_key=apikey)
llm_math_chain = LLMMathChain.from_llm(llm=llm, verbose=True)
tools = [
    Tool(
        name="Search",
        func=search.run,
        description="useful for when you need to answer questions about current events"
    ),
    Tool(
        name="Calculator",
        func=llm_math_chain.run,
        description="useful for when you need to answer questions about math"
    ),
]

model = ChatOpenAI(temperature=0)
planner = load_chat_planner(model)
executor = load_agent_executor(model, tools, verbose=True)
agent = PlanAndExecute(planner=planner, executor=executor, verbose=True)`

### Suggestion:

_No response_
Fixed Typo Error in Update get_started.mdx file by addressing a minor typographical error.
Labels: name: auto:documentation

Fixed Typo Error in Update get_started.mdx file by addressing a minor typographical error.

This improvement enhances the readability and correctness of the notebook, making it easier for users to understand and follow the demonstration. The commit aims to maintain the quality and accuracy of the content within the repository.
please review the change at your convenience.

@baskaryan , @hwaking
Issue: Using Milvus partitions with ConversationalRetrievalChain
Labels: name: area: vector store, name: auto:bug

### Issue you'd like to raise.

I am using langchain version 0.0.281 and using Milvus as the vector store. For now, I have a Milvus-lite instance on my device. I tried using paritions with base vectorstore operations like `add_documents` and `similarity_search` and its working fine i.e it inserts and searches from the mentioned partition only. But when I try to use partitions with ConversationalRetrievalChain and even RetrievalQA it doesn't work i.e it retrieves documents through all partitions. When using `from_llm` classmethod I tried giving the partition names like below:
`QA = ConversationalRetrievalChain.from_llm(
            llm=LLM,
            retriever=VECTOR_DB.vec_db.as_retriever(partition_names=partition_names),
            memory=MEMORY,
            return_source_documents=True
)`
But this doesn't ensure that the vector store will only search the mentioned partitions, rather the vectorestore searches through all the documents present regardless of partition. Is there anyway I can limit the retrieval of documents to only those present in mentioned partition.

### Suggestion:

_No response_
P
Labels: name: area: agent, name: auto:bug, name: area: models

### System Info

when using PlanAndExecutor with guidance prompt of using tools, it does remember previously steps, which will make the pipeline fail as it doesn't know what's previously steps' ouput...


<img width="822" alt="image" src="https://github.com/langchain-ai/langchain/assets/35717759/726a42c3-e4c9-4acf-9808-66645eee090c">


### Who can help?

@hwchase17 @agola11 

### Information

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

### Related Components

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

### Reproduction

1: define guidence tools prompt:
combo_template = """
First understand the problem and devise a plan to solve the problem. 
Please output the plan starting with the header 'Plan:' and then followed by a numbered list of steps. Do not use past conversation history when you are planning the steps.
Please make the plan the minimum number of steps required to accurately complete the task. 
    
These are guidance on when to use a tool to solve a task, follow them strictly: 

first use "reverse index search" tool to get table name 
if previously step not find anyting，then use "embedding knn search" tool to get table name 
if previously step still can't find the answer, say "I can't find the answer for this question." 
otherwise use "db Querying Tool" tool to search table info using table name which previously step return

DO NOT CREATE STEPS THAT ARE NOT NEEDED TO SOLVE A TASK.     
Once you have answers for the question, stop and provide the final answers. The final answers should be a combination of the answers to all the questions, not just the last one.

Please make sure you have a plan to answer all the questions in the input, not just the last one. 
Please use these to construct an answer to the question , as though you were answering the question directly. Ensure that your answer is accurate and doesn’t contain any information not directly supported by the summary and quotes. 
If there are no data or information in this document that seem relevant to this question, please just say "I can’t find any relevant quotes".
"""

2: load chat planner with llm(llama2 13b):
planner = load_chat_planner(sm_llm)
system_message_prompt = SystemMessagePromptTemplate.from_template(combo_template)
human_message_prompt = planner.llm_chain.prompt.messages[1]
planner.llm_chain.prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])

executor = load_agent_executor(sm_llm, custom_tool_list, verbose=False)
agent = PlanAndExecute(planner=planner, executor=executor, verbose=False, max_iterations=1)

3: run agent
output = agent({"input":"最近一个月温度合格的派车单数量"})

### Expected behavior

base on each steps to get into next step with previously steps' output
DOC:  Custom Prompt example code does not work.   Requires pydantic V2
Labels: name: area: doc loader, name: auto:bug, name: auto:documentation, name: stale

### Issue with current documentation:

[This link ](https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/custom_prompt_template.html)references a code sample for a Custom Prompt (awesome stuff!)

Pydantic updated their library and the code sample or library dependencies do not work anymore.   They have a process to help migrate code
Details here:   https://docs.pydantic.dev/latest/migration/

Please update the code samples so that they work with the new version of the Pydantic library so that it works for any Langchain users.



### Idea or request for content:

Updated code samples only
update docs nav
Labels: name: auto:documentation

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Xata chat memory FIX
Labels: name: area: memory, name: lgtm, name: auto:nit

  - **Description:** Changed data type from `text` to `json` in xata for improved performance. Also corrected the `additionalKwargs` key in the `messages()` function to `additional_kwargs` to adhere to `BaseMessage` requirements.
  - **Issue:** The Chathisroty.messages() will return {} of `additional_kwargs`, as the name is wrong for `additionalKwargs` .
  - **Dependencies:**  N/A
  - **Tag maintainer:** N/A
  - **Twitter handle:** N/A

My PR is passing linting and testing before submitting.
only allow single prompt or message batch for Tracer
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/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.
 -->
Add support for MongoDB Atlas $vectorSearch vector search
Labels: name: lgtm, name: area: vector store, name: auto:improvement

Adds support for the `$vectorSearch` operator for MongoDBAtlasVectorSearch, which was announced at .Local London (September 26th, 2023). This change maintains breaks compatibility support for the existing `$search` operator used by the original integration (https://github.com/langchain-ai/langchain/pull/5338) due to incompatibilities in the Atlas search implementations.