Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/TaskProcessing/AudioToAudioChatProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public function getOptionalInputShape(): array {
$this->l->t('The voice used to generate speech'),
EShapeType::Enum
),
'memories' => new ShapeDescriptor(
$this->l->t('Memories'),
$this->l->t('The memories to be injected into the chat session.'),
EShapeType::ListOfTexts
),
];
if (!$isUsingOpenAi) {
$ois['tts_model'] = new ShapeDescriptor(
Expand Down Expand Up @@ -165,6 +170,11 @@ public function process(?string $userId, array $input, callable $reportProgress)
}
$systemPrompt = $input['system_prompt'];

if (isset($input['memories']) && is_array($input['memories']) && count($input['memories'])) {
/** @psalm-suppress InvalidArgument */
$systemPrompt .= "\n\nYou can remember things from other conversation with the user. If they are relevant, take into account the following memories:\n" . implode("\n\n", $input['memories']) . "\n\nDo not mention these memories explicitly. You may use them as context, but do not repeat them. At most, you can mention that you remember something.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$systemPrompt .= "\n\nYou can remember things from other conversation with the user. If they are relevant, take into account the following memories:\n" . implode("\n\n", $input['memories']) . "\n\nDo not mention these memories explicitly. You may use them as context, but do not repeat them. At most, you can mention that you remember something.";
$systemPrompt .= "\n\nYou can remember things from other conversations with the user. If they are relevant, take into account the following memories:\n" . implode("\n\n", $input['memories']) . "\n\nDo not mention these memories explicitly. You may use them as context, but do not repeat them. At most, you can mention that you remember something.";

You can remember things kind of means if you want, then remember things now. How about something like You have memories of other conversations with the user?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remember things kind of means if you want, then remember things now

That is on purpose, because the llm needs to be aware that it can remember things from the current conversation as well. Ie. if the user asks "Can you remember this conversation?" the LLM needs to respond "Yes, I can." -- in my tests it said stuff like e.g. "I cannot remember this interaction in other conversations but I will keep this in mind for the current conversation."

Copy link
Contributor

@kyteinsky kyteinsky Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is on purpose, because the llm needs to be aware that it can remember things from the current conversation as well
"I cannot remember this interaction in other conversations but I will keep this in mind for the current conversation."

the memories would be summaries of other conversations, no? I suppose this instruction of being aware that it can store any memories would be more needed in cases where it needs to do a tool call to store a particular memory.

nevermind

}

if (!isset($input['history']) || !is_array($input['history'])) {
throw new RuntimeException('Invalid chat history, array expected');
}
Expand Down
10 changes: 10 additions & 0 deletions lib/TaskProcessing/TextToTextChatProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function getOptionalInputShape(): array {
$this->l->t('The maximum number of words/tokens that can be generated in the completion.'),
EShapeType::Number
),
'memories' => new ShapeDescriptor(
$this->l->t('Memories'),
$this->l->t('The memories to be injected into the chat session.'),
EShapeType::ListOfTexts
),
];
}

Expand Down Expand Up @@ -97,6 +102,11 @@ public function process(?string $userId, array $input, callable $reportProgress)
}
$systemPrompt = $input['system_prompt'];

if (isset($input['memories']) && is_array($input['memories']) && count($input['memories'])) {
/** @psalm-suppress InvalidArgument */
$systemPrompt .= "\n\nYou can remember things from other conversations with the user. If they are relevant, take into account the following memories:\n" . implode("\n\n", $input['memories']) . "\n\nDo not mention these memories explicitly. You may use them as context, but do not repeat them. At most, you can mention that you remember something.";
}

if (!isset($input['history']) || !is_array($input['history'])) {
throw new RuntimeException('Invalid history');
}
Expand Down
Loading