mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-26 18:24:20 +08:00
[improvement](python) LLM related services support Java service invocation (#484)
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
package com.tencent.supersonic.integration;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tencent.supersonic.StandaloneLauncher;
|
||||
import com.tencent.supersonic.chat.query.llm.analytics.LLMAnswerResp;
|
||||
import com.tencent.supersonic.chat.service.AgentService;
|
||||
import com.tencent.supersonic.common.config.EmbeddingConfig;
|
||||
import com.tencent.supersonic.common.util.embedding.EmbeddingUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@@ -21,13 +18,9 @@ public class MetricInterpretTest {
|
||||
|
||||
@MockBean
|
||||
private AgentService agentService;
|
||||
|
||||
@MockBean
|
||||
private EmbeddingConfig embeddingConfig;
|
||||
|
||||
@MockBean
|
||||
private EmbeddingUtils embeddingUtils;
|
||||
|
||||
@Test
|
||||
public void testMetricInterpret() throws Exception {
|
||||
MockConfiguration.mockAgent(agentService);
|
||||
@@ -36,7 +29,6 @@ public class MetricInterpretTest {
|
||||
LLMAnswerResp lLmAnswerResp = new LLMAnswerResp();
|
||||
lLmAnswerResp.setAssistantMessage("alice最近在超音数的访问情况有增多");
|
||||
|
||||
MockConfiguration.embeddingUtils(embeddingUtils, ResponseEntity.ok(JSONObject.toJSONString(lLmAnswerResp)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package com.tencent.supersonic.integration;
|
||||
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyObject;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.chat.plugin.PluginManager;
|
||||
import com.tencent.supersonic.chat.service.AgentService;
|
||||
import com.tencent.supersonic.common.config.EmbeddingConfig;
|
||||
import com.tencent.supersonic.common.util.embedding.EmbeddingUtils;
|
||||
import com.tencent.supersonic.common.util.embedding.Retrieval;
|
||||
import com.tencent.supersonic.common.util.embedding.RetrieveQueryResult;
|
||||
import com.tencent.supersonic.util.DataUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@@ -38,7 +35,4 @@ public class MockConfiguration {
|
||||
when(agentService.getAgent(1)).thenReturn(DataUtils.getAgent());
|
||||
}
|
||||
|
||||
public static void embeddingUtils(EmbeddingUtils embeddingUtils, ResponseEntity<String> responseEntity) {
|
||||
when(embeddingUtils.doRequest(anyObject(), anyObject(), anyObject())).thenReturn(responseEntity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user