delayedkarma/langchain-issues huggingface dataset:
Issue: not getting output as per prompt,what is neccessary changes i need to do?
Labels: name: auto:question, name: area: models

### Issue you'd like to raise.

I am not getting output as per prompt, what is neccessary modification or changes i need to do.
def chat_langchain(new_project_qa, query, not_uuid):
    check = query.lower()
    relevant_document = result['source_documents']
    user_experience_inst = UserExperience.objects.get(not_uuid=not_uuid)
    custom_prompt_template = f"""You are a Chatbot answering questions. Use the following pieces of context to answer the question at the end. If you don't know the answer, say that you don't know, don't try to make up an answer.
    {relevant_document}
    Question: {check}
    Helpful Answer:"""
    CUSTOMPROMPT = PromptTemplate(
        template=custom_prompt_template, input_variables=["context", "question"]
    )
    print(CUSTOMPROMPT,"------------------")
    new_project_qa.combine_documents_chain.llm_chain.prompt = CUSTOMPROMPT
    result = new_project_qa(query)
    
    if relevant_document:
        source = relevant_document[0].metadata.get('source', '')
        # Check if the file extension is ".pdf"
        file_extension = os.path.splitext(source)[1]
        if file_extension.lower() == ".pdf":
            source = os.path.basename(source)

        # Retrieve the UserExperience instance using the provided not_uuid
        user_experience_inst = UserExperience.objects.get(not_uuid=not_uuid)
        bot_ending = user_experience_inst.bot_ending_msg if user_experience_inst.bot_ending_msg is not None else ""

        # Create the list_json dictionary
        if bot_ending != '':
            list_json = {
                'bot_message': result['result'] + '\n\n' + str(bot_ending),
                "citation": source
            }
        else:
            list_json = {
                'bot_message': result['result'] + str(bot_ending),
                "citation": source
            }
    else:
        # Handle the case when relevant_document is empty
        list_json = {
            'bot_message': result['result'],
            'citation': ''
        }

    # Return the list_json dictionary
    return list_json

### Suggestion:

_No response_
fixed wrong link in documentation
Labels: name: area: doc loader, 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.
 -->

See #14998
DOC: Document PAGE NOT FOUND
Labels: name: area: doc loader, name: auto:documentation

### Issue with current documentation:

404 page: https://python.langchain.com/docs/contributing/integration

referenced by: https://python.langchain.com/docs/contributing/

![image](https://github.com/langchain-ai/langchain/assets/33118163/360d1a67-0c2c-471a-aba1-2eef21bc8f9a)
 

### Idea or request for content:

_No response_
community: fix for surrealdb client 0.3.2 update + store and retrieve metadata
Labels: name: area: vector store, name: auto:improvement, name: size:S

Surrealdb client changes from 0.3.1 to 0.3.2 broke the surrealdb vectore integration.
This PR updates the code to work with the updated client. The change is backwards compatible with previous versions of surrealdb client.
Also expanded the vector store implementation to store and retrieve metadata that's included with the document object.
Add implementation of '_create_chat_result()' method for MiniMax's current implementation
Labels: name: auto:improvement, name: area: models

### Feature request

Add the implementation of '_create_chat_result()' method for MiniMax's current implementation to allow it being accepted as one of the chat models

### Motivation

Currently MiniMax's chat functionality does not work properly with Langchain, as described in this issue: 

https://github.com/langchain-ai/langchain/issues/14796

The investigation to this bug suggests a missing implementation of method '_create_chat_result()'. With a proper implementation of this method, the `_generate` method will be able to return `ChatResult` objects instead of unaccepted `str`.

### Your contribution

I am currently investigating on how to implement it myself, and I am happy to provide any support, including discussion, testing, etc.
Update multi-modal template README.md
Labels: name: area: doc loader, name: auto:documentation, name: integration: chroma, name: size:S

<!-- 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.
 -->
community[minor] langchain[patch]: convert class tool to openai function
Labels: name: area: agent, name: auto:bug, name: size:L

Covert tools to a JSON format description for Openai. Previously, the function `format_tool_to_openai_function` does not return the correct parameter name when given a tool that subclassing the BaseTool:

```python
import os
from langchain.agents import load_tools
from langchain.tools.render import format_tool_to_openai_function
os.environ['SERPER_API_KEY'] = '1' * 40
tools = load_tools(["google-serper"])
format_tool_to_openai_function(tools[0])['parameters']
# {'properties': {'__arg1': {'title': '__arg1', 'type': 'string'}}, 'required': ['__arg1'], 'type': 'object'}
```

This patch is trying to fix it. The correct output should be `{'properties': {'query': {'title': 'Query', 'type': 'string'}}, 'required': ['query'], 'type': 'object'}`
Issue: Adding function calling to ConversationalRetrievalChain 
Labels: name: auto:question, name: area: models

### Issue you'd like to raise.

I am having a problem adding function calling to a chain of type ConversationalRetrievalChain. I need help finding a solution.
Here is my code, which creates a ConversationalRetrievalChain to retrieve local knowledge and generate chat history information in a summary format. It works fine. However, when I try to add a call to weather_function, I don't know where to add it. I have browsed most of the documentation and couldn't find a solution. Can anyone help me? Thank you!
```python
documents = TextLoader("./file/text.txt").load()
text_splitter = CharacterTextSplitter(chunk_size=300, chunk_overlap=50)
docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings(openai_api_key=APIKEY, openai_api_base=OPENAI_API_BASE)
db = FAISS.from_documents(docs, embeddings)
retriever = db.as_retriever()

Template = """You are a good man and happy to chat with everyone:
{context}
history chat information in summary:
{chat_history}
Question: {question}
"""

prompt = PromptTemplate(
    input_variables=["context", "chat_history", "question"], template=Template
)
output_parser = StrOutputParser()

model = ChatOpenAI(
    model_name=DEFAULT_MODEL,
    openai_api_key=APIKEY,
    openai_api_base=OPENAI_API_BASE,
    temperature=0.9,
)

memory = ConversationSummaryMemory(
    llm=model, memory_key="chat_history", return_messages=True
)

conversation_chain = ConversationalRetrievalChain.from_llm(
    llm=model,
    retriever=db.as_retriever(),
    memory=memory,
    combine_docs_chain_kwargs={'prompt': prompt},
    verbose=False,
)
```

function calling : weather_function

```python
class WeatherSearch(BaseModel):
    """Call this with an airport code to get the weather at that airport"""
    airport_code: str = Field(description="airport code to get weather for")

weather_function = convert_pydantic_to_openai_function(WeatherSearch)

```

### Suggestion:

_No response_
Issue: Obtain the content output by AsyncCallbackHandler on_llm_new_token and send it to the front end to find that the newline character is missing.
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

I used AsyncCallbackHandler for callback. When I pushed the content to the front end through on_llm_new_token, I found that the markdown code block was missing a newline character, which caused the front end to be unable to render the markdown format normally. However, when I retrieved the final response and returned the overall answer content, I found that this newline character existed.
<img width="155" alt="image" src="https://github.com/langchain-ai/langchain/assets/14210962/214581c0-f427-4e83-b06e-f1ded11efe20">

I want to ask for help, how should I solve the problem I am currently facing?


### Suggestion:

_No response_
community[patch]: JaguarHttpClient conditional import
Labels: name: lgtm, name: area: vector store, name: auto:improvement, name: size:S

  - **Description:** Fixed jaguar.py to import JaguarHttpClient with try and catch
  - **Issue:** the issue # Unable to use the JaguarHttpClient at run time
  - **Dependencies:** It requires "pip install -U jaguardb-http-client" 
  - **Twitter handle:** workbot
Implement streaming for xml output parser
Labels: name: lgtm, name: area: doc loader, name: auto:improvement, name: size:M

<!-- 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.
 -->
Fixed jaguar.py to import JaguarHttpClient with try and catch
Labels: name: area: vector store, name: auto:improvement, name: size:S

  - **Description:** Fixed jaguar.py to import JaguarHttpClient with try and catch
  - **Issue:** the issue # Unable to use the JaguarHttpClient at run time
  - **Dependencies:** It requires "pip install -U jaguardb-http-client" 
  - **Twitter handle:** workbot
community[patch]:  Fix typo in class Docstring (#14982)
Labels: name: lgtm, name: auto:nit, name: area: models, name: size:XS




  - **Description:** Fix typo in class Docstring to replace AZURE_OPENAI_API_ENDPOINT by AZURE_OPENAI_ENDPOINT
  - **Issue:** the issue #14901 
  - **Dependencies:** NA
  - **Twitter handle:**
Implement streaming for all list output parsers
Labels: name: lgtm, name: auto:improvement, 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.
 -->
ChatOllama stream method raises warn_deprecated NotImplementedError
Labels: name: auto:bug, name: area: models

### System Info

langchain version: v0.0.352
python version: 3.11

Hi there! After that PR https://github.com/langchain-ai/langchain/pull/14713 was merged, I started getting errors in stream() method:
```
File .../lib/python3.11/site-packages/langchain_core/_api/deprecation.py:295, in warn_deprecated(since, message, name, alternative, pending, obj_type, addendum, removal)
    293 if not removal:
    294     removal = f"in {removal}" if removal else "within ?? minor releases"
--> 295     raise NotImplementedError(
    296         f"Need to determine which default deprecation schedule to use. "
    297         f"{removal}"
    298     )
    299 else:
    300     removal = f"in {removal}"

NotImplementedError: Need to determine which default deprecation schedule to use. within ?? minor releases
```

I guess this decorator must have a `pending=True` argument.

### Who can help?

@hwchase17 @agola11 

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

### Reproduction

```
from langchain.chat_models import ChatOllama
llm = ChatOllama(
    model="openchat:7b-v3.5-1210-q4_K_M",
)
for chunk in llm.stream("Where were the Olympics held?"):
    print(chunk, end="", flush=True)
```

### Expected behavior

successful streaming output from llm
API Ref navbar update
Labels: name: area: doc loader, name: auto:improvement, name: template, name: size:XS, name: partner

Now the navbar items are too long and are not visible.
![image](https://github.com/langchain-ai/langchain/assets/2256422/8fb51f75-0ae2-43ec-a225-1dc69f16ce72)

I'm trying to cut the top-level part of the namespace in items.
Issue: Requesting Feedback on Integrating Gretel for Synthetic Tabular Generation
Labels: name: auto:improvement, name: area: models

### Issue you'd like to raise.

Proposing updates to the SyntheticDataGenerator interface to create a cleaner foundation for building community integrations for synthetic tabular models like [Gretel](https://gretel.ai/tabular-llm) [[docs](https://docs.gretel.ai/reference/tabular-llm)]

### Suggestion:

# Existing Interface

The current `SyntheticDataGenerator` interface requires:

```python
def generate(
  subject: str,
  runs: int,
  extra: Optional[str] = None   
) -> List[str]
```

Where:

* `subject`: Subject the synthetic data is about
* `runs`: Number of times to generate the data
* `extra`: Extra instructions for steering

## Proposed Update
I propose changing this to the following:

```python
def generate(
  prompt: str,
  num_records: int,
  optional_dataset: Optional[str, Path, DataFrame]  
) -> List[str]
```

## Where:

* `prompt`: User prompt to create synthetic data
* `num_records`: Number of rows to generate
* `optional_dataset`: Dataset to edit/augment

I believe this creates a cleaner interface for synthetic tabular data flows, by combining the `subject` and `extra` parameters into a single field, and allowing the user to clearly specify the number of results they want `num_records`, vs the number of `runs` of the LLM which could generate more than one record each time. The `optional_dataset` arg lets the user prompt the model with a dataset to edit or augment with new synthetic data. 

# Requesting Feedback
I would appreciate any thoughts on this proposed update, and happy to open a PR! Before I get started, please let me know:

* If you see any issues with changing the interface
* If an alternative integration approach would be better
* Any other API details to consider

https://python.langchain.com/docs/use_cases/data_generation

My goal is have an intuitive integration for Gretel and future synthetic data models
community: add args_schema to GmailSendMessage
Labels: name: lgtm, name: auto:improvement, name: size:S

  - **Description:** `tools.gmail.send_message` implements a `SendMessageSchema` that is not used anywhere. `GmailSendMessage` also does not have an `args_schema` attribute (this led to issues when invoking the tool with an OpenAI functions agent, at least for me). Here we add the missing attribute and a minimal test for the tool.
  - **Issue:** N/A
  - **Dependencies:** N/A
  - **Twitter handle:** N/A
WIP Runnable Chain
Labels: name: auto:improvement, name: area: models, 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.
 -->
Vectara summarization
Labels: name: area: vector store, name: auto:bug, name: size:XXL

Description: Adding Summarization to Vectara, to reflect it provides not only vector-store type functionality but also can return a summary.
Also added:
MMR capability (in the Vectara platform side)

Updated templates

Updated documentation and IPYNB examples

Tag maintainer: @baskaryan
Twitter handle: @ofermend
Optionally limit the Current Buffer loaded in ConversationSummaryBufferMemory
Labels: name: area: memory, name: auto:improvement, name: size:XS


  - **Description:** 
      -   `ConversationSummaryBufferMemory` does not have a way to limit the loaded messages/buffer from `ChatHistory`. While it summarizes/prunes the previous buffer when the buffer loaded from `ChatHistory` exceeds the token threshold but when `ConversationSummaryBufferMemory` loads the memory variables, it reloads all of messages which goes along with `moving_summary_buffer`. Their needs to be a way to OPTIONALLY limit the Window of current buffer loaded from ChatHistory which will go with the moving_summary_buffer in the final prompt otherwise the memory variables will just keep on increasing like simple `ConversationBufferMemory`.
  - **Issue:** #14822 
  - **Tag maintainer:** @baskaryan, @eyurtsev, @hwchase17.
core(minor): Allow explicit types for ChatMessageHistory adds
Labels: name: lgtm, name: auto:improvement, name: area: models, name: size:S

<!-- 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://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/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
## Description
Changes the behavior of `add_user_message` and `add_ai_message` to allow for messages of those types to be passed in. Currently, if you want to use the `add_user_message` or `add_ai_message` methods, you have to pass in a string. For `add_message` on `ChatMessageHistory`, however, you have to pass a `BaseMessage`. This behavior seems a bit inconsistent. Personally, I'd love to be able to be explicit that I want to `add_user_message` and pass in a `HumanMessage` without having to grab the `content` attribute. This PR allows `add_user_message` to accept `HumanMessage`s or `str`s and `add_ai_message` to accept `AIMessage`s or `str`s to add that functionality and ensure backwards compatibility.

## Issue
* None

## Dependencies
* None

## Tag maintainer
@hinthornw
@baskaryan 

## Note
`make test` results in `make: *** No rule to make target 'test'.  Stop.`