delayedkarma/langchain-issues huggingface dataset:
Add support for HTTP PUT in the open api agent prompt
Labels: name: area: agent, name: auto:improvement

**Description:** This PR adds HTTP PUT support for the langchain openapi agent toolkit by leveraging existing structure and HTTP put request wrapper. The PUT method is almost identical to HTTP POST but should be idempotent and therefore tighter than POST which is not idempotent. Some APIs may consider to use PUT instead of POST which is unfortunately not supported with the current toolkit yet.
pip install from source creates UNKNOWN package
Labels: name: auto:bug, name: auto:documentation

### System Info

Python Version: `Python 3.10.12`
LangChain Version: `master`

### Who can help?

@hwchase17 

### Information

- [X] 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

Following [Getting Started - Installing - From Source](https://python.langchain.com/docs/get_started/installation#from-source)

```
python3 -m pip install -e .
```

Yields an install of `UNKNOWN` package due to missing `[project]` section in the `pyproject.toml`

```
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
  Attempting uninstall: UNKNOWN
    Found existing installation: UNKNOWN 0.0.0
    Uninstalling UNKNOWN-0.0.0:
      Successfully uninstalled UNKNOWN-0.0.0
Successfully installed UNKNOWN-0.0.0
```

### Expected behavior

```
Successfully built langchain
Installing collected packages: langchain
Successfully installed langchain-0.0.294
```
LLMSingleActionAgent Doesnot provide Expected response
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

I am using LLMSingleActionAgent with ReAct Prompt. Most of the times it fails to give the proper response to the input. For example, when I greet the agent, it is not greeting back most of the times. Below is the response snippet

![image](https://github.com/langchain-ai/langchain/assets/77723011/82e15dd2-1dcc-4c55-b34d-a4a4199dce2b)

![image](https://github.com/langchain-ai/langchain/assets/77723011/14aebdb5-0c84-4e0a-8e9b-ffa98ff7e373)

**Below is my Agent code:**

agent = LLMSingleActionAgent(
    llm_chain=llm_chain,
    output_parser=output_parser,
    stop=["\nObservation:"],
    allowed_tools=tool_names
)

**Part of Prompt:**

You have access to the following tools. you can use tools, your Previous conversation history to answer the questions
{tools}

Previous Conversation history:
{history}


Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, can be one of [{tool_names}] or {history}
Action Input: the input to the action
Observation: the result of the action
Thought: I now know the final answer
Final Answer: the final answer to the original input question

**Output Parser:**

class CustomOutputParser(AgentOutputParser):

    def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:
        # Check if agent should finish
        if "Final Answer:" in llm_output:
            return AgentFinish(
                # Return values is generally always a dictionary with a single `output` key
                # It is not recommended to try anything else at the moment :)
                return_values={"output": llm_output.split("Final Answer:")[-1].strip()},
                log=llm_output,
            )
        # Parse out the action and action input
        regex = r"Action\s*\d*\s*:(.*?)\nAction\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)"
        match = re.search(regex, llm_output, re.DOTALL)
        if not match:
            raise ValueError(f"Could not parse LLM output: `{llm_output}`")
        action = match.group(1).strip()
        action_input = match.group(2)
        # Return the action and action input
        return AgentAction(tool=action, tool_input=action_input.strip(" ").strip('"'), log=llm_output)

 

### Suggestion:

_No response_
mv data bricks sql page
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.
 -->
LLaMa-2-13B-chat deployed on azureml studio giving out of context response
Labels: name: auto:bug, name: auto:question, name: area: models

### Issue you'd like to raise.

Recently, we re-deployed the llam2-13-B chat model on azure ML Studio, whenever we are trying to do in-contex learning (RAG QA), always replied back with out of context response.

Currently we are passing request payload as using langchain:

System prompt: sys msg + context
Human prompt: question
Response: out of context response

2nd variation:

Human prompt: context + question
Response: junk answers like \n

Any suggestions who have experienced?

And, we are also followed the required input format.

### Suggestion:

_No response_
Support of Gradient.ai LLM
Labels: name: auto:enhancement, name: area: models

### Feature request

I propose to add the Python client of gradient.ai as a `LLM`.

 `gradient_ai.py` under https://github.com/langchain-ai/langchain/tree/master/libs/langchain/langchain/llms
```python
class GradientAI(LLM):
     # client for Large Language Models on gradient.ai
     # 
```

See: API docs
https://docs.gradient.ai/reference/listmodels


### Motivation

Gradient.ai offers fine-tuning and inference of models without paying for the server costs. 

I fine-tuned a model with a specific RAG template based on llama2 on gradient.ai, now i want to use it from Langchain.

### Your contribution

I would submit a PR.
Updated return parameter of YouTubeSearchTool
Labels: name: lgtm, name: auto:improvement

**Description:** 
changed return parameter of YouTubeSearchTool
 

1. changed the returning links of youtube videos by adding prefix "https://www.youtube.com", now this will return the exact links to the videos
2. updated the returning type from 'string' to 'list', which will be more suited for further processings

 **Issue:** 
Fixes #10742

 **Dependencies:** 
None


<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** changed return parameter of YouTubeSearchTool
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** None
  - **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.
 -->
Update return parameter of YouTubeSearchTool
Labels: name: auto:improvement

### Feature request

Return the Youtube video links in full format like `https://www.youtube.com/watch?v=VIDEO_ID`
Currently the links are like `/watch?v=VIDEO_ID`

Return the links as List like `['link1, 'link2']`
Currently it is returning the whole list as string ` "['link1, 'link2']" `

### Motivation

If the links returned are exact same as **direct links to youtube in a list** rather than a string, i can avoid the hustle and bustle of processing it agian to convert to the required format

### Your contribution

I will change the code a bit and pull it.
Issue: How to update Pinecone vectors data using langchain
Labels: name: area: doc loader, name: area: vector store, name: auto:question, name: auto:improvement, name: integration: pinecone

### Issue you'd like to raise.

I am using langchain with Pinecone to push the embedding into the Pincone vector db. using below code. But I see that there is too many IDs created for the single PDF file in Pincone Browswer(My PDF file more than 250 pages). I want to update my PDF for the same Index. How can I do ?

`from langchain.document_loaders import UnstructuredPDFLoader, OnlinePDFLoader, PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores import Chroma, Pinecone
from langchain.embeddings.openai import OpenAIEmbeddings
import pinecone
import os
from langchain.llms import OpenAI
from langchain.chains.question_answering import load_qa_chain

loader = UnstructuredPDFLoader("example.pdf")
data = loader.load()

text_splitter = RecursiveCharacterTextSplitter(chunk_size=2000, chunk_overlap=0)
texts = text_splitter.split_documents(data)
type(texts)

OPENAI_API_KEY = "sk-xxxxx"
PINECONE_API_KEY = "xxxx"
PINECONE_API_ENV = "us-west-gcp-free"

embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)

pinecone.init(
    api_key=PINECONE_API_KEY,  
    environment=PINECONE_API_ENV
)
index_name = "langchaintest"
docsearch = Pinecone.from_texts([t.page_content for t in texts], embeddings, index_name=index_name)`


I want to update my vectors Due to multiple IDs I am not able to get the ID to update the New one PDF file

### Suggestion:

ID should be one for the single PDF file.
Bug fixes for runnables
Labels: name: auto:bug

- tools invoked in async methods would not work due to missing await
- RunnableSequence.stream() was creating an extra root run by mistake, and it can simplified due to existence of default implementation for .transform()

<!-- 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: <Langchain Retriever Agent Function Not Passing “ChatMessageHistory” When Called in Console - Python>
Labels: name: area: memory, name: area: agent, name: auto:bug, name: integration: pinecone

### Issue you'd like to raise.

Hello everyone,

I am facing an issue with a Python function that I have created to handle some chat functionality with the ChatGPT model. The function is part of a bigger project that aims to use Pinecone to search and retrieve similar documents.

Here is a simplified version of my code:

> def pineconeGPT(system, user, questions, answers, instruction, metadata={}):
  llm = ChatOpenAI(model='gpt-3.5-turbo-16k', temperature=0, openai_api_key="key")
      embeddings = OpenAIEmbeddings(
          openai_api_key="key", model="text-embedding-ada-002")
      pinecone.init(api_key='key', environment='region')
  index = Pinecone.from_existing_index('index_name', embeddings)
  history = ChatMessageHistory()
      if len(questions) > 0:
          for i in range(len(questions)):
              history.add_ai_message(questions[i])
              history.add_user_message(answers[i])
  retriever = index.as_retriever(
                  search_type="similarity",
                  search_kwargs={'filter': metadata}
              )
    pineconeIndex = create_retriever_tool(
          retriever, 
          "search_pinecone",
          "Searches and returns documents regarding the similarity."
          )
  tools = [pineconeIndex]
  system_message = SystemMessage(
          content=(system)
      prompt = OpenAIFunctionsAgent.create_prompt(
          system_message=system_message
      )
  agent = OpenAIFunctionsAgent(llm=llm, tools=tools, prompt=prompt)
  agent_executor = AgentExecutor(
          agent=agent,
          tools=tools,
          memory=ConversationBufferMemory(chat_memory=history),
          verbose=True,
          return_intermediate_steps=False,
          return_only_outputs=False)
  result = agent_executor({"input" : instruction})

The history is included in the result but for example:

If the question is: What is your name? 
Answer: My name is Bob 

And the instruction says "what is my name" 
ChatGPT response is saying I have not provided name.

This suggest that ChatGPT has not being passed the history by the agent.


I would appreciate any insights on what might be causing this issue and how to resolve it. Thank you in advance!

### Suggestion:

_No response_
Typing error in WebResearchRetriever
Labels: name: area: vector store, name: auto:bug

### System Info

langchain 0.0.292

The type of text_splitter must be TextSplitter and not RecursiveCharacterTextSplitter
```
class WebResearchRetriever(BaseRetriever):
    ...
    text_splitter: **TextSplitter** = Field(
        RecursiveCharacterTextSplitter(chunk_size=1500, chunk_overlap=50),
        description="Text splitter for splitting web pages into chunks",
    )
```

### Who can help?

@hwchase17

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

### Reproduction

Use WebResearchRetriever with a simple TextRetriver. It's run.
Now `make lint` => Error

### Expected behavior

No error with `make lint`

Pull request [here](https://github.com/langchain-ai/langchain/pull/10734)
get_openapi_chain throws error when running example from docs
Labels: name: auto:bug

### System Info

pydantic    '1.10.0'   or '2.3.0'
langchain  '0.0.292'
python       '3.11.5'



### Who can help?

@hwchase17 
@agola11

### Information

- [X] 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.openai_functions.openapi import get_openapi_chain
chain = get_openapi_chain("https://www.klarna.com/us/shopping/public/openai/v0/api-docs/")
chain("What are some options for a men's large blue button down shirt")

Error message when running with pydantic 1
Unable to parse spec from source https://chat-web3-plugin.alchemy.com/openapi.yaml  error 

Error message when running with pydantic 2
AttributeError: type object 'OpenAPISpec' has no attribute 'from_url'


### Expected behavior

normal execution without errors
Update ContextCallbackHandler Docstring & metadata key
Labels: name: lgtm, name: auto:documentation, name: area: models


  - **Description:** Updating URL in Context Callback Docstrings and update metadata key Context CallbackHandler uses to send model names.
  - **Issue:** The URL in ContextCallbackHandler is out of date. Model data being sent to Context should be under the "model" key and not "llm_model". This allows Context to do more sophisticated analysis.
  - **Dependencies:** None

Tagging @agamble.
async mongodb chat message history 
Labels: name: area: memory, name: auto:improvement

### Feature request

Switch to motor in the [MongoDBChatMessageHistory](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/memory/chat_message_histories/mongodb.py) class for asyncio support.

### Motivation

There is already a PR #10645 for async Document Loader for MongoDB, this way we can keep consistency in the mongodb clients.

### Your contribution

I already implemented it, if you want  I can submit a PR.
Sagemaker endpoint capability to inject boto3 client for cross account scenarios
Labels: name: lgtm, name: auto:improvement, name: area: models, name: integration: aws

  - **Description: Allow to inject boto3 client for Cross account access type of scenarios in using Sagemaker Endpoint ** 
  - **Issue:#10634 #10184** 
  - **Dependencies: None** 
  - **Tag maintainer:** 
  - **Twitter handle:lethargicoder**
Issue: unexpected keyword argument 'stop' 
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "D:\Users\DHANKA01\vox-usecase-wrdm-nco-dev\src\backend\api.py", line 49, in nco_generate
    result=final_run(Paths.prompt_lib,Paths.sdpk_path)
  File "D:\Users\DHANKA01\vox-usecase-wrdm-nco-dev\src\backend\llm_run.py", line 126, in final_run
    answer_resp,content_resp,question_covered=file_run(prompt_idx,index_temp,LLM_MODEL,EMBEDDING_MODEL,max_tokens,question_covered)
  File "D:\Users\DHANKA01\vox-usecase-wrdm-nco-dev\src\backend\llm_run.py", line 71, in file_run
    Ans_line, res_text=get_queryAnswer(llm_model,embedding_model,index_name,max_tokens,query,flag)
  File "D:\Users\DHANKA01\vox-usecase-wrdm-nco-dev\src\backend\llm_run.py", line 43, in get_queryAnswer
    output1=chain.run(question)
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\chains\base.py", line 290, in run    
    return self(args[0], callbacks=callbacks, tags=tags)[_output_key]
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\chains\base.py", line 166, in __call__
    raise e
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\chains\base.py", line 160, in __call__
    self._call(inputs, run_manager=run_manager)
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\chains\llm.py", line 92, in _call    
    response = self.generate([inputs], run_manager=run_manager)
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\chains\llm.py", line 102, in generate    return self.llm.generate_prompt(
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\llms\base.py", line 141, in generate_prompt
    return self.generate(prompt_strings, stop=stop, callbacks=callbacks, **kwargs)
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\llms\base.py", line 227, in generate 
    output = self._generate_helper(
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\llms\base.py", line 178, in _generate_helper
    raise e
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\llms\base.py", line 165, in _generate_helper
    self._generate(
  File "D:\Users\DHANKA01\anaconda3\envs\pls_final\lib\site-packages\langchain\llms\base.py", line 527, in _generate    else self._call(prompt, stop=stop, **kwargs)
TypeError: _call() got an unexpected keyword argument 'stop'

### Suggestion:

hi,

while running the same code with jupyter notebook, it's running fine but after integration with fastapi getting error. 
from langchain.chains import LLMChain
chain=LLMChain(llm=llm,prompt=prompt) 
chain.run(query)

Fastapi version=0.103.1
langchain version tried= 0.0.292,0.0.267,0.0.215

please suggest a fix for the same.
How to custom prompt in agent type CHAT_CONVERSATIONAL_REACT_DESCRIPTION 
Labels: name: area: agent, name: auto:question

```
agent_chain = initialize_agent(
    tools,
    llm,
    agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION,
    verbose=True,
    return_intermediate_steps=True,
    handle_parsing_errors=True,
    memory=memory
)
```

how to overwrite the PREFIX, SUFFIX and FORMAT_INSTRUCTIONS when I using the CHAT_CONVERSATIONAL_REACT_DESCRIPTION and creating agent by ```initialize_agent``` function?
feat(vectorstore): :sparkles: Create new integration with PGVector async
Labels: name: area: vector store, name: auto:enhancement, name: size:XXL

- **Description:** Add PGVector integration with support for async connections.
- **Issue:** None
- **Dependencies:** Optionally, `asyncpg` and `greenlet`.
- **Tag maintainer:** @nfcampos 
- **Twitter handle:** @jvelezmagic

Note:

I added `adelete` method to the `VectorStore` base class. It would be useful when integrating with the `SQLRecordManager`. It shouldn't have any impact on preexisting vectorstores.
using the OpenAPI toolkit, override the headers for each request
Labels: name: auto:question, name: auto:improvement, name: stale

### Issue you'd like to raise.

I configured it to use the OpenAPI toolkit by merging various APIs, but I could not solve the problem of having to redefine the header at the request stage.

### Suggestion:

I'm not sure if there is a way to solve this in langchain or if I need to apply a separate module such as a request interceptor.

Thank you in advance for your reply :)
Runnable fallbacks howto
Labels: name: area: doc loader, 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.
 -->