Skip to content

Commit

Permalink
Include AI model in plugin data
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Dec 20, 2023
1 parent 4d001fb commit 4f44cf9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/jasper/component/delta/Ai.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.theokanning.openai.OpenAiHttpException;
import com.theokanning.openai.completion.chat.ChatCompletionChoice;
import com.theokanning.openai.completion.chat.ChatMessage;
Expand Down Expand Up @@ -135,7 +137,9 @@ public void run(Ref ref) throws JsonProcessingException {
response.setComment(reply);
response.setTags(new ArrayList<>(List.of("plugin/debug", "+plugin/openai")));
}
response.setPlugin("+plugin/openai", objectMapper.convertValue(res.getUsage(), JsonNode.class));
var responsePlugin = objectMapper.convertValue(res.getUsage(), ObjectNode.class);
responsePlugin.set("model", TextNode.valueOf(config.model));
response.setPlugin("+plugin/openai", responsePlugin);
break;
} catch (Exception e) {
if (e instanceof OpenAiHttpException o) {
Expand Down

0 comments on commit 4f44cf9

Please sign in to comment.