langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Can't instantiate langchain.chains.LLMChain to create_llama_chat_agent (Setting custom prompt)

Open tezcahernandez opened this issue 3 years ago • 4 comments

Hello everyone,

Working in an implementation Index-GPT+LangChain. I'm trying to set a custom prompt where I can set additional context. Based on the documentation I'm trying to run this code.

langchain 0.0.139 llama-index 0.5.15


template = """Pretend you are Steve Jobs. Answer with motivational content. Steve: How I can help you today?. Person: I want some motivation. Steve: You are amazing you can create any type of business you want.
Person: {question}?
Steve:"""

prompt = PromptTemplate(template=template, input_variables=["question"])

llm=OpenAI(temperature=0)
print(type(llm))
llm = LLMChain(prompt=prompt, llm=llm)
print(type(llm))

memory = ConversationBufferMemory(memory_key="chat_history")

agent_chain = create_llama_chat_agent(
    toolkit,
    llm,
    memory=memory,
    verbose=True
)

But I'm getting the below error:

ValidationError: 1 validation error for LLMChain
llm
  Can't instantiate abstract class BaseLanguageModel with abstract methods agenerate_prompt, generate_prompt (type=type_error)

Thanks for your help.

tezcahernandez avatar Apr 15 '23 00:04 tezcahernandez

@tezcahernandez did you resolve this? What was the issue? I'm facing the same all of a sudden.

homanp avatar Apr 18 '23 21:04 homanp

@homanp We have changed the approach since this code is not working. Now we are using our own chain/agent with Langchain.

tezcahernandez avatar Apr 21 '23 18:04 tezcahernandez

@homanp We have changed the approach since this code is not working. Now we are using our own chain/agent with Langchain.

I Did the same

homanp avatar Apr 21 '23 19:04 homanp

can you explain how did you do it ???? o where i can found documentation ... i have the same problem ...

postix avatar May 19 '23 03:05 postix

Me too, I face the same problem, how do you solve it @tezcahernandez ?

dinhan92 avatar Jun 20 '23 04:06 dinhan92

getting the same error when trying this:

self.agent_llm_chain = LLMChain(
                llm=OpenAI(model="gpt-3.5-turbo-instruct", temperature=0),
)

self.agent_chain = initialize_agent(
              self.tools,
              self.agent_llm_chain,
              agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
              verbose=True,
              memory=self.agent_memory,
)

faev999 avatar Sep 20 '23 10:09 faev999

Hi, @tezcahernandez

I'm helping the LangChain team manage their backlog and am marking this issue as stale. From what I understand, you raised an issue regarding a validation error encountered when trying to instantiate langchain.chains.LLMChain to create a custom prompt for a chat agent. In the comments, you mentioned changing the approach and using your own chain/agent with Langchain. Other users also reported facing the same problem and sought solutions or documentation. The issue remains unresolved at this time.

Could you please confirm if this issue is still relevant to the latest version of the LangChain repository? If it is, please let the LangChain team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!

dosubot[bot] avatar Dec 20 '23 16:12 dosubot[bot]