delayedkarma/langchain-issues huggingface dataset:
Update passthrough.py
Labels: name: auto:nit, name: area: langserve, name: size:XS


<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/

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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
langchain: Fix for issue #14631 - .devcontainer doesnt build
Labels: name: auto:bug, name: area: langserve, name: size:XS

  - **Description:** Fix for issue #14631
 - **Issue:** This fixes [Issue #14631](https://github.com/langchain-ai/langchain/issues/14631)
  - **Twitter handle:** [@consultchrisq ](https://twitter.com/consultchrisq?lang=en)
langchain: Fix for issue #14631 - .devcontainer doesnt build
Labels: name: auto:bug, name: area: langserve, name: size:S

  - **Description:** Fix for issue #14631
 - **Issue:** This fixes [Issue #14631](https://github.com/langchain-ai/langchain/issues/14631)
  - **Twitter handle:** [@consultchrisq ](https://twitter.com/consultchrisq?lang=en)
community: Enhance Github error prompt
Labels: name: auto:improvement, name: area: langserve, name: size:XS

  - **Description:** The Github error prompt is confused because of JWT enctrypt to somebody not familiar with Github connection method. This PR is to add some useful error prompt to help users troubleshooting.
  - **Issue:** https://github.com/langchain-ai/langchain/issues/14550#issuecomment-1867445049
  - **Dependencies:** None,
  - **Twitter handle:** None
DOC: langchain LCEL - transfer of information between generations
Labels: name: auto:question, name: area: lcel

### Issue with current documentation:

I do not understand how chains are built with the transfer of information between generations. here is an example of the code in the langchain [documentation](https://python.langchain.com/docs/expression_language/why):
```
from langchain_core.runnables import RunnablePassthrough

prompt = ChatPromptTemplate.from_template(
    "Tell me a short joke about {topic}"
)

output_parser = StrOutputParser()
model = llm
chain = (
    {"topic": RunnablePassthrough()} 
    | prompt
    | model
    | output_parser
)

chain.invoke("ice cream")
```
here in the promo, please write a joke about ice cream, based on this example, my question will be: "how to make the chain continue further and, for example, analyze this joke (that is, work further with what was generated)."
There was an idea to just create a second promt and add it to the chain:
```
prompt = ChatPromptTemplate.from_template(
    "Tell me a short joke about {topic}"
)
prompt1 = ChatPromptTemplate.from_template(
    "What was the joke about?"
)

output_parser = StrOutputParser()
model = llm
chain = (
    {"topic": RunnablePassthrough()} 
    | prompt
    | model
    | output_parser
    | prompt1
    | model
    | output_parser
)
```
But it won't work that way, because for some reason the model doesn't know the context...
![image](https://github.com/langchain-ai/langchain/assets/146547175/75083537-c75b-46a3-a3fd-5c0884bca9bf)

### Idea or request for content:

_No response_
Fixed small gramm mistakes
Labels: name: area: memory, name: auto:documentation, name: size:XS

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/

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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
python 3.10 `|` union syntax compatibility
Labels: name: area: doc loader, name: auto:question

### Issue you'd like to raise.

Based on the documentation and RFC standards referenced in the links:

- https://peps.python.org/pep-0604/
- https://www.blog.pythonlibrary.org/2021/09/11/python-3-10-simplifies-unions-in-type-annotations/

it's evident that the introduction of using | instead of 'union' for type annotations is a feature that was introduced in Python 3.10.
However, I've observed that in our project's pyproject.toml and ci.yaml files, the Python version is specified as python = ">=3.8.1,<4.0".

This leads me to question whether LangChain will face issues with type checking or even running in the specified Python 3.8 environment, given that it doesn't support the | syntax for unions.

If there are any considerations or plans, such as updating the pyproject.toml and ci.yaml to make LangChain compatible with a minimum of Python 3.10, or if it's appropriate for me to submit a PR to address the use of the | operator in type annotations within LangChain, I'd appreciate your input and guidance.

### Suggestion:

Upgrade the python version, or fix and remove | syntax, I would be happy to do this, please let me know your decision

@hwchase17
community: allow additional kwargs in MlflowEmbeddings for compatibility with Cohere API
Labels: name: area: embeddings, name: auto:improvement, name: size:S

<!-- Thank you for contributing to LangChain!
If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->

  - **Description:** add support for kwargs in`MlflowEmbeddings` `embed_document()` and `embed_query()` so that all the arguments required by Cohere API (and others?) can be passed down to the server.
  - **Issue:** #15234 
  - **Dependencies:** MLflow with MLflow Deployments (`pip install mlflow[genai]`)

**Tests**
Now this code [adapted from the docs](https://python.langchain.com/docs/integrations/providers/mlflow#embeddings-example) for the Cohere API works locally.

```python
"""
Setup
-----
export COHERE_API_KEY=...
mlflow deployments start-server --config-path examples/deployments/cohere/config.yaml

Run
---
python /path/to/this/file.py
"""
embeddings = MlflowCohereEmbeddings(target_uri="http://127.0.0.1:5000", endpoint="embeddings")
print(embeddings.embed_query("hello")[:3])
print(embeddings.embed_documents(["hello", "world"])[0][:3])
```

Output
```
[0.060455322, 0.028793335, -0.025848389]
[0.031707764, 0.021057129, -0.009361267]
```
WIP: Use HB Inference Client in llms package
Labels: name: auto:improvement, name: area: models, name: size:L

Fixes https://github.com/langchain-ai/langchain/issues/10483

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/

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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
DOC: langchain plus OpenAI-compatible URL API equally error
Labels: name: auto:question, name: area: models

### Issue with current documentation:

hello everyone! Is it possible to use the OpenAI-compatible URL API from text-generation-webui with langchain? the langchain [documentation](https://python.langchain.com/docs/integrations/llms/textgen) says about localhost, but I don't have access to it, I tried to insert the link into model_url, the error appeared both in google colab and in the terminal.
![photo_2023-12-28_04-55-13](https://github.com/langchain-ai/langchain/assets/146547175/82d3aa41-0e8b-4caa-a723-64735e3d2e0f)
![photo_2023-12-28_05-04-24](https://github.com/langchain-ai/langchain/assets/146547175/d85037d4-81f2-45d2-86d4-335b7f86cd3c)


### Idea or request for content:

_No response_
Issue: validation errors for ConversationalRetrievalChain
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

I am receiving this error 2 validation errors for ConversationalRetrievalChain
qa_template
  extra fields not permitted (type=value_error.extra)
question_generator_chain_options
  extra fields not permitted (type=value_error.extra) , for the following code :
     ```
 retriever = vector_store.as_retriever()

        sales_persona_prompt = PromptTemplate.from_template(SALES_PERSONA_PROMPT)
        condense_prompt = PromptTemplate.from_template(CONDENSE_PROMPT)

        question_generator_chain_options = {
            "llm": non_streaming_model,
            "template": condense_prompt,
        }

        chain = ConversationalRetrievalChain.from_llm(
            streaming_model,
            retriever,
            qa_template=sales_persona_prompt,
            question_generator_chain_options=question_generator_chain_options,
            return_source_documents=False,
        )
```

### Suggestion:

_No response_
Executing Chain with HuggingFace Models using wrapper
Labels: name: auto:bug, name: area: models

### System Info

Langchain version:  0.0.340
Python version: 3.11.0


### Who can help?

@hwchase17 
@agola11 

### Information

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

### Related Components

- [X] 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

I am trying to use the HuggingFace Hub Wrapper to create a chat model instance and use the model in a chain. However these seems to be some library discrepancies between various base files.

Below is the code that works: 

from langchain_community.llms import HuggingFaceHub
from langchain_core.messages import HumanMessage, SystemMessage
from langchain_community.chat_models.huggingface import ChatHuggingFace
from langchain.prompts import PromptTemplate, ChatPromptTemplate

llm = HuggingFaceHub(
    repo_id="HuggingFaceH4/zephyr-7b-beta",
    task="text-generation",
    model_kwargs={
        "max_new_tokens": 512,
        "top_k": 30,
        "temperature": 0.1,
        "repetition_penalty": 1.03,
    },
)

chat_model = ChatHuggingFace(llm=llm)

messages = [
    SystemMessage(content="You're a zoologist who is able to answer questions about various animals. You are tasked with answering the following question provided"),
    HumanMessage(content="What is the average lifespan of an Elephant?"),
]


res = chat_model.invoke(messages)
print(res.content)

I want to modify this to allow the prompt to be more dynamic and potentially include a chain of prompts. Here is my modification:

prompt = ChatPromptTemplate.from_messages(
    [
        SystemMessage(content="You're a zoologist who is able to answer questions about various animals. You are tasked with answering the following question provided"),
        HumanMessage(content="What is the average lifespan of an {animal}?"),
    ]
)

chain1 = prompt| chat_model 
chain1.invoke({"animal": "giraffe"})

I get the following error: NotImplementedError: Unsupported message type: <class 'langchain_core.messages.system.SystemMessage'> - this is because in the chat.py file the import statement for the messages is the following: from langchain.schema.messages import (
    AIMessage,
    AnyMessage,
    BaseMessage,
    ChatMessage,
    HumanMessage,
    SystemMessage,
    get_buffer_string,
). However the updated version I found in documentation states to use langchain_core.messages.

Even if I update the import statement to be the old version, I run into the following error: TypeError: 'ChatPromptValue' object is not subscriptable.



### Expected behavior

I should be able to execute the chain and receive the same output from the non-dynamic verison of the code - res.content output.
HuggingFace Chat Wrapper - issue with HuggingFaceHub
Labels: name: auto:bug, name: area: models

### Issue with current documentation:

I am currently following the document to use a hugigngface LLM as a chat model: https://python.langchain.com/docs/integrations/chat/huggingface

I have setup my Huggingface API and am using Option 3 (HuggingFaceHub) to instantiate an LLM. 

After running this line: chat_model._to_chat_prompt(messages) 

I get the following error: ValueError: last message must be a HumanMessage

I am running the code the exactly the same as the documentation, including using the HuggingFaceH4/zephyr-7b-beta model.

Any help in resolving this issue is much appreciated.

### Idea or request for content:

_No response_
Add .pick and .assign methods to Runnable
Labels: name: auto:improvement, name: area: lcel, name: size:L

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/

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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Issue: issue with pdfplumber
Labels: name: area: doc loader, name: auto:bug

### Issue you'd like to raise.

from langchain.document_loaders.parsers.pdf import PDFPlumberParser

def generate_embeddings(config: dict = None, urls = None, file_path = None, persist_directory=None):
    if file_path:
        parser = PDFPlumberParser()
        data = parser.load(file_path)
        processed_data = parser.process(data)
        print(processed_data,"processed_data is-----------------llllllllllllllllllllllllllllll")
#below is the error i'm getting
  data = parser.load(file_path)
AttributeError: 'PDFPlumberParser' object has no attribute 'load'

### Suggestion:

_No response_
Implement nicer runnable seq constructor, Propagate name through Runn…
Labels: name: auto:improvement, name: area: models, name: size:L

…ableBinding

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/

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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
core + community: Added ANN override to VectorStore [new feature]
Labels: name: area: vector store, name: auto:enhancement, name: size:L

Addresses: https://github.com/langchain-ai/langchain/issues/15221
(Most of the context of this PR exists on that issue.)

Adds this method to VectorStore:
```
    @abstractmethod
    def similarity_search_with_override(
        self, query: str, search_override: str, k: int = 4, **kwargs: Any
    ) -> List[Document]:
        """Return docs most similar to query."""
```

Updates _get_relevant_documents() on VectorStore to include search_override, like this:
```
        elif self.search_type == "similarity_with_override":
            docs = self.vectorstore.similarity_search_with_override(query, self.search_override, **self.search_kwargs)
```
Also adds the corresponding method to AstraDB (as an example):

```
    def similarity_search_with_override(
            self,
            query: str,
            search_override: str,
            k: int = 4,
            filter: Optional[Dict[str, str]] = None,
            **kwargs: Any,
    ) -> List[Document]:
        embedding_vector = self.embedding.embed_query(search_override)
        return self.similarity_search_by_vector(
            embedding_vector,
            k,
            filter=filter,
        )
```

When I try to run the tests from root, I get:

```
% poetry install --with test
Installing dependencies from lock file

No dependencies to install or update

% make test
make: *** No rule to make target `test'.  Stop.
```
When I try to run the tests from core, I get:
```
% make test
poetry run pytest tests/unit_tests/
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --snapshot-warn-unused
  inifile: /Users/devin.bost/proj/repos/langchain/libs/core/pyproject.toml
  rootdir: /Users/devin.bost/proj/repos/langchain/libs/core

make: *** [test] Error 4
```

I tried the steps in the [guide](https://python.langchain.com/docs/contributing/testing), but I'm still not getting tests to run. Some guidance would be much appreciated. 

I'd also appreciate some guidance on how I might test this new functionality in LCEL.
support gemini on vertexai
Labels: name: auto:bug, name: area: models

### Feature request

As per documentation there's a package for Gemini support but this only works for Gemini API and doesn't work with Vertexai.
https://python.langchain.com/docs/integrations/platforms/google
However in the vertexai docs gemini is mentioned (for some reason gemini ultra ? ) even though when tried with geimini-pro (gemini-ultra is not out yet unless Langchain folks have connections at Google :) ) it's throwing an error indicating that model doesn't exist. 
https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm#multimodality
 Unknown model publishers/google/models/gemini-pro-vision; {'gs://google-cloud-aiplatform/schema/predict/instance/chat_generation_1.0.0.yaml': <class 'vertexai.language_models.ChatModel'>} (type=value_error)

### Motivation

gemini has been out for a while and seemingly should be supported by langchain as they already made a whole package for it.

### Your contribution

I would be willing to make a pr but I'm not even sure what's the issue since the docs supposedly mention that it should be already supported.
Enable manual override of vector search query for controlled RAG
Labels: name: area: vector store, name: auto:improvement

### Feature request

I need a mechanism to allow more control over the ANN search performed for a given RAG chain. Consider the initial example:
```
retriever = vectorstore.as_retriever()
template = """You're a helpful assistant who is great at code generation. Don't give me any explanation or summary. I'll give you some examples that may or may not be relevant, and I want you to use the examples to write code that solves the provided problem. Return only the code that solves the problem.

PROBLEM:
{problem}

EXAMPLES:
{context}

ANSWER: 
"""

prompt = ChatPromptTemplate.from_template(template)

model = ChatOpenAI()
chain = (
    {"context": retriever, "problem": RunnablePassthrough()}
    | prompt
    | model
    | StrOutputParser()
)
chain.invoke("Generate an example Python method that uses LCEL to write a CQL query")
```
This approach assumes that the question will be used for creating the embedding. However, consider something like this:

```
retriever = vectorstore.as_retriever(ann_query="LCEL, AstraDB, CQL")
```
In this situation, when the retriever is invoked to embed the query, instead of performing vector search on the embedding of the very wordy

> "Generate an example Python method that uses LCEL to write a CQL query" 

I want vector search to perform ANN on:

> "LCEL, AstraDB, CQL"

so that I have a greater likelihood of having the right docs stuffed into the prompt for the LLM to solve the problem, which was:
> Generate an example Python method that uses LCEL to write a CQL query




### Motivation

RAG results can be poor when the human input is very wordy or contains more info (for the LLM) than we want the vector store to search for. We need a mechanism to allow separation between the vector search query and the LLM query. 

### Your contribution

I will create a PR.