Skip to content

Commit

Permalink
Segregate memory of concurrent requests to different AI services
Browse files Browse the repository at this point in the history
This is done by adding the name of the interface and method
to the name given by the provider
  • Loading branch information
geoand committed May 16, 2024
1 parent 9f82cf7 commit aa95402
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ private static Object memoryId(AiServiceMethodCreateInfo createInfo, Object[] me
for (DefaultMemoryIdProvider provider : DEFAULT_MEMORY_ID_PROVIDERS) {
Object memoryId = provider.getMemoryId();
if (memoryId != null) {
return memoryId;
String perServiceSuffix = "#" + createInfo.getInterfaceName() + "." + createInfo.getMethodName();
return memoryId + perServiceSuffix;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import io.quarkiverse.langchain4j.RegisterAiService;
import io.quarkiverse.langchain4j.openai.testing.internal.OpenAiBaseTest;
import io.quarkiverse.langchain4j.testing.internal.WiremockAware;
import io.quarkus.arc.InjectableContext;
import io.quarkus.test.QuarkusUnitTest;
import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.websockets.next.OnOpen;
Expand Down Expand Up @@ -77,7 +76,7 @@ public void restRequest() {
.statusCode(200);

assertThat(chatMemoryStore.idsFromGetMessages).hasSize(1)
.hasOnlyElementsOfType(InjectableContext.ContextState.class);
.hasOnlyElementsOfType(String.class);
assertThat(chatMemoryStore.idsFromGetMessages).hasSameElementsAs(chatMemoryStore.idsFromDeleteMessaged);

when()
Expand All @@ -86,7 +85,7 @@ public void restRequest() {
.statusCode(200);

assertThat(chatMemoryStore.idsFromGetMessages).hasSize(2)
.hasOnlyElementsOfType(InjectableContext.ContextState.class);
.hasOnlyElementsOfType(String.class);
assertThat(chatMemoryStore.idsFromGetMessages).hasSameElementsAs(chatMemoryStore.idsFromDeleteMessaged);
}

Expand Down

0 comments on commit aa95402

Please sign in to comment.