delayedkarma/langchain-issues huggingface dataset:
Update reduce_openapi_spec in spec.py to handle NULL value for 'docs'
Labels: name: area: agent, name: needs test, name: auto:bug

@hinthornw 

**Description**

When iterating through an openapi spec, if the value of `docs`  is NULL within a get/post/patch or delete endpoint, then the code throws an error - docs not have attribute "get".

**Example** 

An openapi compliant json spec where this is material fix - https://github.com/SpaceTradersAPI/api-docs/blob/main/reference/SpaceTraders.json

Code blob to load the file and check
```
from langchain.tools import OpenAPISpec
from langchain.agents.agent_toolkits.openapi.spec import reduce_openapi_spec

raw_spacetraders_spec = OpenAPISpec.from_file('Path/to/SpaceTraders.json') # load referenced JSON openapi spec
converted_spacetraders_spec = json.loads(raw_spacetraders_spec.json())
reduced_spacetraders_spec = reduce_openapi_spec(converted_spacetraders_spec) 
# The above line throws an Attribute error because a null type doesn't have attribute 'get' 

```

**Suggested Fix**

We can additionally check for docs being NULL as a part of the if statement. Thus, only if an endpoint is get/post/patch/delete AND the route is not null, do we store the tuple

<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Fix AgentExecutor tracing in LangSmith
Labels: name: area: agent, name: auto:bug

Description: this PR fixes an issue when AgentExecutor run is not properly traced and uploaded to LangSmith.

Before: AgentExecutor hangs indefinitely in Pending mode, output & tokens & latency are not tracked to the system
![image](https://github.com/langchain-ai/langchain/assets/18504735/5a850fdd-9869-42a7-a898-5102667a8a89)

After: everything works as expected
![image](https://github.com/langchain-ai/langchain/assets/18504735/2586ff15-3888-4fb6-9274-b15ef680713b)



<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Added Memory Parameter to SQL-Chain (Langchain Experimental)
Labels: name: area: memory, name: auto:improvement

- Description:  SQL Database Chain and Agent does not allow to pass in memory, therefore, added this feature with additional tests. 
I had created a PR #7546 for this but  chain has moved to langchain_experimental lib therefore created a new PR.
- Issue:  #6918
- Tag maintainer: @hwchase17
Rely less on positional arg order in subclasses of vector store when calling async methods
Labels: name: area: vector store, name: auto:improvement



<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
doc(prompts): Follow up on broken Prompt Sublink pages
Labels: name: auto:documentation

  - Description: Follow up of #8478  
  - Issue: #8477
  - Dependencies: None
  - Tag maintainer: @baskaryan
  - Twitter handle: [@BharatR123](twitter.com/BharatR123)

The links were still broken after #8478 and sadly the issue was not caught with either the Vercel app build and `make docs_linkcheck`
<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Cannot import name 'HumanMessage' from 'langchain.schema' 
Labels: name: auto:bug

### System Info

LangChain ==0.0.248
Platform Windows 10
Python  == 3.10.9

Whenever I use from langchain.schema import HumanMessage I get error, 

**ImportError: cannot import name 'HumanMessage' from 'langchain.schema'**

I have tried updating llama-index but still getting same error

@agola11 

### Who can help?

_No response_

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

### Reproduction

from langchain.llms import OpenAI

llm = OpenAI(openai_api_key="key")

from langchain.schema import HumanMessage

### Expected behavior

It should work
how to Stream Search tool responses
Labels: name: area: agent, name: auto:question

### Issue you'd like to raise.

search = SerpAPIWrapper()
tools = define_tools(llm_chain,search)


tools = [
      Tool(
          name="Search",
          func=search.run,
          description="useful for when you need to answer questions about current events",
          # return_direct = True
      ),


  ]

prompt = CustomPromptTemplate(
        template=template,
        tools=tools,
        input_variables=["input", "intermediate_steps", "chat_history"]
    )

output_parser = CustomOutputParser()
llm = ChatOpenAI(temperature=0, model_name = "gpt-4-0613", streaming = True, callbacks = [MyCustomHandler(new_payload=new_payload)])
llm_chain = LLMChain(llm=llm, prompt=prompt)

agent = LLMSingleActionAgent(llm_chain=llm_chain, output_parser=output_parser, stop=["\nObservation:"], allowed_tools=tools)
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent,
                                                tools=tools,
                                                verbose=True, memory = memory, early_stopping_method='generate')



### Suggestion:

_No response_
Issue: ImportError: cannot import name 'SQLDatabaseChain' from 'langchain' 
Labels: name: auto:bug

### Issue you'd like to raise.

I am just trying to from langchain import LLMMathChain, SerpAPIWrapper, SQLDatabase, SQLDatabaseChain

Traceback (most recent call last):
  File "/home/huangj/01_LangChain/LangChainCHSample/05_05_SQL_Chain.py", line 1, in <module>
    from langchain import OpenAI, SQLDatabase, SQLDatabaseChain
ImportError: cannot import name 'SQLDatabaseChain' from 'langchain' (/home/huangj/01_LangChain/langchain_env/lib/python3.8/site-packages/langchain/__init__.py)

### Suggestion:

_No response_
Update prompts to only return SQL command
Labels: name: auto:bug

v0.0.248 included new documentation for the sql integration (#8442). I had been struggling already to get sql integration working right, so as soon as I saw that I followed it. Using the `create_sql_query_chain` function resulted in the following error (it's marked as a warning, but sqlite still doesn't do anything with it:

> Warning: You can only execute one statement at a time.

I figured out this is because the prompt is still telling the LLM to try executing the sql to get an answer. In my case (on a local LLM and using OpenAI). So using the code:

```python
chain = create_sql_query_chain(llm, db, prompt=pipeline_prompt, k=10)
response = chain.invoke({"question": "How many records are in the service_logs table?"})
print(f"==={response}===") # Using === to show it's all one string
```

I got:

> ===SELECT COUNT(*) FROM "service_logs";
>
> SQLResult: 
> Answer: 3===

I was able to fix this by removing the instruction to execute the query from the response, as well as the template that shows the query, answer, etc.

Note: I am only able to test this on sqlite. I don't have access to the other databases.

Tag: @hwchase17 @baskaryan
Fix bug in SPARQL intent selection
Labels: name: auto:bug

- Description: Fix bug in SPARQL intent selection
- Issue: After the change in #7758 the intent is always set to "UPDATE". Indeed, if the answer to the prompt contains only "SELECT" the `find("SELECT")` operation returns a higher value w.r.t. `-1` returned by `find("UPDATE")`.
- Dependencies: None,
- Tag maintainer: @baskaryan @aditya-29 
- Twitter handle: @mario_scrock
🐛 Docs Fixes [2 one-liners, examples broken]
Labels: name: auto:documentation

## Description: 
   
1)Map reduce example in docs is missing an important import statement. Figured other people would benefit from being able to copy 🍝 the code.

2)RefineDocumentsChain example also broken.

## Issue: 

None

## Dependencies:

None. One liner.

## Tag maintainer:

@baskaryan

## Twitter handle: 

I mean, it's a one line fix lol. But @will_thompson_k is my twitter handle.
Add OpenAI Whisper Audio Loader
Labels: name: area: doc loader, name: auto:enhancement

- Description: Introducing an ability to load a transcription document of audio file using OpenAI Whisper
- Issue: None
- Dependencies: None
- Tag maintainer: @rlancemartin, @eyurtsev
<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Bugfix for async requests made through plugins failing making calls through agent.
Labels: name: auto:bug

This auth parameter being passed to the method results in a duplicate keyword argument since auth doesn't exist on the parameters.

This is an issue fix for https://github.com/langchain-ai/langchain/issues/7953

It was introduced as part of this change.
https://github.com/langchain-ai/langchain/commit/663b0933e488383e6a9bc2a04b4b1cf866a8ea94

@agola11  @baskaryan 
<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Bugfix for async requests made through plugins failing making calls through agent.
Labels: name: auto:bug

This auth parameter being passed to the method results in a duplicate keyword argument since auth doesn't exist on the parameters. 

This is an issue fix for #7953 

It was introduced as part of this change.
https://github.com/langchain-ai/langchain/commit/663b0933e488383e6a9bc2a04b4b1cf866a8ea94

@agola11 @baskaryan 
<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
SQL use case docs
Labels: name: auto:documentation

<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Issue: <Please write a comprehensive title after the 'Issue: ' prefix>
Labels: name: auto:question

### Issue you'd like to raise.

when i want to use openai, i install it with command"pip3 install openai", but  i really wanti to use chatglm, when i run "pip3 install chartglm ", it does not work",please help to answer the question

### Suggestion:

_No response_
Add memory to an Agent using RedisChatMessageHistory with sentinels throwing an error
Labels: name: area: memory, name: area: agent, name: auto:bug

### System Info

I am trying to use `RedisChatMessageHistory` within an agent, but I'm encountering this error:
![image](https://github.com/langchain-ai/langchain/assets/28096499/2b5b5002-3f6c-4ca3-8d28-7439a6bcbf74)

My redis url I am using looks like that:
`redis_url = "redis+sentinel://:password@host:port/service_name/db"`

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

### Reproduction

```
message_history = RedisChatMessageHistory(url=redis_url, ttl=600, session_id="test_id")
message_history.add_user_message("hi!")
message_history.add_ai_message("whats up?")
memory = ConversationBufferWindowMemory(memory_key="memory", chat_memory=message_history,  return_messages=True, k=15)
```

### Expected behavior

See on Redis the messages I added in my code.
Issue: output_parsers to work with lists of custom objects?
Labels: name: auto:question

### Issue you'd like to raise.

So It's possible to parse "complex" objects with

```python
response_schemas = [
    ResponseSchema(name="date", description="The date of the event"),
    ResponseSchema(name="place", description="The place where the event will happen"),
]
output_parser = StructuredOutputParser.from_response_schemas(response_schemas)
```

and

```python
class Pair_of_numbers(BaseModel):
    L: int = Field(description="A number")
    R: int = Field(description="A number that ends in 2, 3 or 4")

    @validator("R")
    def question_ends_with_question_mark(cls, field):
        if int(str(field)[-1]) not in [2, 3, 4]:
            raise ValueError("No bro :(")
        return field

parser = PydanticOutputParser(pydantic_object=Pair_of_numbers)
```

But I can't seem to find information on how to parse a list of custom objects/dicts? There is the [list parser](https://python.langchain.com/docs/modules/model_io/output_parsers/comma_separated), but this is just for simple strings. It's possible there is a way to achieve this wrapping a pydantic `BaseModel` in a python `List`, but so far I've had no luck 😫

### Suggestion:

_No response_
add 3 property types in metadata for notiondb loader
Labels: name: lgtm, name: area: doc loader, name: auto:improvement

### Description: 
NotionDB supports a number of common property types. I have found three common types that are not included in notiondb loader. When programs loaded them with notiondb, which will cause some metadata information not to be passed to langchain. Therefore, I added three common types: 
- date
- created_time
- last_edit_time.

### Issue: 
no
### Dependencies: 
No dependencies added :)
### Tag maintainer: 
@rlancemartin, @eyurtsev
### Twitter handle: 
@BJTUTC