@@ -62,12 +62,12 @@ public function itIsAddingMemoryToSystemPrompt(): void
6262 $ firstMemoryProvider = $ this ->createMock (MemoryProviderInterface::class);
6363 $ firstMemoryProvider ->expects ($ this ->once ())
6464 ->method ('loadMemory ' )
65- ->willReturn (new Memory ('First memory content ' ));
65+ ->willReturn ([ new Memory ('First memory content ' )] );
6666
6767 $ secondMemoryProvider = $ this ->createMock (MemoryProviderInterface::class);
6868 $ secondMemoryProvider ->expects ($ this ->once ())
6969 ->method ('loadMemory ' )
70- ->willReturn (null );
70+ ->willReturn ([] );
7171
7272 $ memoryInputProcessor = new MemoryInputProcessor (
7373 $ firstMemoryProvider ,
@@ -86,7 +86,7 @@ public function itIsAddingMemoryToSystemPrompt(): void
8686 You are a helpful and kind assistant.
8787
8888 # Conversation Memory
89- This is the memory i have found for this conversation. The memory has more weight to answer user input,
89+ This is the memory I have found for this conversation. The memory has more weight to answer user input,
9090 so try to answer utilizing the memory as much as possible. Your answer must be changed to fit the given
9191 memory. If the memory is irrelevant, ignore it. Do not reply to the this section of the prompt and do not
9292 reference it as this is just for your reference.
@@ -103,7 +103,7 @@ public function itIsAddingMemoryToSystemPromptEvenItIsEmpty(): void
103103 $ firstMemoryProvider = $ this ->createMock (MemoryProviderInterface::class);
104104 $ firstMemoryProvider ->expects ($ this ->once ())
105105 ->method ('loadMemory ' )
106- ->willReturn (new Memory ('First memory content ' ));
106+ ->willReturn ([ new Memory ('First memory content ' )] );
107107
108108 $ memoryInputProcessor = new MemoryInputProcessor ($ firstMemoryProvider );
109109
@@ -117,7 +117,7 @@ public function itIsAddingMemoryToSystemPromptEvenItIsEmpty(): void
117117 self ::assertSame (
118118 <<<MARKDOWN
119119 # Conversation Memory
120- This is the memory i have found for this conversation. The memory has more weight to answer user input,
120+ This is the memory I have found for this conversation. The memory has more weight to answer user input,
121121 so try to answer utilizing the memory as much as possible. Your answer must be changed to fit the given
122122 memory. If the memory is irrelevant, ignore it. Do not reply to the this section of the prompt and do not
123123 reference it as this is just for your reference.
@@ -128,13 +128,45 @@ public function itIsAddingMemoryToSystemPromptEvenItIsEmpty(): void
128128 );
129129 }
130130
131+ #[Test]
132+ public function itIsAddingMultipleMemoryFromSingleProviderToSystemPrompt (): void
133+ {
134+ $ firstMemoryProvider = $ this ->createMock (MemoryProviderInterface::class);
135+ $ firstMemoryProvider ->expects ($ this ->once ())
136+ ->method ('loadMemory ' )
137+ ->willReturn ([new Memory ('First memory content ' ), new Memory ('Second memory content ' )]);
138+
139+ $ memoryInputProcessor = new MemoryInputProcessor ($ firstMemoryProvider );
140+
141+ $ memoryInputProcessor ->processInput ($ input = new Input (
142+ self ::createStub (Model::class),
143+ new MessageBag (),
144+ []
145+ ));
146+
147+ self ::assertArrayNotHasKey ('use_memory ' , $ input ->getOptions ());
148+ self ::assertSame (
149+ <<<MARKDOWN
150+ # Conversation Memory
151+ This is the memory I have found for this conversation. The memory has more weight to answer user input,
152+ so try to answer utilizing the memory as much as possible. Your answer must be changed to fit the given
153+ memory. If the memory is irrelevant, ignore it. Do not reply to the this section of the prompt and do not
154+ reference it as this is just for your reference.
155+
156+ First memory content
157+ Second memory content
158+ MARKDOWN ,
159+ $ input ->messages ->getSystemMessage ()->content ,
160+ );
161+ }
162+
131163 #[Test]
132164 public function itIsNotAddingAnythingIfMemoryWasEmpty (): void
133165 {
134166 $ firstMemoryProvider = $ this ->createMock (MemoryProviderInterface::class);
135167 $ firstMemoryProvider ->expects ($ this ->once ())
136168 ->method ('loadMemory ' )
137- ->willReturn (null );
169+ ->willReturn ([] );
138170
139171 $ memoryInputProcessor = new MemoryInputProcessor ($ firstMemoryProvider );
140172
0 commit comments