Implement model-specific prompt handling in AdvancedAIPromptSolver
This commit is contained in:
@@ -66,17 +66,40 @@ public class AdvancedAIPromptSolver extends StepSolver {
|
|||||||
|
|
||||||
String userText = this.qai_user_input;
|
String userText = this.qai_user_input;
|
||||||
|
|
||||||
Message userMessage = new UserMessage(userText);
|
|
||||||
Message systemMessage = new SystemMessage(this.qai_system_prompt_template);
|
|
||||||
|
|
||||||
CallResponseSpec resp = chatClient.prompt()
|
CallResponseSpec resp=null;
|
||||||
.messages(userMessage,systemMessage)
|
|
||||||
.advisors(advisor -> advisor
|
|
||||||
.param("chat_memory_conversation_id", this.scenarioExecution.getId()+this.qai_custom_memory_id)
|
if( chatModel.getDefaultOptions().getModel().contains("o1-") ){
|
||||||
.param("chat_memory_response_size", 100))
|
logger.info("Using o1- model => " + chatModel.getDefaultOptions().getModel());
|
||||||
.call();
|
|
||||||
|
String completePrompt = this.qai_system_prompt_template + userText;
|
||||||
|
|
||||||
|
resp = chatClient.prompt()
|
||||||
|
.messages(new UserMessage(completePrompt))
|
||||||
|
.advisors(advisor -> advisor
|
||||||
|
.param("chat_memory_conversation_id", this.scenarioExecution.getId()+this.qai_custom_memory_id)
|
||||||
|
.param("chat_memory_response_size", 100))
|
||||||
|
.call();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
logger.info("Using standard model=> " + chatModel.getDefaultOptions().getModel());
|
||||||
|
|
||||||
|
Message userMessage = new UserMessage(userText);
|
||||||
|
Message systemMessage = new SystemMessage(this.qai_system_prompt_template);
|
||||||
|
|
||||||
|
resp = chatClient.prompt()
|
||||||
|
.messages(userMessage,systemMessage)
|
||||||
|
.advisors(advisor -> advisor
|
||||||
|
.param("chat_memory_conversation_id", this.scenarioExecution.getId()+this.qai_custom_memory_id)
|
||||||
|
.param("chat_memory_response_size", 100))
|
||||||
|
.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Usage usage = resp.chatResponse().getMetadata().getUsage();
|
Usage usage = resp.chatResponse().getMetadata().getUsage();
|
||||||
|
|
||||||
if (usage != null) {
|
if (usage != null) {
|
||||||
Long usedTokens = usage.getTotalTokens();
|
Long usedTokens = usage.getTotalTokens();
|
||||||
this.scenarioExecution.setUsedTokens(usedTokens);
|
this.scenarioExecution.setUsedTokens(usedTokens);
|
||||||
|
|||||||
Reference in New Issue
Block a user