Skip to content

Commit

Permalink
Merge pull request #460 from solliancenet/kb-csv-agent-optimizations
Browse files Browse the repository at this point in the history
Disabling CSV agent conversation history
  • Loading branch information
codingbandit authored Jan 14, 2024
2 parents 41dfa96 + 142d577 commit 951adf8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/python/PythonSDK/foundationallm/langchain/agents/csv_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ def __init__(
PythonAstREPLTool(locals = df_locals)
]

memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
#Add previous messages to memory
for i in range(0, len(self.message_history), 2):
history_pair = itemgetter(i,i+1)(self.message_history)
for message in history_pair:
if message.sender.lower() == 'user':
user_input = message.text
else:
ai_output = message.text
memory.save_context({"input": user_input}, {"output": ai_output})
memory = ConversationBufferMemory(memory_key="chat_history") #, return_messages=True)
# #Add previous messages to memory
# for i in range(0, len(self.message_history), 2):
# history_pair = itemgetter(i,i+1)(self.message_history)
# for message in history_pair:
# if message.sender.lower() == 'user':
# user_input = message.text
# else:
# ai_output = message.text
# memory.save_context({"input": user_input}, {"output": ai_output})

self.prompt_prefix = completion_request.agent.prompt_prefix
self.prompt_prefix += f'\nYou are working with {len(df_names)} pandas dataframe{"s"[:len(df_names)^1]} in Python named {", ".join(df_names)}.'
Expand Down

0 comments on commit 951adf8

Please sign in to comment.