delayedkarma/langchain-issues huggingface dataset:
How to enable the memory mechanism when using create_pandas_dataframe_agent?
Labels: name: auto:question

### System Info

LangChain version : 0.0.216
Python version : 3.11.4
System: Windows

### Who can help?

@hwchase17 @eyu

### 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
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [X] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

I want to create a chatbot to retrieve information from my own csv file in response to a query using google PaLM model,
I want to improve the model's capabilities to perform specific data retrieval requests from the CSV. Here are a few examples of queries I would like the chatbot to handle:

a-Calculate the average of data from a specific column in the CSV file.
b-Return the top 10 scores based on a column of grades as a dataframe(the output of llm should be a json format).
c-Track the evolution of a product over time by analyzing a date column.

I have 2 questions : 

1-
what should I change in the following code to maintain contextual memory during the conversation(by changing question)?

```
from langchain.agents import create_pandas_dataframe_agent
from langchain.llms import VertexAI


ChatModel = VertexAI(
      model_name="text-bison@001",
      max_output_tokens=1024,
      temperature=0.1,
      top_p=0.8,
      top_k=40,
      verbose=True,
  )
        
pd_agent = create_pandas_dataframe_agent(ChatModel, 
                                                  df, 
                                                  verbose=True,
                                                  max_iterations=6,)

#prompt=...
#question=...
response = pd_agent.run(prompt + question)
```

2-

I'm looking for efficient ways to handle different types of tasks in my chatbot. Some questions require DataFrame responses, others need text responses, and some require both. Can I create specialized agents to handle specific tasks separately instead of specifying everything in one prompt? 


### Expected behavior

1-A chatbot that maintains contextual memory during the conversation using create_pandas_dataframe_agent
2-A suggestion of jobs separation to optimize the output of the chain
Pandas / CSV agent only show partial results from dataframe head
Labels: name: auto:bug

### System Info

Hi my data has 10 rows and I tried with both pandas and csv agent, in the observations I can see the agents are able to process all rows, but in the final answer both agents only output the first 5 rows from df.head(). I tried to set 'number_of_head_rows' to 10 but it doesn't work. Is there any way to make the agents to show results from all rows rather the the head?

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

from langchain.chat_models import AzureChatOpenAI
from langchain.agents import create_pandas_dataframe_agent
from langchain.agents.agent_types import AgentType

pd_agent = create_pandas_dataframe_agent(AzureChatOpenAI(deployment_name="gpt-4", model_kwargs={
    "api_key": openai.api_key,
    "api_base": openai.api_base,
    "api_type": openai.api_type,
    "api_version": openai.api_version
}, temperature=0.0), 
    df, 
    agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
    handle_parsing_errors=True)

### Expected behavior

should output the results from whole table
WhyLabsCallbackHandler  updates
Labels: name: lgtm, name: auto:improvement

Updates to the WhyLabsCallbackHandler and example notebook
- Update dependency to langkit 0.0.6 which defines new helper methods for callback integrations
- Update WhyLabsCallbackHandler to use the new `get_callback_instance` so that the callback is mostly defined in langkit
- Remove much of the implementation of the WhyLabsCallbackHandler here in favor of the callback instance

This does not change the behavior of the whylabs callback handler implementation but is a reorganization that moves some of the implementation externally to our optional dependency package, and should make future updates easier.

@agola11
updated langchain/chains/openai_functions/base.py and langchain/chains/base.py 
Labels: name: auto:bug

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: a description of the change, 
  - Issue: the issue # it fixes (if applicable),
  - Dependencies: any dependencies required for this change,
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: we announce bigger features on Twitter. If your PR gets announced and you'd like a mention, we'll gladly shout you out!

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->

Related to issue #7578, create_structured_output_chain will return Dict as o/p where as in documentation it says it will return string, updated examples in langchain/chains/openai_functions/base.py.
Is it possible to use open source embedding methods rather than OpenAIEmbeddings?
Labels: name: auto:question

### System Info

LangChain version :  0.0.216
Python version : 3.11.4
System: Windows

### 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
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction


I want to create a chatbot to retrieve information from my own pdf  in response to a query  using google PaLM model, I followed these steps : 
-load the pdf
-split it using RecursiveCharacterTextSplitter
-store its embeddings in a Chroma vectorestore
and then create a chain ...


```
from langchain.document_loaders import PyPDFLoader
from langchain.document_loaders import PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores import Chroma
from langchain.embeddings.openai import OpenAIEmbeddings

import langchain

loader=PyPDFLoader("path/to/pdf.pdf")
chroma_dir="./chroma
pages=loader.load()
splitter=RecursiveCharacterTextSplitter(
    chunk_size=1000,
    chunk_overlap=150,
    separators=['\n\n','\n'," ",""]
)

splits=splitter.split_documents(pages)

#I want to change this with another embedding method which doesn't require API authentification
embeddings=OpenAIEmbeddings()

vector_db=Chroma.from_documents(
documents=splits,
embedding=embeddings,
persist_directory=chroma_dir
)

```

But the only embedding method that is available in the LangChain documentation is OpenAIEmbeddings,how can we do without it?


### Expected behavior

all the splits embeddings stored in Chroma vectorestore without using OpenAIEmbeddings()
Issue with Langchain LLM Chains 
Labels: name: auto:bug

### System Info

I am using Windows 11 as OS, RAM = 44GB. Also, I am using  LLaMa vicuna-7b-1.1.ggmlv3.q4_0.bin as Local LLM.
I am using Python 3.11.3 in venv virtual environment in VS code IDE and Langchain version 0.0.221.

<img width="948" alt="Screenshot 2023-07-13_Pydantic Error" src="https://github.com/hwchase17/langchain/assets/88419852/6f172fcd-5a06-472f-b3bb-aec069f626f0">


### 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
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Use the following code - 

from llama_cpp import Llama
from langchain import PromptTemplate
from langchain.chains import LLMChain
from langchain.chat_models import ChatOpenAI
import os
from dotenv import load_dotenv
import json
import time

load_dotenv()


model_path = os.environ.get('MODEL_PATH')
print(model_path)
# Load the model
print("....Loading LLAMA")
llm = Llama(model_path=model_path, n_ctx=2048, n_threads=8)
# llm = ChatOpenAI(
#         temperature=0, model_name="gpt-3.5-turbo"
#     )  

text="A lion lives in a jungle"

template = """/
Given the text data {text}, I want you to:
 extract all possible semantic triples in the format of (subject, predicate,object)"""

triple_template = PromptTemplate(input_variables=["text"], template=template)
#print(triple_template)
#triple_template.format(text=t)
chain = LLMChain(llm=llm, prompt=triple_template)
#Run the model
print("RUnning Model.....")
print(chain.run(text=text))

I have commented out llm generated by ChatOpenAI, this code executes and gives desired results if we use OpenAI LLM. However, I am using LLaMa vicuna-7b-1.1.ggmlv3.q4_0.bin, the chain gives the following error - 
File "pydantic\main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for LLMChain
llm
  value is not a valid dict (type=type_error.dict)

I have tested the LLaMa LLM, it works outside LLM chain without any problem.

### Expected behavior

In response to the given text, it should have returned a semantic triple of form ( Subject, Predicate Object) ie. ( Lion, Lives in , Jungle) or something similar.
_get_python_function_name does not work with classes
Labels: name: auto:bug

### System Info

LangChain : v0.0.231

### Who can help?

@hwchase17 

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

# Issue
`convert_to_openai_function` does not work as intended:
- Classes are not supported
- Any function without its source is not supported

# Reproduce

```python
from dataclasses import dataclass
from langchain.chains.openai_functions.base import (
    convert_to_openai_function,
)

@dataclass
class System:
    name: str
    ram: int

convert_to_openai_function(System)
```

### Expected behavior

When calling `langchain.chains.openai_functions.base.convert_to_openai_function`, the subsequent call to `_get_python_function_name` fails because it tries to read source code (and cannot find it).

Something much simpler would be to access the `__name__` attribute of the callable.
Permit Equivalence Checking
Labels: name: auto:bug

Currently you can't compare most chains.

Would fix #7484
```
from langchain.chains import TransformChain
def foo(val):
    return val
chain = TransformChain(transform=foo, input_variables=['foo'], output_variables=['foo'])
chain == chain

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[13], line 1
----> 1 chain == chain

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pydantic/main.py:909, in pydantic.main.BaseModel.__eq__()

File ~/code/lc/lckg/langchain/chains/base.py:556, in Chain.dict(self, **kwargs)
    554     raise ValueError("Saving of memory is not yet supported.")
    555 _dict = super().dict(**kwargs)
--> 556 _dict["_type"] = self._chain_type
    557 return _dict

File ~/code/lc/lckg/langchain/chains/base.py:94, in Chain._chain_type(self)
     92 @property
     93 def _chain_type(self) -> str:
---> 94     raise NotImplementedError("Saving not supported for this chain type.")

NotImplementedError: Saving not supported for this chain type.
```
ImportError: cannot import name 'AgentType' from 'langchain.agents'
Labels: name: auto:bug

### System Info

It's unclear how to check your langchain version, I can instead detail the steps I have taken. 

I am running python 3.10.6 and python 3.11.4

I have uninstalled and reinstalled both versions individually, in path, and attempted to install and run langchain with just one of either of those two versions installed. 

I have installed in both instances 'pip install langchain' uninstalled and reinstalled as 'langchain[all]', ran 'pip install --upgrade langchain[all]'.

I am running this in a streamlit environment with the latest version installed by pip.

the line I am having issue with is:

from langchain.agents import AgentType, initialize_agent, load_tools

Which is out of the langchain published documentation. 

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

from langchain import OpenAI
from langchain.agents import AgentType, initialize_agent, load_tools
from langchain import StreamlitCallbackHandler
import streamlit as st
from dotenv import load_dotenv

### Expected behavior

I expect it to import AgentType from langchain.agents as specified in the public documentation.
Issue: Big issue with inefficient search from Google/Wikipedia and LLM hallucinations with ReAct agent
Labels: name: auto:bug, name: auto:question

### Issue you'd like to raise.

Hi, LangChain community,

just to share that even with the examples mentioned in the official documentation, it is almost impossible to get consistent results when using agents with Wikipedia/Google search tools. Or the search is non conclusive or the LLM is totally hallucinating at the very early step of the pipeline. LLMs from OpenAI for Completion or Conversation.

Did someone else notice this new behavior?

Best regards

Jerome

### Suggestion:

_No response_
Fix Lint: Bittensor llm
Labels: name: auto:nit

I fixed the lint so it passes checks for pull #7602 

I didn't remove the bearer key in the headers on line 58 in case it's there on purpose for whatever reason that could be. However, @Kunj-2206 if that's not left in on purpose, either reply here to remove it or git checkout this pull req and make a new one.
If we continuously send "Hello" messages to the "conversational retrieval chain," the model produces weired/wrong answers.
Labels: name: auto:bug

### System Info

langchain==0.0.170
openai==0.27.4
python
windows

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

I am using the "**ConversationalRetrievalChain**", Whenever I send a message to a model, it produces wrong results with history, whereas if I send the same message without history, it produces correct results. The issue here is that the model is forming the wrong standalone question, and the same wrong standalone question is passing to the OpenAI Model.

Steps to reproduce:
1. Use the Conversational Retrieval Chan
2. Pass the history on to the chain.
3. Send the "Hello" message continuously.
Here you can observe wrong/weired answers.

The above scenario is Just an example. But whenever we ask some question, immediately if we send the message "Hello", the "conversational retrieval chain" forms the wrong standalone question, hence the openAI model producing wrong answers.

This is the code I am using: -

_template = """
	Use the following pieces of context to answer the question at the end.
	{context}
	If you still cant find the answer, just say that you don't know, don't try to make up an answer.
	You can also look into chat history.
	{chat_history}
	Question: {question}
	Answer:                
	"""
	
	
CONDENSE_QUESTION_PROMPT = PromptTemplate(
	template=_template,
	input_variables = ["context","question", "chat_history"],
)


chain = ConversationalRetrievalChain.from_llm(
	llm= azure_chat_api_llm_objct,
	retriever=vectors.as_retriever(),
	verbose=True,
	chain_type="stuff",
	memory = memory,
	get_chat_history=lambda h:h,    
	# condense_question_prompt=CONDENSE_QUESTION_PROMPT,
	combine_docs_chain_kwargs={"prompt": CONDENSE_QUESTION_PROMPT},
	return_generated_question=True,
	)   
	
chain.run("Hello")

Note:- I have tried multiple way like removing "CONDENCE_QUESTION", without prompt, with different types of prompts, etc..but still its producing wrong standalone question.
Ex:-
_template = """
  Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
  
  Chat History:
  {chat_history}
  Follow Up Input: {question}
  Standalone question:
"""

Thanks in advance, and please correct me if I made any mistakes in the code.

<img width="458" alt="image" src="https://github.com/hwchase17/langchain/assets/52491904/eb0e3aba-6151-42f8-924b-bda2cb4ccfaf">



### Expected behavior

It should form a proper standalone question when we pass history before passing to model.
Add support for Meilisearch vector databases
Labels: name: auto:enhancement

### Feature request

Add support for Meilisearch vector search.
[Meilisearch](https://www.meilisearch.com) is an open-source search engine. See [documentation](https://www.meilisearch.com/docs)

### Motivation

Meilisearch is releasing the vector search/store feature, which should be available from July 31st.

### Your contribution

I'm working on it and will submit a PR for this issue soon.
add bittensor llm to langchain llms
Labels: name: auto:enhancement

  - Description:  Adding BittensorLLM via Validator Endpoint to langchain llms
  - Tag maintainer: @Kunj-2206 


Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11
Create langchain/llms/bittensor.py
Labels: name: auto:enhancement

Added BittensorLLM model inside langchain.llms

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: a description of the change, 
  - Issue: the issue # it fixes (if applicable),
  - Dependencies: any dependencies required for this change,
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: we announce bigger features on Twitter. If your PR gets announced and you'd like a mention, we'll gladly shout you out!

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Output parser set number of list result
Labels: name: auto:question

### Issue you'd like to raise.

I'd like to understand if there is a way to have from OpenAI response a **list of values** (string or objects: it's the same) of a **fixed length**. I read the documentation here: https://python.langchain.com/docs/modules/model_io/output_parsers/comma_separated but I didn't find anything related to a length (maybe it's not possible?). Indeed I understood that probably these parsers only add a well-formatted piece of prompt, but you don't have the safety to have the expected results.

In my use case, I have a list of texts and I want to have a title on each of them. My prompt is something like that:
```
####
Text 1:
- Bla bla bla
...
Text 8:
- Bla bla bla
###

Use these texts to generate a title for each text. The number of the titles must be 8.
```

At the end of the prompt I "force" the number to the number of the expected results with the same number of the text, but sometimes the model gives me more titles (above all when the number of texts is 1).

So I thought to use these parsers. But I don't find any constraints on the length of the results, the only thing is a validator to check if the length is correct.

### Suggestion:

_No response_