delayedkarma/langchain-issues huggingface dataset:
Issue: Amazon Bedrock can't load my credentials when called from a Lambda function
Labels: name: auto:bug, name: auto:question

### Issue you'd like to raise.

Bedrock can't seem to load my credentials when used within a Lambda function. My AWS credentials were set up in my local environment using environment variables. When I use the bedrock class directly, it is able to load my credentials and my code runs smoothly. Here is the RetrievalQA function that utilizes the bedrock class: 

```
def qa(query):
    secrets = json.loads(get_secret())
    kendra_index_id = secrets['kendra_index_id']


    llm = Bedrock(model_id="amazon.titan-tg1-large", region_name='us-east-1')
    llm.model_kwargs = {"maxTokenCount": 4096}
    

    retriever = AmazonKendraRetriever(index_id=kendra_index_id)
    
    prompt_template = """
    {context}
    {question} If you are unable to find the relevant article, respond 'I can't generate the needed content based on the context provided.'
    """
    
    PROMPT = PromptTemplate(
    template=prompt_template, input_variables=["context", "question"])
    
    chain = RetrievalQA.from_chain_type(
    llm=llm,
    retriever=retriever,
    verbose=True,
    chain_type_kwargs={
    "prompt": PROMPT
    }
    )
    
    return chain(query)
```

The above code runs without issues when used directly. However, when used within a lambda function, it fails. The scripts file used to build my lambda function uses the bedrock class as written above, however, I run into the `validation errors` when I invoke the Lambda function. 
`
{
  "errorMessage": "1 validation error for Bedrock\n__root__\n  Could not load credentials to authenticate with AWS client. Please check that credentials in the specified profile name are valid. (type=value_error)",
  "errorType": "ValidationError",
  "requestId": "b772f236-f582-4308-8af5-b5a418d4327f",
  "stackTrace": [
    "  File \"/var/task/main.py\", line 62, in handler\n    response = qa(query)\n",
    "  File \"/var/task/main.py\", line 32, in qa\n    llm = Bedrock(model_id=\"amazon.titan-tg1-large\", region_name='us-east-1',) #client=BEDROCK_CLIENT)\n",
    "  File \"/var/task/langchain/load/serializable.py\", line 74, in __init__\n    super().__init__(**kwargs)\n",
    "  File \"pydantic/main.py\", line 341, in pydantic.main.BaseModel.__init__\n    raise validation_error\n"
  ]
`

As clearly indicated by the error message, bedrock couldn't load credentials. 

### Suggestion:

I have looked at the official documentation of the [bedrock class](https://github.com/langchain-ai/langchain/blob/b786335dd10902489f87a536ee074d747b6df370/libs/langchain/langchain/llms/bedrock.py#L51) but still do not understand why my code fails. Any help will be appreciated. @3coins @jasondotparse @hwchase17
BSHTMLLoader not working for urls
Labels: name: area: doc loader, name: auto:bug

### System Info

BSHTMLLoader not working for urls

````
from langchain.document_loaders import BSHTMLLoader

url = "https://www.google.com"

loader = BSHTMLLoader({"url": url})
doc = loader.load()
````


I tried this one also not working 

````
from langchain.document_loaders import BSHTMLLoader

url = "https://www.google.com"

loader = BSHTMLLoader({"url": url})
doc = loader.load()
````

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

### Reproduction

```
from langchain.document_loaders import BSHTMLLoader

url = "https://www.example.com"

loader = BSHTMLLoader(url)
doc = loader.load()
```

### Expected behavior

It has respond html data of url. I believe BSHTMLLoader won't work with url and only work files(.html files).
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ pydantic.error_wrappers.ValidationError: 1 validation error for Document"
Labels: name: area: doc loader, name: area: vector store, name: auto:bug

### System Info

Traceback:

 docsearch.similarity_search(
  File "/usr/local/lib/python3.9/site-packages/langchain/vectorstores/pinecone.py", line 162, in similarity_search
    docs_and_scores = self.similarity_search_with_score(
  File "/usr/local/lib/python3.9/site-packages/langchain/vectorstores/pinecone.py", line 136, in similarity_search_with_score
    docs.append((Document(page_content=text, metadata=metadata), score))
  File "/usr/local/lib/python3.9/site-packages/langchain/load/serializable.py", line 74, in __init__
    super().__init__(**kwargs)
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Document"
page_content  str type expected (type=type_error.str)


### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

langchain pinecone similarity_search_with_score
 docs.append((Document(page_content=text, metadata=metadata), score))
seem to raise error when page_content is not an string type 
while  when we wrote the document to the pinecone using pdf loader 
maybe the loader produce something unexpected.
it should be a bug

### Expected behavior

No erro raised
Add new parameter forced_decoder_ids to OpenAIWhisperParserLocal + small bug fix
Labels: name: lgtm, name: area: doc loader, name: auto:improvement

  - Description: new parameter forced_decoder_ids for OpenAIWhisperParserLocal to force input language, and enable optional translate mode. Usage example:
    processor = WhisperProcessor.from_pretrained("openai/whisper-medium")  
    forced_decoder_ids = processor.get_decoder_prompt_ids(language="french", task="transcribe") 
    #forced_decoder_ids = processor.get_decoder_prompt_ids(language="french", task="translate") 
    loader = GenericLoader(YoutubeAudioLoader(urls, save_dir), OpenAIWhisperParserLocal(lang_model="openai/whisper-medium",forced_decoder_ids=forced_decoder_ids))
  - Issue #8792
  - Tag maintainer: @rlancemartin, @eyurtsev


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.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Add option to directly set input language for OpenAIWhisperParserLocal
Labels: name: auto:improvement

### Feature request

Add option to directly set input language for OpenAIWhisperParserLocal (in case incorrect autodetection  (language="french", task = "transcribe") and optionally use translation mode of the whisper model (language="french", task = "translate")

### Motivation

I encountered situations where audio is split in chunks and therefore language autodetection was incorrect by OpenAIWhisperParserLocal

### Your contribution

I'll post PR.
Fix: RecursiveUrlLoader is not working (#8367)
Labels: name: lgtm, name: area: doc loader, name: auto:bug

Fixes #8367 

Before this fix: 
```python
from langchain.document_loaders import RecursiveUrlLoader
docs = RecursiveUrlLoader(url="https://docs.python.org/3/").load()
print(len(docs))
```
It returns 0 docs

After this fix:
```python
from langchain.document_loaders import RecursiveUrlLoader
docs = RecursiveUrlLoader(url="https://docs.python.org/3/").load()
print(len(docs))
```
It returns 23 docs now.



<!-- 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: AzureOpenAI connection with SQL Database
Labels: name: area: agent, name: auto:bug, name: auto:question

### Issue you'd like to raise.

Hello,

I want achive SQL Database Agent, by using that I want to retrive data from the database and execute queries.

So for that I have tried,

```
from langchain.agents import create_sql_agent
from langchain.agents.agent_toolkits import SQLDatabaseToolkit
from langchain.sql_database import SQLDatabase
from langchain.llms.openai import AzureOpenAI
from langchain.agents.agent_types import AgentType

db = SQLDatabase.from_uri("mysql://user:pwd@localhost/db_name")
toolkit = SQLDatabaseToolkit(db=db, llm=AzureOpenAI(deployment_name="ABCD",model_name="text-davinci-003",temperature=0))

agent_executor = create_sql_agent(
    llm=AzureOpenAI(deployment_name="ABCD",model_name="text-davinci-003",temperature=0),
    toolkit=toolkit,
    verbose=True,
    agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
)

agent_executor.run("Describe the XYZ table")
```

But into above code facing problem is that "**openai.error.InvalidRequestError: Invalid URL (POST /v1/openai/deployments/trailadvisor/completions)**". Same thing I can run using the OpenAI but getting error in AzureOpenAI.

Am i doing the correct approach, or any other way that using AzureOpenAI deployment we can achive the requirement?

### Suggestion:

_No response_
"n" hyperparmeter doesn't work in ChatOpenAI
Labels: name: area: embeddings, name: auto:bug

### System Info

Name: langchain
Version: 0.0.250

Python=3.11.4


### Who can help?

@agola @hwchase17 

### Information

- [ ] The official example notebooks/scripts
- [X] 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

```
llm = ChatOpenAI(
        model="gpt-4",
        temperature=0.0,
        top_p=1.0,
        n=20,
        max_tokens=30
    )

results = llm(chat_prompt.format_prompt(
        inputs_description=vars["inputs_description"],
        task_description=vars["task_description"],
        criteria=vars["criteria"],
        criteria_description=vars["criteria_description"],
        eval_steps=vars["eval_steps"],
        input=vars["input"],
        input_type=vars["input_type"],
        output=vars["output"],
        output_type=vars["output_type"]
    ).to_messages())
```

### Expected behavior

I was expecting to get a response with 20 results, instead of just one since I set n=20. This is the behaviour when using Openai SDK.
Error while loading the Llama 2 70B chat model
Labels: name: area: embeddings, name: auto:bug

### System Info

Hi!

While using Llama cpp in LangChain, I am trying to load the "llama-2-70b-chat" model. The code I am using is:


n_gpu_layers = 40  # Change this value based on your model and your GPU VRAM pool.
n_batch = 512  # Should be between 1 and n_ctx, consider the amount of VRAM in your GPU.

callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
llm = LlamaCpp(
    model_path="/Users/taimoorarif/Downloads/llama-2-70b-chat.ggmlv3.q4_0.bin",
    n_gpu_layers=n_gpu_layers,
    n_batch=n_batch,
    callback_manager=callback_manager,
    verbose=True,
    n_ctx=2048
)

I am getting an error which I am attaching below. The same code works perfectly fine for the 13b model. Moreover, for the 65B model, the model keeps processing the prompt and does not return anything. Any help would be appreciated. Thanks!

<img width="1018" alt="Screenshot 2023-08-05 at 3 59 05 AM" src="https://github.com/langchain-ai/langchain/assets/56273879/db0fb151-3bdb-4518-b6f7-d58dca2af261">


### 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

.

### Expected behavior

.
#8786 Fixed: Callback handler disconnect in between
Labels: name: lgtm, name: auto:bug

Fixes for  #8786 @agola11 

  - Description: The flow of callback is breaking till the last chain, as callbacks are missed in between chain along nested path. This will help get full trace and correlate parent child relationship in all nested chains.

  - Issue: the issue #8786 
  - Dependencies: NA
  - Tag maintainer: @agola11 
  - Twitter handle: Agarwal_Ankur
RetrievalQA.from_chain_type: callbacks are not called for all nested chains
Labels: name: area: agent, name: auto:bug

### System Info

langchain: 0.0.252
python: 3.10.12



@agola11

### Who can help?

@agola11 please take a look, 

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

### Reproduction

1. Create a callback handler LogHandler for on_chain_start, on_chain_start, on_chat_model_start and log run_id, parent_run_id in each of them
2. Create a retrival chain and add this LogHandler
3. Add this LogHandler to llm as well 
4. When running the chain, one of nested chain is not logged in between, because callbacks are not passed to that chain

### Expected behavior

All the nested chains should have callbacks defined.
Update links on QA Use Case docs
Labels: name: auto:documentation

  - Description: 2 links were not working on Question Answering Use Cases documentation page. Hence, changed them to nearest useful links, 
  - Issue: NA,
  - Dependencies: NA,
  - Tag maintainer: @baskaryan,
  - Twitter handle: NA

<!-- 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
 -->
Add missing test for retrievers self_query
Labels: name: auto:improvement

# What
- Add missing test for retrievers self_query
- Add missing import validation

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: Add missing test for retrievers self_query
  - Issue: None
  - Dependencies: None
  - Tag maintainer: @rlancemartin, @eyurtsev
  - Twitter handle: @MlopsJ
  
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
 -->
NLTK  alternatives option
Labels: name: auto:enhancement

### Feature request

if possible to provide NLTK tokenizer alternative options? such as spaCy, openNLP...

### Motivation

NLTK issues:
```
 Resource averaged_perceptron_tagger not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('averaged_perceptron_tagger')
  
  For more information see: https://www.nltk.org/data.html

```

### Your contribution

https://python.langchain.com/docs/modules/data_connection/document_transformers/text_splitters/split_by_token#spacy

NLTK issues: https://stackoverflow.com/questions/49546253/attributeerror-module-nltk-has-no-attribute-download
inconsistent agent answer
Labels: name: area: agent, name: auto:bug

### System Info

i'm using newest langchain, python 3
so i try agent but got inconsistent answer, this is the output
![WhatsApp Image 2023-08-04 at 19 31 26](https://github.com/langchain-ai/langchain/assets/35356597/5a594e1c-55c8-40e4-a584-9433e429784b)
the true answer is "Jalan lori tidak termasuk jalan umum". i try using retrieval with prompt without agent and got true answer too. so sometimes agent has inconsistent answer. how to prevent this?



### Who can help?

_No response_

### Information

- [x] 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
- [X] Agents / Agent Executors
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

i put example code below
my Agent Prompt
![WhatsApp Image 2023-08-04 at 19 31 26 (1)](https://github.com/langchain-ai/langchain/assets/35356597/91f5dde2-7fd6-4ea3-a9d9-3ddd3cd5c9a7)

How To Call my Agent
```
agent_executor = initialize_agent(
        tools, 
        llm, 
        agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, 
        verbose=True,
        handle_parsing_errors=True,
        return_direct=True,
        agent_kwargs={
            'prefix':constant.PREFIX,
            'format_instructions':constant.FORMAT_INSTRUCTIONS,
            'suffix':constant.SUFFIX
        }
    )
    result = agent_executor.run(question)
    return result
```


### Expected behavior

got true answer same with the documents
Add integration to collect feedback on documentation
Labels: name: documentation, name: auto:enhancement

## Background

LangChain has become widely popular and adopted by developers. The documentation of any developer product plays a crucial role in the developer experience. Collecting feedback on the LangChain documentation will further improve the developer experience and help the community.

## Description

[Docsly](https://docsly.dev) is a feedback tool crafted for developer documentation. It lets the readers leave contextual feedback  (comments) on the documentation website and helps the maintainer by showing the feedback exactly where the user left it.

The feedback feature (like/dislike) gives a general sense of whether users are finding a particular page helpful.

  - Dependencies: Installed `@docsly/react` in the Docusaurus project
  - Tag maintainer: @baskaryan
  - Twitter handle: [sun_anshuman](https://twitter.com/sun_anshuman)

### Example project for preview

[Clerk](https://clerk.com/docs), [Tigris](https://www.tigrisdata.com/docs/), and [Dyte](https://docs.dyte.io) are using docsly in production already.

### Todo

- [ ] Sign up on [docsly.dev ](https://docsly.dev/dashboard)for a fresh account for maintainers

### Cost implications

[Docsly](https://docsly.dev) is free to use for open-source projects.
Just install Langchain and getting Import error from typing extensions
Labels: name: auto:bug

### System Info


Latest versions of langchain at the current time. 

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

Literally just pip installed lang-chain and getting the error: ImportError: cannot import name 'dataclass_transform' from 'typing_extensions'. I tried upgrading pydantic and typing_extensions which only make the problem worse. 


### Expected behavior

No import errors.
Extend the StreamlitChatMessageHistory docs with a fuller example and…
Labels: name: area: memory, name: auto:documentation

Add more details to the [notebook for StreamlitChatMessageHistory](https://python.langchain.com/docs/integrations/memory/streamlit_chat_message_history), including a link to a [running example app](https://langchain-st-memory.streamlit.app/).

Original PR: https://github.com/langchain-ai/langchain/pull/8497
rfc: runnable locals
Labels: name: auto:enhancement

add concept of locals, which is state to pass around in RunnableSequence, and specific runnable for read/write to locals. cc @jacoblee93 @nfcampos 

![Screenshot 2023-08-04 at 1 18 36 PM](https://github.com/langchain-ai/langchain/assets/22008038/1e9608cb-e4c1-4df1-956e-e5f640929b56)