Skip to content

Commit a781de5

Browse files
authored
Merge pull request #93 from nextcloud/feat/memories
feat: Add optional memories input slot
2 parents bb1ffee + 22754bb commit a781de5

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

ex_app/lib/agent.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ async def call_model(
134134
system_prompt_text += "Use the find_person_in_contacts tool to find a person's email address and location.\n"
135135
if tool_enabled("find_details_of_current_user"):
136136
system_prompt_text += "Use the find_details_of_current_user tool to find the current user's location.\n"
137+
138+
if task['input'].get('memories', None) is not None:
139+
system_prompt_text += "You can remember things from other conversations with the user. If relevant, take into account the following memories:\n\n" + "\n".join(task['input']['memories']) + "\n\n"
137140
# this is similar to customizing the create_react_agent with state_modifier, but is a lot more flexible
138141
system_prompt = SystemMessage(
139142
system_prompt_text.replace("{CURRENT_DATE}", current_date)

ex_app/lib/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def background_thread_task():
159159
task = response["task"]
160160
log(nc, LogLvl.INFO, 'New Task incoming')
161161
log(nc, LogLvl.DEBUG, str(task))
162-
log(nc, LogLvl.INFO, str({'input': task['input']['input'], 'confirmation': task['input']['confirmation'], 'conversation_token': '<skipped>'}))
162+
log(nc, LogLvl.INFO, str({'input': task['input']['input'], 'confirmation': task['input']['confirmation'], 'conversation_token': '<skipped>', 'memories': task['input'].get('memories', None)}))
163163
asyncio.create_task(handle_task(task, nc))
164164

165165

ex_app/lib/provider.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@
1414
description="Used tools",
1515
shape_type=ShapeType.LIST_OF_TEXTS
1616
)
17+
],
18+
optional_input_shape= [
19+
ShapeDescriptor(
20+
name="memories",
21+
description="Injected memories",
22+
shape_type=ShapeType.LIST_OF_TEXTS
23+
)
1724
]
1825
)

0 commit comments

Comments
 (0)