Fixed as par some more review comments.

This commit is contained in:
CHANDRAKANT Kumar 2023-10-29 23:23:54 +05:30
parent ed75b80958
commit 2b22ffc5ea
6 changed files with 1 additions and 21 deletions

View File

@ -1,6 +0,0 @@
## Language Model Integration Libraries
This module contains articles about libraries for language model integration in Java.
### Relevant articles
- [Introduction to LangChain](https://www.baeldung.com/langchain)

View File

@ -31,7 +31,6 @@ public class ChainWithDocumentLiveTest {
@Test
public void givenChainWithDocument_whenPrompted_thenValidResponse() {
EmbeddingModel embeddingModel = new AllMiniLmL6V2EmbeddingModel();
EmbeddingStore<TextSegment> embeddingStore = new InMemoryEmbeddingStore<>();
@ -61,7 +60,6 @@ public class ChainWithDocumentLiveTest {
logger.info(answer);
assertNotNull(answer);
}
}

View File

@ -38,7 +38,6 @@ public class ChatWithDocumentLiveTest {
@Test
public void givenDocument_whenPrompted_thenValidResponse() {
Document document = loadDocument(Paths.get("src/test/resources/example-files/simpson's_adventures.txt"));
DocumentSplitter splitter = DocumentSplitters.recursive(100, 0, new OpenAiTokenizer(GPT_3_5_TURBO));
List<TextSegment> segments = splitter.split(document);
@ -77,7 +76,6 @@ public class ChatWithDocumentLiveTest {
logger.info(aiMessage.text());
assertNotNull(aiMessage.text());
}
}

View File

@ -22,7 +22,6 @@ public class ChatWithMemoryLiveTest {
@Test
public void givenMemory_whenPrompted_thenValidResponse() {
ChatLanguageModel model = OpenAiChatModel.withApiKey(Constants.OPEN_AI_KEY);
ChatMemory chatMemory = TokenWindowChatMemory.withMaxTokens(300, new OpenAiTokenizer(GPT_3_5_TURBO));
@ -38,9 +37,7 @@ public class ChatWithMemoryLiveTest {
.content();
logger.info(answerWithName.text());
chatMemory.add(answerWithName);
assertThat(answerWithName.text()
.contains("Kumar"));
assertThat(answerWithName.text()).contains("Kumar");
}
}

View File

@ -21,7 +21,6 @@ public class PromptTemplatesLiveTest {
@Test
public void givenPromptTemplate_whenSuppliedInput_thenValidResponse() {
PromptTemplate promptTemplate = PromptTemplate.from("Tell me a {{adjective}} joke about {{content}}..");
Map<String, Object> variables = new HashMap<>();
variables.put("adjective", "funny");
@ -37,7 +36,6 @@ public class PromptTemplatesLiveTest {
String response = model.generate(prompt.text());
logger.info(response);
assertNotNull(response);
}
}

View File

@ -16,7 +16,6 @@ public class ServiceWithToolsLiveTest {
private static final Logger logger = LoggerFactory.getLogger(ServiceWithToolsLiveTest.class);
static class Calculator {
@Tool("Calculates the length of a string")
int stringLength(String s) {
return s.length();
@ -26,17 +25,14 @@ public class ServiceWithToolsLiveTest {
int add(int a, int b) {
return a + b;
}
}
interface Assistant {
String chat(String userMessage);
}
@Test
public void givenServiceWithTools_whenPrompted_thenValidResponse() {
Assistant assistant = AiServices.builder(Assistant.class)
.chatLanguageModel(OpenAiChatModel.withApiKey(Constants.OPEN_AI_KEY))
.tools(new Calculator())
@ -48,7 +44,6 @@ public class ServiceWithToolsLiveTest {
logger.info(answer);
assertThat(answer).contains("13");
}
}