You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I couldn't quite figure out from a quick first read of the code how to use conversation history. Like if I run this, it doesn't know what I just asked:
r=lf.query('Who is Larry Page', lm=lm)
print(r)
# Larry Page is a prominent American computer scientist ...r2=lf.query('What did I just ask?', lm=lm)
print(r2)
# I'm sorry, but I can't recall or access previous interactions.
The text was updated successfully, but these errors were encountered:
Might have answered my own question, but let me know if there is a more preferred method:
importlangfunaslffromlangfun.core.templates.conversationimportConversationclassAnswer(pg.Object):
result: intlm=lf.llms.Gpt4o()
c=Conversation(
preamble='You are a helpful and joyful chat bot. Let us chat.',
)
input_message='The result of one plus two is'r=lf.query(c.prompt.render(input_message=input_message), Answer, lm=lm, returns_message=True)
# Answer(result=3)# update memoryc.add(input_message, r)
input_message='What did I just say?'r2=lf.query(c.prompt.render(input_message=input_message), lm=lm, returns_message=True)
# "you just asked me the result of one plus two..."
It seems like under the hood, when making the call to the LLM provider, this Conversation template puts all of the turns into one single message with the user role instead of multiple messages with alternating roles?
Very fun project :)
I couldn't quite figure out from a quick first read of the code how to use conversation history. Like if I run this, it doesn't know what I just asked:
The text was updated successfully, but these errors were encountered: