delayedkarma/langchain-issues huggingface dataset:
Remove lucene characters and fix RRF normalization for neo4j vector
Labels: name: area: vector store, name: auto:improvement, name: size:L

Introduces two changes for neo4j vector store:

* Fixes Hybrid search normalization (before we didn't normalize vector similarity)
* Remove special lucene characters from full text index queries (fixes https://github.com/langchain-ai/langchain/issues/14232)


cc @jexp
impossible to connect to PowerBI Datasets even after providing all the information
Labels: name: area: agent, name: auto:bug, name: area: models

### System Info

Langchain version = 0.0.344
Python version = 3.11.5



### Who can help?

@hwchase17 @agola11

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

### Reproduction

here is my code. i am unable to connect to powerbi dataset.

from langchain.agents.agent_toolkits import PowerBIToolkit
from langchain.utilities.powerbi import PowerBIDataset
from azure.identity import ClientSecretCredential
from azure.core.credentials import TokenCredential

# Create an instance of the language model (llm)

toolkit = PowerBIToolkit(
    powerbi=PowerBIDataset(
        dataset_id="",
        table_names=['WinShareTable'],
        credential=ClientSecretCredential(
            client_id=",
            client_secret='',
            tenant_id=""
        )
    ),
    llm=llm
)

Either getting field "credential" not yet prepared so type is still a ForwardRef, you might need to call PowerBIDataset.update_forward_refs() error or

Tokencredentials error

### Expected behavior

Should allow to connect to PowerBi datasets
updated streaming chunk on_llm_new_token in vertexai
Labels: name: auto:improvement, name: area: models, name: size:XS

  - **Description:** We have made changes to fix the issue in streaming chunks in vertexAI, 
  - **Issue:** Python app is getting crashed when trying to stream response in vertexAI,
  - **Dependencies:** No dependency,
  - Please help with the review @baskaryan @lkuligin @hwchase17 ,
  - **Twitter handle:** https://twitter.com/shrinitg
Stable release 11.4.0 of azure.search.documents.models not compatible with latest langchain version -> class Vector gone
Labels: name: area: vector store, name: auto:bug

### Discussed in https://github.com/langchain-ai/langchain/discussions/13245

<div type='discussions-op-text'>

<sup>Originally posted by **yallapragada** November 12, 2023</sup>
I am testing a simple RAG implementation with Azure Cognitive Search.

I am seeing a "cannot import name 'Vector' from azure.search.documents.models" error when I invoke my chain. Origin of my error is line 434 in lanchain/vectorstores/azuresearch.py (from azure.search.documents.models import Vector)

this is the relevant code snippet, I get the import error when I execute rag_chain.invoke(question)

from langchain.schema.runnable import RunnablePassthrough
from langchain.prompts import ChatPromptTemplate
from langchain.chat_models.azure_openai import AzureChatOpenAI

question = "my question.."

-- vector_store is initialized using AzureSearch(), not including that snippet here --
retriever = vector_store.as_retriever()

template = ''' 
Answer the question based on the following context: 
{context}

Question: {question} 
'''

prompt = ChatPromptTemplate.from_template(template=template)

llm = AzureChatOpenAI( deployment_name='MY_DEPLOYMENT_NAME', model_name='MY_MODEL', openai_api_base=MY_AZURE_OPENAI_ENDPOINT, openai_api_key=MY_AZURE_OPENAI_KEY, openai_api_version='2023-05-15', openai_api_type='azure' )

rag_chain = {'context' : retriever, 'question' : RunnablePassthrough} | prompt | llm 
rag_chain.invoke(question)

--------------

my package versions

langchain==0.0.331
azure-search-documents==11.4.0b11
azure-core==1.29.5
openai==0.28.1</div>
DOC: Please add stronger contrast or labeling between notebook input and output blocks
Labels: name: area: doc loader, name: auto:improvement, name: auto:documentation

### Issue with current documentation:

Page: https://python.langchain.com/docs/modules/memory/

In dark mode, there is very little contrast between inputs and outputs. Especially for pages imported from Jupyter notebooks, it can be really confusing figuring out which code blocks are safe to test in a `.py` function and which code blocks are intended for use in Jupyter. 

Adding in explicit contrast or labeling between input and output blocks would be helpful.

![image](https://github.com/langchain-ai/langchain/assets/113563866/ba628424-fcc5-4496-8053-128254e068a7)




### Idea or request for content:

_No response_
Support Weaviate client v4
Labels: name: auto:enhancement

### Feature request

Weaviate has released a beta version of their [python client v4](https://weaviate.io/developers/weaviate/client-libraries/python) which seems to be more robust compared to v3. It follows a different structure but allows for more versatility and better error handling when it comes to queries. I think it would be great to add support in langchain for the new client.

### Motivation

I was using the v3 client (without langchain) to batch import data into Weaviate. It worked, but it was slower than I expected and also resulted in errors that I was not able to manage easily. The new v4 client supports their new [gRPC API](https://weaviate.io/developers/weaviate/api/grpc) which outperforms the traditional REST API that v3 is using. 

### Your contribution

I will start creating some custom functions using Weaviate's new client to test its reliability. If I don't encounter any serious errors, I'll try to find the time and create a PR to add support for it in langchain. I think that support for both v3 and v4 should exist, at least until v4 becomes stable.
Update cohere provider docs
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:M

Preview since github wont preview .mdx : 

<img width="1401" alt="image" src="https://github.com/langchain-ai/langchain/assets/144115527/9e8ba3d9-24ff-4584-9da3-2c9b60e7e624">
Add the collection_description parameter to Milvus
Labels: name: lgtm, name: area: vector store, name: auto:improvement, name: size:XS

Because Milvus' collection_name doesn't support UFT8 characters in other languages, I want the `collection_descriotion`.


<!-- 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.
 -->
When the self-deployed chatglm3 model is invoked based on the openai API specification and create_sql_agent is used to query the first three rows of the data table, the output format is reported to be incorrect. But there are no formatting errors with qwen. How do I fix chatglm3

### System Info

langchain=0.0.348
openai=0.28.1

### 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

model= "chatglm3"

llm = ChatOpenAI(model_name=model,openai_api_key=api_key,openai_api_base=api_url)

db = SQLDatabase.from_uri("mysql+pymysql://.....")

toolkit = SQLDatabaseToolkit(db=db, llm=llm,use_query_checker=True)

agent_executor = create_sql_agent( llm=llm,toolkit=toolkit, verbose=True,agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,handle_parsing_errors=False
)

content=agent_executor.run("Look at the structure of the table ads_pm_empl_count first, then give the first three rows of data")

print(content)
<img width="875" alt="联想截图_20231211165355" src="https://github.com/langchain-ai/langchain/assets/73893296/8fcee38e-0235-44c5-8454-6fd368351488">


### Expected behavior

How do I fix this output format problem
1

### System Info

langchain=0.0.348
python=3.9
openai=0.28.1

### 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

![Uploading 联想截图_20231211165355.png…]()

model= "chatglm3"

#llm = OpenAI(model_name=model,openai_api_key=api_key,openai_api_base=api_url)
llm = ChatOpenAI(model_name=model,openai_api_key=api_key,openai_api_base=api_url)

db = SQLDatabase.from_uri("mysql+pymysql://。。。。。")

toolkit = SQLDatabaseToolkit(db=db, llm=llm,use_query_checker=True)

#memory = ConversationBufferMemory(memory_key ="chat_history ")
agent_executor = create_sql_agent(
    llm=llm,
    toolkit=toolkit,
    verbose=True,
    agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    handle_parsing_errors=False
)
# content=agent_executor.output_schema.schema()
content=agent_executor.run("Look at the structure of the table ads_pm_empl_count first, then give the first three rows of data")
print(content)

### Expected behavior

How do I fix this output format problem
StructuredChatAgent would go wrong when the input contain some code such as protobuf.
Labels: name: area: agent, name: auto:bug

### System Info

LangChain: 0.0.311
Python: 3.11
OS: macOS 11.6


### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Thought: The user is asking for help implementing CRUD operations for a specific table in a MySQL database using the Go language. This is a programming task so I will use the programmer_agent tool to help with this. 

Action:
```
{
  "action": "programmer_agent",
  "action_input": {
    "task": {
      "title": "Implement CRUD operations for limited_relationships_config table in MySQL using Go",
      "description": "Write functions for adding, updating, deleting, and retrieving limited relationships configurations in a MySQL database using Go. The operations will be performed on the `limited_relationships_config` table.",
      "type": "code"
    }
  }
}
```

### Expected behavior

Thought: The user is asking for help implementing CRUD operations for a specific table in a MySQL database using the Go language. This is a programming task so I will use the programmer_agent tool to help with this. 

Action:
```
{
  "action": "programmer_agent",
  "action_input": {
    "task": "Implement CRUD operations for limited_relationships_config table in MySQL using Go"
  }
}
```
how to use gpt2 with custom promt?
Labels: name: auto:question, name: auto:enhancement, name: area: models

### Feature request

i want to use gpt2 for text genration & want to control the llm

### Motivation

gpt2 is smaller version & its is best for next-word prediction

### Your contribution

want to use below code for loading gpt2 model

```
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = 'gpt2'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)


prompt = 'want to do more '

config1 = {
    'num_beams': 3,  # Number of beams for beam search
    'do_sample': True,  # Whether to do sampling or not
    'temperature': 0.6  # The value used to module the next token probabilities
}

config2 = {
    'penalty_alpha': 0.6,  # The penalty alpha for contrastive search
    'top_k': 6  # The number of highest probability vocabulary tokens to keep for top-k-filtering
}

inputs = tokenizer(prompt, return_tensors='pt')
output = model.generate(**inputs, **config1)  # Here, you should choose config1 or config2
result = tokenizer.decode(output[0], skip_special_tokens=True)

print("------->>>>.",result)



```
Is 'collection_name' required when initializing 'PGVector'?
Labels: name: area: vector store, name: auto:question

### System Info
```langchain = "^0.0.345"```
I want to embed and store multiple documents in PGVector and RAG query the DB.
When saving documents, I am specifying a collection_name for each document.
(For example, if I have 3 documents, I have 3 collection_names)
Is it possible to separate collections like this?
Also, is the collection_name required when connecting to PGVector?

### 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
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

db1 = PGVector.from_documents(
    embedding=embed,
    documents=documents,
    collection_name="my doc 1",
    connection_string=CONNECTION_STRING
)

db2 = PGVector.from_documents(
    embedding=embed,
    documents=documents,
    collection_name="my doc 2",
    connection_string=CONNECTION_STRING
)

# after, To query the DB where the document is stored.

db_connection = PGVector(
    embedding=embed,
    documents=documents,
    collection_name="my doc 2",         # I don't want to specify a collection_name.
    connection_string=CONNECTION_STRING
)

### Expected behavior

I want to connect to the PGVector only the first time, and then use that session to query the collection_name (1 document in my case).
Breaking of pattern in `from_document` function
Labels: name: area: vector store, name: auto:nit, name: integration: chroma

https://github.com/langchain-ai/langchain/blob/c0f4b95aa9961724ab4569049b4c3bc12ebbacfc/libs/langchain/langchain/vectorstores/chroma.py#L742

This function breaks the pattern of how the `embedding_function` is referenced by just calling it `embedding`.
Small issue but definitely makes it a bit confusing to navigate without diving into the code/docs. 

Happy to PR it in if worthwhile
Qdrant retriever with existing data leads to pydantic.error_wrappers.ValidationError: 1 validation error for Document page_content   none is not an allowed value (type=type_error.none.not_allowed)
Labels: name: area: vector store, name: auto:bug, name: area: models

### System Info

Python 3.10.2
langchain version 0.0.339
WSL 

### Who can help?

@hwchase17 
@agola11 

### Information

- [x ] 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
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction
I am using Qdrant on docker with information preloaded. However im unable to get it to search

```
MODEL_TO_USE = 'all-mpnet-base-v2'
client = QdrantClient(QDRANT_ENDPOINT, port=6333, timeout=120)
embeddings = HuggingFaceEmbeddings(model_name=MODEL_TO_USE)
qdrant = Qdrant(client, collection_name, embeddings)
conversation_chain = ConversationalRetrievalChain.from_llm(
        llm=llm,
        retriever=qdrant.as_retriever(search_kwargs={'k': 5}),
        get_chat_history=lambda h : h,
        memory=memory
    )

# im using a streamlit frontend
import streamlit as st
st.session_state.conversation = conversation_chain 

# during chat
result = st.session_state.conversation({
                "question": user_query, 
                "chat_history": st.session_state['chat_history']})
```

Result would then lead to the error. 

### Expected behavior

Chat is supposed to work instead of getting

```
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Document
page_content
  none is not an allowed value (type=type_error.none.not_allowed)
```
Customize how messages are formatted in MessagesPlaceholder
Labels: name: auto:improvement, name: area: models

### Feature request

Customize how messages are formatted in MessagesPlaceholder
Currently, history messages are always format to: 
'''
Human: ...
AI: ...
'''

Popular chat fine-tunings use all sorts of different formats.  

Example:

'''

user
...


assistant
...

'''

There's currently no way to change how history messages are prompted.





### Motivation

I wanted to use langchain to make chatbots.  Currently that use case is not well supported.

### Your contribution

Here's how I got it to work.  I have to manually parse the history in a previous step.

<img width="683" alt="image" src="https://github.com/langchain-ai/langchain/assets/2053475/15fe31e2-cc23-47f2-9d0c-d5670f22768a">
RunnableWithMessageHistory streaming bug
Labels: name: auto:bug, name: integration: redis

### System Info

0.0.348, linux , python 3.11

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

### Reproduction

```
 chain_with_history = RunnableWithMessageHistory(
        chain,
        lambda session_id: RedisChatMessageHistory(session_id, url=REDIS_URL, ttl=600),
        input_messages_key="inputs",
        history_messages_key="history",
    )
    return chain_with_history

  response = customer_support_invoke().stream(
          {"inputs": userChats.inputs, "profile": userChats.profile},
          config={"configurable": {"session_id": "123"}},
      )
      for s in response:
          print(s.content, end="", flush=True)
```

if I streaming twice , it will raise an error "ValueError: Got unexpected message type: AIMessageChunk
"

### Expected behavior

streaming correctly
Help me run this
Labels: name: area: agent, name: auto:question, name: auto:documentation, name: area: models

### Issue with current documentation:

import requests
from typing import Optional
from langchain.tools import StructuredTool

``` python
def post_message(url: str, body: dict, parameters: Optional[dict]=None) -> str:
    """Sends a POST request to the given url with the given body and parameters."""
    result = requests.post(url, json=body, params=parameters)
    return result.text


custom_tool = StructuredTool.from_function(post_message)

from langchain.agents import initialize_agent, AgentType
from langchain.chat_models import ChatOpenAI

tools = [custom_tool] # Add any tools here
llm = ChatOpenAI(temperature=0) # or any other LLM
agent_chain = initialize_agent(tools, llm, agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
```

How to run this and get the results if I have an api endpoint

### Idea or request for content:

_No response_
Move runnable context to beta
Labels: name: lgtm, name: auto:refactor, name: size:M

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