delayedkarma/langchain-issues huggingface dataset:
Add progress bar to GooglePalmEmbeddings
Labels: name: area: embeddings, name: auto:improvement

### Feature request

Add a progress bar to `GooglePalmEmbeddings.embed_documents()` function. [tqdm](https://github.com/tqdm/tqdm) would work just fine.

In my opinion, all embedders should have a progress bar.

### Motivation

When processing embeddings the user should have an idea of how much time is going to take to embed the data. While using GooglePalmEmbeddings, which are not the fastest, I couldn't see a progress bar and that was frustrating me because I had no idea if it was even accessing GooglePalm correctly or how much time it was going to take.

### Your contribution

```python
from __future__ import annotations

import logging
from typing import Any, Callable, Dict, List, Optional
from tqdm import tqdm

from langchain_core.pydantic_v1 import BaseModel, root_validator
from langchain_core.schema.embeddings import Embeddings
from tenacity import (
    before_sleep_log,
    retry,
    retry_if_exception_type,
    stop_after_attempt,
    wait_exponential,
)

from langchain.utils import get_from_dict_or_env

logger = logging.getLogger(__name__)

...

class GooglePalmEmbeddings(BaseModel, Embeddings):
    """Google's PaLM Embeddings APIs."""

    client: Any
    google_api_key: Optional[str]
    model_name: str = "models/embedding-gecko-001"
    """Model name to use."""

    @root_validator()
    def validate_environment(cls, values: Dict) -> Dict:
        """Validate api key, python package exists."""
        google_api_key = get_from_dict_or_env(
            values, "google_api_key", "GOOGLE_API_KEY"
        )
        try:
            import google.generativeai as genai

            genai.configure(api_key=google_api_key)
        except ImportError:
            raise ImportError("Could not import google.generativeai python package.")

        values["client"] = genai

        return values

    def embed_documents(self, texts: List[str]) -> List[List[float]]:
        return [self.embed_query(text) for text in tqdm(texts)]

    def embed_query(self, text: str) -> List[float]:
        """Embed query text."""
        embedding = embed_with_retry(self, self.model_name, text)
        return embedding["embedding"]
```
TypeError in Jira Wrapper When Parsing Empty Ticket Information
Labels: name: area: agent, name: area: doc loader, name: auto:bug, name: auto:improvement

### System Info

When using the Jira wrapper in LangChain to parse data from Jira tickets, the application encounters a TypeError if the ticket information is empty. This issue occurs specifically when the priority field of a ticket is not set, leading to a 'NoneType' object is not subscriptable error.

### Environment Details
LangChain version: [specify version]
Jira Wrapper version: [specify version]
Python version: 3.10
Operating System: [specify OS]

### Error Logs/Stack Traces
```
Traceback (most recent call last):
  ...
  File "/path/to/langchain/tools/jira/tool.py", line 53, in _run
    return self.api_wrapper.run(self.mode, instructions)
  ...
  File "/path/to/langchain/utilities/jira.py", line 72, in parse_issues
    priority = issue["fields"]["priority"]["name"]
TypeError: 'NoneType' object is not subscriptable


```

### Proposed Solution
I propose adding a check before parsing the ticket information. If the information is empty, return an empty string instead of 'None'. This modification successfully prevented the application from breaking in my tests.



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

### Reproduction

Steps to Reproduce
1- Execute a JQL query to fetch issues from a Jira project (e.g., project = SN and sprint = 'SN Sprint 8 + 9' and labels = 'fe').
2- Ensure that one of the fetched issues has an empty priority field.
3- Observe the application breaking with a TypeError.


### Expected behavior

The Jira wrapper should handle cases where ticket information, such as the priority field, is empty, without causing the application to break.
iMessage loader: implement message content extraction from attributed…
Labels: name: lgtm, name: needs test, name: area: doc loader, name: auto:improvement, name: size:M

  - **Description:** We are adding functionality to extract message content from the `attributedBody` field of the database, in case the content is not in the `text` field.
  - **Issue:** Closes #13326 and #10680 
  - **Dependencies:** None.
  - **Tag maintainer:** @eyurtsev, @hwchase17
remove openai api key from cookbook
Labels: name: auto:nit, name: size:XS

<!-- 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/langchain-ai/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.
 -->
Langchain.schema.runnable now missing from docs?
Labels: name: area: doc loader, name: auto:bug, name: auto:documentation

### System Info

Lanchain V: 0.339

### Who can help?

@hwchase17
@agola11 

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

### Reproduction

Following any example that uses a `langchain.schema.runnable` object. For example the "[Adding memory](https://python.langchain.com/docs/expression_language/cookbook/memory)" tutorial uses `RunnableLambda` and `RunnablePassthrough`.

- I no longer see `langchain.schema` in the API docs (see image below).
- Searching in the API docs also doesn't return any results when searching for `RunnablePassthrough`
<img width="363" alt="image" src="https://github.com/langchain-ai/langchain/assets/94480542/1b3ded17-c669-406d-8309-4f953f42c1f6">



### Expected behavior

- I don't see anything in the release notes about the `langchain.schema.runnables` being removed or relocated.
- I would have expected to see them in the API docs, or at least for them to still be returned when searching for them.
- Not sure if this is a documentation build issue and the modules are still importable as I have not updated my Langchain version yet. I was just using the docs as a reference and then starting getting 404 errors upon page refresh (e.g. [this](https://api.python.langchain.com/en/latest/schema/langchain.schema.messages.AIMessageChunk.html#langchain.schema.messages.AIMessageChunk) page for `AIMessageChunk` also no longer exists)
Configurable timeout for Ollama
Labels: name: area: agent, name: auto:enhancement, name: area: models

### Feature request

I have been using Ollama with Langchain for various tasks, but sometimes Ollama takes too long to respond depending on my local hardware. Is it possible to add a configurable timeout to the Ollama base class so that I can adjust this setting to avoid timeouts when using agents. Currently, I am getting a `httpx` timeout error when using Ollama. 

### Motivation

This feature will help to leverage local LLMs on a variety of hardware and let's experiment and build with local LLMs before using any third party APIs.

### Your contribution

If this is something that would be considered as a feature I am happy to add in a PR for this feature.
Add Databricks Vector Search as a new vector store
Labels: name: needs documentation, name: area: vector store, name: auto:enhancement, name: size:XXL

**Description:**
This PR adds Databricks Vector Search as a new vector store in LangChain.

- [x] Add `DatabricksVectorSearch` in `langchain/vectorstores/`
- [x] Unit tests
- [x] Add [`databricks-vectorsearch`](https://pypi.org/project/databricks-vectorsearch/) as a new optional dependency

We ran the following checks:
- `make format` passed ✅ 
- `make lint` failed but the failures were caused by other files
    + Files touched by this PR passed the linter ✅ 
- `make test` passed ✅ 
- `make coverage` failed but the failures were caused by other files. Tests added by or related to this PR all passed
    + langchain/vectorstores/databricks_vector_search.py test coverage 94% ✅ 
- `make spell_check` passed ✅ 

The example notebook and updates to the [provider's documentation page](https://github.com/langchain-ai/langchain/blob/master/docs/docs/integrations/providers/databricks.md) will be added later in a separate PR.

**Dependencies:**
Optional dependency: [`databricks-vectorsearch`](https://pypi.org/project/databricks-vectorsearch/)

<!-- 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/langchain-ai/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.
 -->
VoyageEmbeddings embed_general_texts
Labels: name: lgtm, name: area: embeddings, name: auto:improvement, name: size:S

  - **Description:** add method  embed_general_texts in VoyageEmebddings to support input_type
  - **Issue:** 
  - **Dependencies:** 
  - **Tag maintainer:** 
  - **Twitter handle:** @Voyage_AI_
feat: implement max marginal relevance for momento vector index
Labels: name: lgtm, name: area: vector store, name: auto:enhancement, name: size:L

**Description**

Implements `max_marginal_relevance_search` and `max_marginal_relevance_search_by_vector` for the Momento Vector Index vectorstore.

Additionally bumps the `momento` dependency in the lock file and adds logging to the implementation.

**Dependencies**

✅ updates `momento` dependency in lock file

**Tag maintainer**

@baskaryan 

**Twitter handle**

Please tag @momentohq for Momento Vector Index and @mloml for the contribution 🙇 

<!-- 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/langchain-ai/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: `pgvector` versions in `poetry.lock` are really old
Labels: name: auto:improvement

### Issue you'd like to raise.

The compatible versions for library `pgvector` listed in `poetry.lock` are really old: `"pgvector (>=0.1.6,<0.2.0)"`.

Are we able to update them to more recent ones?

### Suggestion:

Update versions to recent ones.
standardise metadata_field handling
Labels: name: area: vector store, name: auto:improvement, name: integration: elasticsearch, name: size:XS

 - **Description:** updated func max_marginal_relevance_search handling of metadata_field to be same as similarity_search_with_score. Allow flatten Opensearch mapping, where meta fields are not nested into any field.
 - **Issue:** #10524
 - **Maintainer:** @hwchase17, @baskaryan
ValueError: Redis failed to connect:
Labels: name: area: vector store, name: auto:bug, name: integration: redis

### System Info



# Create and load Redis with documents
vectorstore = RedisVectorStore.from_texts(
    texts=texts,
    metadatas=metadatas,
    embedding=embedding,
    index_name=index_name,
    redis_url=redis_url
)


The error i faced
Redis cannot be used as a vector database without RediSearch >=2.4Please head to https://redis.io/docs/stack/search/quick_start/to know more about installing the RediSearch module within Redis Stack.


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

.
Type Checking issue: CacheBackedEmbeddings.split_documents does not take a list of Documents
Labels: name: area: embeddings, name: area: doc loader, name: auto:bug

### System Info

I encountered an exception and a type checking notice in PyCharm while working with the following code snippet:

```
split_documents = text_splitter.split_documents(raw_documents)
cached_embedder.embed_documents(**split_documents**)
```

The type checking notice indicates that there is a mismatch in the expected type for a Document. According to the type definition, a Document should have properties such as page_content, type, and metadata. However, the function embed_documents seems to be designed to handle a list of strings instead of documents.

To align with the expected type for a Document, it is suggested to consider renaming the function from embed_documents to something like embed_strings or embed_texts. This change would accurately reflect the input type expected by the function and help avoid type-related issues during development.

Thank you for your attention to this matter.


```
    cached_embedder.embed_documents(split_documents)
...
  File "venv/lib/python3.11/site-packages/langchain/embeddings/cache.py", line 26, in _hash_string_to_uuid
    hash_value = hashlib.sha1(input_string.encode("utf-8")).hexdigest()
                              ^^^^^^^^^^^^^^^^^^^
AttributeError: 'Document' object has no attribute 'encode'
```





### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

loader = DirectoryLoader(
    "./data",
    glob="**/*.md",
    show_progress=True,
    use_multithreading=True,
    loader_cls=UnstructuredMarkdownLoader,
    loader_kwargs={"mode": "elements"},
)
raw_documents = loader.load()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
split_documents = text_splitter.split_documents(raw_documents)
cached_embedder.embed_documents(split_documents)

### Expected behavior

method should either accept a list of Documents or be renamed to embed_strings
Added support for partial_variables to BaseStringMessagePromptTemplate
Labels: name: auto:improvement, name: area: models, name: size:XS

**Description:** BaseStringMessagePromptTemplate.from_template was passingg the value of partial_variables into cls(...) via **kwargs, rather than passing it to PromptTemplate.from_template. 
**Tag maintainer:** @eyurtsev
**Twitter handle:** @josep_pon
Issue: Validation errors for ConversationalRetrievalChain (combine_docs_chain)
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

Hello, I am working on a conversational chatbot, here is a snippet of the code : 

```
general_system_template = ""You a chatbot...

---
{summaries}"""

general_user_template = "Question: {question}"

messages = [
    SystemMessagePromptTemplate.from_template(general_system_template),
    HumanMessagePromptTemplate.from_template(general_user_template)
]

qa_prompt = ChatPromptTemplate(
    messages=messages,
    input_variables=['question', 'summaries']
)

q = Queue()

llm_chat = ChatVertexAI(
    temperature=0,
    model_name="chat-bison",
    streaming=True,
    callbacks=[QueueCallback(q)],
    verbose=False
)

retriever = docsearch.as_retriever(
    search_type="similarity",
    search_kwargs={
        'k': 2,
        'filter': {'source': {'$in': sources}}
    }
)

llm_text = VertexAI(
    temperature=0,
    model_name="text-bison"
)

combine_docs_chain = load_qa_with_sources_chain(
    llm=llm_chat,
    chain_type="stuff",
    prompt=qa_prompt
)

condense_question_template = (
    """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.
    Chat History: {chat_history}
    Follow Up Input: {question}"""
)

condense_question_prompt = PromptTemplate.from_template(condense_question_template)
condense_chain = LLMChain(
    llm=llm_text,
    prompt=condense_question_prompt,
    verbose=True
)

chain = ConversationalRetrievalChain(
    combine_docs_chain_=combine_docs_chain,
    retriever=retriever,
    question_generator=condense_chain
)
```

When running the code I have the following error : 
```
pydantic.error_wrappers.ValidationError: 2 validation errors for ConversationalRetrievalChain
combine_docs_chain
  field required (type=value_error.missing)
combine_docs_chain_
  extra fields not permitted (type=value_error.extra)
```

How could I solve this ? Is there any way to have a more detailed error ? 

### Suggestion:

_No response_
Changed import of VertexAI
Labels: name: auto:bug, name: area: models

### System Info

python = "^3.8.10"
langchain = "^0.0.336"
google-cloud-aiplatform = "^1.36.3"

### Who can help?

@hwchase17 @agol

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

```python
from langchain.llms.vertexai import VertexAI

model = VertexAI(
            model_name="text-bison@001",
            temperature=0.2,
            max_output_tokens=1024,
            top_k=40,
            top_p=0.8
        )

model.client
# <vertexai.preview.language_models._PreviewTextGenerationModel at ...>

# it should be <vertexai.language_models.TextGenerationModel at ...>
```

### Expected behavior

Code reference: https://github.com/langchain-ai/langchain/blob/78a1f4b264fbdca263a4f8873b980eaadb8912a7/libs/langchain/langchain/llms/vertexai.py#L255C77-L255C77

The VertexAI API is now using vertexai.language_models.TextGenerationModel.
Instead, here we are still importing it from from vertexai.preview.language_models.
Structured tools not able to pass structured data to each other
Labels: name: area: agent, name: auto:bug

### System Info

LangChain 0.0.338
Python 3.11.5

### 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
- [X] Agents / Agent Executors
- [X] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

I was trying to combine multiple structured `Tool`s, one that produces a `List` of values and another that consumes it, but couldn't get it to work. I asked the LangChain support bot whether it was possible and it said yes and produced the following example. But it does not work :)
```python
from langchain.llms import OpenAI
from langchain.agents import initialize_agent, AgentType
from langchain.tools import BaseTool
from typing import List

# Define the first structured tool that returns a list of strings
class ListTool(BaseTool):
    name = "List Tool"
    description = "Generates a list of strings."

    def _run(self) -> List[str]:
        """Return a list of strings."""
        return ["apple", "banana", "cherry"]

tool1 = ListTool()

# Define the second structured tool that accepts a list of strings
class ProcessListTool(BaseTool):
    name = "Process List Tool"
    description = "Processes a list of strings."

    def _run(self, input_list: List[str]) -> str:
        """Process the list of strings."""
        # Perform the processing logic here
        processed_list = [item.upper() for item in input_list]
        return f"Processed list: {', '.join(processed_list)}"

tool2 = ProcessListTool()

llm = OpenAI(temperature=0)
agent_executor = initialize_agent(
    [tool1, tool2],
    llm,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
)

output = agent_executor.run("Process the list")
print(output)  # Output: 'Processed list: APPLE, BANANA, CHERRY'
```
Full output:
```
> Entering new AgentExecutor chain...
Action:

{
  "action": "Process List Tool",
  "action_input": {
    "input_list": {
      "title": "Input List",
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  }
}


Observation: Processed list: TITLE, TYPE, ITEMS
Thought: I have the processed list
Action:

{
  "action": "Final Answer",
  "action_input": "I have processed the list and it contains the following: TITLE, TYPE, ITEMS"
}



> Finished chain.
```

### Expected behavior

Expected output:
```
Processed list: APPLE, BANANA, CHERRY'
```