-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLLMUtils.java
More file actions
25 lines (23 loc) · 809 Bytes
/
LLMUtils.java
File metadata and controls
25 lines (23 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.example.spring.app.llm;
public class LLMUtils {
public static String wrapUserInputWithConversationContext(String userInput) {
return """
Conversation:
%s
""".formatted(userInput);
}
/**
* Parse conversation title to limit to max 6 words.
* If more than 6 words, append "..." at the end.
*/
public static String parseConversationTitle(String conversationTitle) {
String parsedTitle = conversationTitle;
if (conversationTitle != null) {
String[] words = conversationTitle.split("\\s+");
if (words.length > 6) {
parsedTitle = String.join(" ", java.util.Arrays.copyOfRange(words, 0, 6)) + "...";
}
}
return parsedTitle;
}
}