From 03656c2c35eb7596e46eb52ec1f1d4f43b99bca3 Mon Sep 17 00:00:00 2001 From: lixw <> Date: Tue, 3 Dec 2024 09:40:27 +0800 Subject: [PATCH] Modify the ChatModelListenerIT#should_listen_error test case. --- .../XinferenceChatModelListenerIT.java | 61 ++++++------- ...inferenceStreamingChatModelListenerIT.java | 90 ++++++++++--------- 2 files changed, 77 insertions(+), 74 deletions(-) diff --git a/models/langchain4j-community-xinference/src/test/java/dev/langchain4j/community/model/xinference/XinferenceChatModelListenerIT.java b/models/langchain4j-community-xinference/src/test/java/dev/langchain4j/community/model/xinference/XinferenceChatModelListenerIT.java index 98f2a85..c7c6242 100644 --- a/models/langchain4j-community-xinference/src/test/java/dev/langchain4j/community/model/xinference/XinferenceChatModelListenerIT.java +++ b/models/langchain4j-community-xinference/src/test/java/dev/langchain4j/community/model/xinference/XinferenceChatModelListenerIT.java @@ -9,37 +9,38 @@ class XinferenceChatModelListenerIT extends ChatModelListenerIT { - @Override - protected ChatLanguageModel createModel(ChatModelListener listener) { - return XinferenceChatModel.builder() - .baseUrl(AbstractInferenceChatModelInfrastructure.baseUrl()) - .apiKey(AbstractInferenceChatModelInfrastructure.apiKey()) - .modelName(modelName()) - .temperature(temperature()) - .topP(topP()) - .maxTokens(maxTokens()) - .logRequests(true) - .logResponses(true) - .listeners(singletonList(listener)) - .build(); - } + @Override + protected ChatLanguageModel createModel(ChatModelListener listener) { + return XinferenceChatModel.builder() + .baseUrl(AbstractInferenceChatModelInfrastructure.baseUrl()) + .apiKey(AbstractInferenceChatModelInfrastructure.apiKey()) + .modelName(modelName()) + .temperature(temperature()) + .topP(topP()) + .maxTokens(maxTokens()) + .logRequests(true) + .logResponses(true) + .listeners(singletonList(listener)) + .build(); + } - @Override - protected String modelName() { - return AbstractInferenceChatModelInfrastructure.modelName(); - } + @Override + protected String modelName() { + return AbstractInferenceChatModelInfrastructure.modelName(); + } - @Override - protected ChatLanguageModel createFailingModel(ChatModelListener listener) { - return XinferenceChatModel.builder() - .apiKey("banana") - .maxRetries(1) - .listeners(singletonList(listener)) - .build(); - } + @Override + protected ChatLanguageModel createFailingModel(ChatModelListener listener) { + return XinferenceChatModel.builder() + .baseUrl(AbstractInferenceChatModelInfrastructure.baseUrl()) + .modelName("llama3.1") + .maxRetries(1) + .listeners(singletonList(listener)) + .build(); + } - @Override - protected Class expectedExceptionClass() { - return XinferenceHttpException.class; - } + @Override + protected Class expectedExceptionClass() { + return XinferenceHttpException.class; + } } diff --git a/models/langchain4j-community-xinference/src/test/java/dev/langchain4j/community/model/xinference/XinferenceStreamingChatModelListenerIT.java b/models/langchain4j-community-xinference/src/test/java/dev/langchain4j/community/model/xinference/XinferenceStreamingChatModelListenerIT.java index a94d897..8a6483a 100644 --- a/models/langchain4j-community-xinference/src/test/java/dev/langchain4j/community/model/xinference/XinferenceStreamingChatModelListenerIT.java +++ b/models/langchain4j-community-xinference/src/test/java/dev/langchain4j/community/model/xinference/XinferenceStreamingChatModelListenerIT.java @@ -9,48 +9,50 @@ class XinferenceStreamingChatModelListenerIT extends StreamingChatModelListenerIT { - @Override - protected StreamingChatLanguageModel createModel(ChatModelListener listener) { - return XinferenceStreamingChatModel.builder() - .baseUrl(AbstractInferenceChatModelInfrastructure.baseUrl()) - .apiKey(AbstractInferenceChatModelInfrastructure.apiKey()) - .modelName(modelName()) - .temperature(temperature()) - .topP(topP()) - .maxTokens(maxTokens()) - .logRequests(true) - .logResponses(true) - .listeners(singletonList(listener)) - .build(); - } - - /** - * Streaming support for tool calls is available only when using Qwen models with vLLM backend or GLM4-chat models without vLLM backend. - * - * @return - */ - @Override - protected boolean supportsTools() { - return false; - } - - @Override - protected String modelName() { - return AbstractInferenceChatModelInfrastructure.modelName(); - } - - @Override - protected StreamingChatLanguageModel createFailingModel(ChatModelListener listener) { - return XinferenceStreamingChatModel.builder() - .apiKey("banana") - .logRequests(true) - .logResponses(true) - .listeners(singletonList(listener)) - .build(); - } - - @Override - protected Class expectedExceptionClass() { - return XinferenceHttpException.class; - } + @Override + protected StreamingChatLanguageModel createModel(ChatModelListener listener) { + return XinferenceStreamingChatModel.builder() + .baseUrl(AbstractInferenceChatModelInfrastructure.baseUrl()) + .apiKey(AbstractInferenceChatModelInfrastructure.apiKey()) + .modelName(modelName()) + .temperature(temperature()) + .topP(topP()) + .maxTokens(maxTokens()) + .logRequests(true) + .logResponses(true) + .listeners(singletonList(listener)) + .build(); + } + + /** + * Streaming support for tool calls is available only when using Qwen models with vLLM backend or + * GLM4-chat models without vLLM backend. + * + * @return + */ + @Override + protected boolean supportsTools() { + return false; + } + + @Override + protected String modelName() { + return AbstractInferenceChatModelInfrastructure.modelName(); + } + + @Override + protected StreamingChatLanguageModel createFailingModel(ChatModelListener listener) { + return XinferenceStreamingChatModel.builder() + .baseUrl(AbstractInferenceChatModelInfrastructure.baseUrl()) + .modelName("llama3.1") + .logRequests(true) + .logResponses(true) + .listeners(singletonList(listener)) + .build(); + } + + @Override + protected Class expectedExceptionClass() { + return XinferenceHttpException.class; + } }