Skip to content

Commit

Permalink
Update chatmodel-springai/src/main/java/com/example/ai/service/ChatSe…
Browse files Browse the repository at this point in the history
…rvice.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
rajadilipkolli and coderabbitai[bot] authored Apr 9, 2024
1 parent 560b9c3 commit 8a9295f
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ public AIChatResponse chatWithSystemPrompt(String query) {
return new AIChatResponse(answer);
}

private static final String SENTIMENT_ANALYSIS_TEMPLATE = "{query}, You must answer strictly in the following format: one of [POSITIVE, NEGATIVE, SARCASTIC]";
public AIChatResponse analyzeSentiment(String query) {
String template =
"""
{query}, You must answer strictly in the following format: one of [POSITIVE, NEGATIVE, SARCASTIC]
""";
AssistantPromptTemplate promptTemplate = new AssistantPromptTemplate(template);
AssistantPromptTemplate promptTemplate = new AssistantPromptTemplate(SENTIMENT_ANALYSIS_TEMPLATE);
Prompt prompt = promptTemplate.create(Map.of("query", query));
ChatResponse response = chatClient.call(prompt);
Generation generation = response.getResult();
Expand Down

0 comments on commit 8a9295f

Please sign in to comment.