delayedkarma/langchain-issues huggingface dataset:
jw metaphor v3
Labels: name: auto:improvement

- add metaphor search new api fields
- update example notebook
- clear output
- add new field, fix ipynb formatting

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

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
 -->
Update pgembedding.ipynb
Labels: name: lgtm, name: auto:documentation

Correct links to the pg_embedding repository and the Neon 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!

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
 -->
Integrate Rockset as a document loader
Labels: name: area: doc loader, name: auto:enhancement

<!-- 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!

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
 -->

Integrate [Rockset](https://rockset.com/docs/) as a document loader.

Issue: None
Dependencies: Nothing new (rockset's dependency was already added [here](https://github.com/hwchase17/langchain/pull/6216))
Tag maintainer: @rlancemartin

I have added a test for the integration and an example notebook showing its use. I ran `make lint` and everything looks good.
Update base chain type hints
Labels: name: auto:improvement

Addresses #7578. `run()` can return dictionaries, Pydantic objects or strings, so the type hints should reflect that. See the chain from `create_structured_output_chain` for an example of a non-string return type from `run()`.

I've updated the BaseLLMChain return type hint from `str` to `Any`. Although, the differences between `run()` and `__call__()` seem less clear now. 

CC: @baskaryan
Feature: Add ``from_embeddings`` class method to Chroma
Labels: 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!

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
 -->

# Description
This PR adds a ``from_embeddings`` class method to the ``Chroma`` vectorstore. This can be handy, if one wants to replace vectorstores that have that method (e.g. ``FAISS``) with ``Chroma``. Additionally, this is useful if one already has pre-computed embeddings and does not want to re-compute them.

The implementation is very simple and just gets the Chroma collection, splits the ``text_embeddings`` into ``texts`` and ``embeddings`` and then calls the ``add_texts`` method. Within ``add_texts`` we need to add a check that only if ``embeddings is None`` we embed the documents to avoid re-embedding.

@rlancemartin and @eyurtsev would be happy to get some feedback!

## Usecase
To use the self-query feature from langchain for my [scholarGPT](https://twitter.com/L_Salewski/status/1673084085474820096) academic chatbot I moved from ``FAISS`` to ``Chroma`` and I wanted a drop-in replacement. 

## Notes
- This feature does not introduce any new dependencies.
- My Twitter handle is [@L_Salewski](https://twitter.com/L_Salewski)
Fixed handling of absolute URLs in `RecursiveUrlLoader`
Labels: name: auto:bug

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description:
  - 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!

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
 -->

## Description
This PR addresses a bug in the RecursiveUrlLoader class where absolute URLs were being treated as relative URLs, causing malformed URLs to be produced. The fix involves using the urljoin function from the urllib.parse module to correctly handle both absolute and relative URLs.

@rlancemartin @eyurtsev
some notebook updates
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!

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: Can't use NotebookLoader to load ipynb files generically
Labels: name: auto:question

### Issue you'd like to raise.

Hi!
I have some problem with the `NotebookLoader` loader:
I'm trying to access my repo and detect all of the `.ipynb` files, and then load them to the LLM Chain I'm implementing using LangChain. The repo can be viewed [here](https://github.com/eilone/RepoReader/tree/eilon-br) 


```
    for ext in extensions:
        glob_pattern = f'**/*.{ext}'
        try:
            loader = None
            if ext == 'ipynb':
                loader = **NotebookLoader**(str(repo_path), include_outputs=True, max_output_length=20,
                                        remove_newline=True,  loader_kwargs={"content_type": "text/plain"})
```

Yet I don't know how to pass the `glob_pattern` to this loader, resulting in going to the base dir and not being able to look for the notebook files...

```
[Errno 21] Is a directory: 'my_dir'
```

Can you please help me figure it out? Considering I don't want to pass each `ipynb` file-path individually?

### Suggestion:

_No response_
Nuclia understanding api
Labels: name: auto:enhancement

# Description

This pull request allows to use the [Nuclia](https://docs.nuclia.dev/docs/about/nuclia) file processing capabilities in LangChain.

It provides:

- a tool allowing to push files to the Nuclia processing queue, and to pull results fron this queue.
- a document loader wrapping the tool, to ease the usage and to comply with the LangChain practices.

(both comes with an example notebook + unit tests)

That's mostly about extracting text and metadata from any kind of file (document or media). It does *not* provide the other services offered by the Nuclia API.

I will do other PRs to cover:
- entity recognition
- vector storage and searching in the NucliaDB vector database
(unless you prefer a single PR providing all the different services altogether, let me know)

# Dependencies

It requires an up-to-date version of `protobuf` (which is already a dependency of LangChain) and the `nucliadb-protos` package, in order to parse Protobuf messages retrieved from the Nuclia API.

@rlancemartin, @eyurtsev,  @hinthornw, please review it when you have a moment :)
And thank you for your work on LangChain, that's great!

Note: our Twitter handler is `@NucliaAI`
ArxivRetriever should return a metadata Sources field
Labels: name: auto:improvement

### System Info

langchain=0.0.230


### Who can help?

@eyurtsev 

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

### Reproduction

Looks like in `ArxivAPIWrapper` perhaps could change:
```
            if self.load_all_available_meta:
                extra_metadata = {
                    "entry_id": result.entry_id,
                    "published_first_time": str(result.published.date()),
                    "comment": result.comment,
                    "journal_ref": result.journal_ref,
                    "doi": result.doi,
                    "primary_category": result.primary_category,
                    "categories": result.categories,
                    "links": [link.href for link in result.links],
                }
            else:
                extra_metadata = {}
            metadata = {
                "Published": str(result.updated.date()),
                "Title": result.title,
                "Authors": ", ".join(a.name for a in result.authors),
                "Summary": result.summary,
                **extra_metadata,
            }
```
To include a "Sources" tag, perhaps with the direct link(s) to the paper

### Expected behavior

Metadata containing a "Sources" tag
Uncap pydantic dependency (allow pydantic 2.x)
Labels: name: auto:improvement

### Feature request

Hello, and thanks for this fantastic library!!

In pyproject.toml, the Pydantic library [is pinned to version 1.x](https://github.com/hwchase17/langchain/blob/master/pyproject.toml#L15) 

I'd like to unpin that dependency by changing `^1` to `>=1`.

### Motivation

Pydantic 2.0.2 is apparently production-ready, and it has a feature we badly need but our dependency on langchain prevents us from using it.

Deep background on dependency pinning here: https://iscinumpy.dev/post/bound-version-constraints/


### Your contribution

Two tiny commits like [this](https://github.com/rec/langchain/commits/master) and [this one in langsmith](https://github.com/rec/langchainplus-sdk/commits/main) are all that is needed.

I can test the langchain commit and submit it for review; I can send the langsmith one for review, but not sure how to test it.
DOC: ContextualCompressionRetriever - is it possible to retain sources
Labels: name: auto:enhancement, name: auto:documentation

### Issue with current documentation:

I'd like to pass in documents to a chain created from `load_qa_with_sources_chain` that are the results of `compression_retriever.get_relevant_documents(user_query)`.  It's not clear from the documentation whether this is possible, and, if so, how to accomplish it.

### Idea or request for content:

An example demonstrating this if it is currently possible.

If it is not currently possible, a feature request to make it so
RetrievalQA.from_chain_type not working fine for chain_type="refine" when using ChatVertexAI
Labels: name: auto:bug

### System Info

Version: 0.0.201


```
llm = ChatVertexAI(temperature=0)

qa_chain_mr = RetrievalQA.from_chain_type(
    llm, retriever=vectordb.as_retriever(), chain_type="refine"
)
result = qa_chain_mr({"query": question})
result["result"]
```

Error:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[42], line 6
      1 llm = ChatVertexAI(temperature=0)
      3 qa_chain_mr = RetrievalQA.from_chain_type(
      4     llm, retriever=vectordb.as_retriever(), chain_type="refine"
      5 )
----> 6 result = qa_chain_mr({"query": question})
      7 result["result"]

File [~/.conda/envs/genai/lib/python3.10/site-packages/langchain/chains/base.py:149](https://vscode-remote+ssh-002dremote-002blevi-002dpers-002dpp-002dnb-002dshajebi.vscode-resource.vscode-cdn.net/home/jupyter/code/misc/LLMs/courses/LangChain-Chat-with-Your-Data/~/.conda/envs/genai/lib/python3.10/site-packages/langchain/chains/base.py:149), in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, include_run_info)
    147 except (KeyboardInterrupt, Exception) as e:
    148     run_manager.on_chain_error(e)
--> 149     raise e
    150 run_manager.on_chain_end(outputs)
    151 final_outputs: Dict[str, Any] = self.prep_outputs(
    152     inputs, outputs, return_only_outputs
    153 )

File [~/.conda/envs/genai/lib/python3.10/site-packages/langchain/chains/base.py:143](https://vscode-remote+ssh-002dremote-002blevi-002dpers-002dpp-002dnb-002dshajebi.vscode-resource.vscode-cdn.net/home/jupyter/code/misc/LLMs/courses/LangChain-Chat-with-Your-Data/~/.conda/envs/genai/lib/python3.10/site-packages/langchain/chains/base.py:143), in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, include_run_info)
    137 run_manager = callback_manager.on_chain_start(
    138     dumpd(self),
    139     inputs,
    140 )
    141 try:
...
--> 126     chat._history.append((pair.question.content, pair.answer.content))
    127 response = chat.send_message(question.content, **self._default_params)
    128 text = self._enforce_stop_words(response.text, stop)

AttributeError: 'ChatSession' object has no attribute '_history'



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

```
llm = ChatVertexAI(temperature=0)

qa_chain_mr = RetrievalQA.from_chain_type(
    llm, retriever=vectordb.as_retriever(), chain_type="refine"
)
result = qa_chain_mr({"query": question})
result["result"]
```

### Expected behavior

To work fine. It works for ChatOpanAI().
Issue: Tool many tools, and the embedding can not filter all tools i need, is there any good ideas?
Labels: name: auto:question, name: auto:improvement

### Issue you'd like to raise.

I have a case,that there are many tools to be used,  so i can't put them all in prompt,  is there any good ideas, retrievers, to filtrate the tools?

and i have try the embedding, vector_store ,but it can not  filtrate all tools i need, and it can't filtrate the tools which are Indirectly dependent to the user query

is there any better retrievers?

### Suggestion:

_No response_
Could not parse LLM output: `AI: Alright, if you have any other questions in the future, feel free to ask. Enjoy your day!`
Labels: name: auto:bug

### Issue you'd like to raise.

File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
File "/home/ajay/MeetsMeta/scripts/streamlit.py", line 72, in <module>
    msg = {"role": "assistant", "content": agent_chain.run(prompt)}
File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/langchain/chains/base.py", line 315, in run
    return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/langchain/chains/base.py", line 181, in __call__
    raise e
File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/langchain/chains/base.py", line 175, in __call__
    self._call(inputs, run_manager=run_manager)
File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/langchain/agents/agent.py", line 987, in _call
    next_step_output = self._take_next_step(
File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/langchain/agents/agent.py", line 803, in _take_next_step
    raise e
File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/langchain/agents/agent.py", line 792, in _take_next_step
    output = self.agent.plan(
File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/langchain/agents/agent.py", line 444, in plan
    return self.output_parser.parse(full_output)
File "/home/ajay/anaconda3/envs/andy/lib/python3.9/site-packages/langchain/agents/mrkl/output_parser.py", line 42, in parse
    raise OutputParserException(

I am getting Error when i am using multiple tools . Can you please let me know how to figure out this error 

### Suggestion:

_No response_
Set OpenAIEmbeddings parameters, not explicitly specified
Labels: name: auto:improvement

### Issue you'd like to raise.

- Azure/OpenAI API has a user (Optional) parameter.
  - Create chat completion
    - https://platform.openai.com/docs/api-reference/chat/create#chat/create-user
    - https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#completions
  - Create embeddings
    - https://platform.openai.com/docs/api-reference/embeddings/create#embeddings/create-user
    - https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#embeddings

- LangChain ChatOpenAI has no user parameter, but does have a model_kwargs parameter.
  - https://github.com/hwchase17/langchain/blob/master/langchain/chat_models/openai.py#L170

- LangChain OpenAIEmbeddings has no user and model_kwargs parameter.
  - https://github.com/hwchase17/langchain/blob/master/langchain/embeddings/openai.py#L121

### Suggestion:

Doesn't LangChain OpenAIEmbeddings require a model_kwargs parameter?
OpenAI recommends Sending end-user IDs in Safety best practices.
- https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids
Fix SQLAlchemy LLM cache clear
Labels: name: lgtm, name: auto:bug

Fixes #7652 

Description: 
This is a fix for clearing the cache for SQL Alchemy based LLM caches. 

The langchain.llm_cache.clear() did not take effect for SQLite cache. 
Reason: it didn't commit the deletion database change.

See SQLAlchemy documentation for proper usage:
https://docs.sqlalchemy.org/en/20/orm/session_basics.html#opening-and-closing-a-session
https://docs.sqlalchemy.org/en/20/orm/session_basics.html#deleting

@hwchase17 @baskaryan
SQLite LLM cache clear does not take effect
Labels: name: auto:bug

### System Info

Langchain version: 0.0.231
Python version: 3.10.11

Bug:

There is an issue when clearing LLM cache for SQL Alchemy based caches.
langchain.llm_cache.clear() does not clear the cache for SQLite LLM cache. 

Reason: it doesn't commit the deletion database change. The deletion doesn't take effect.

### Who can help?

@hwchase17 @ag

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

- Configure SQLite LLM Cache
- Call an LLM via langchain
- The SQLite database get's populated with an entry
- call langchain.llm_cache.clear()

- Actual Behaviour: Notice that the entry is still in SQLite


### Expected behavior

- Expected Behaviour: The cache database table should be empty