fix custom ai

This commit is contained in:
robin
2024-02-01 20:57:36 +08:00
parent 6f968086c9
commit eda2401e8c
3 changed files with 9 additions and 15 deletions

View File

@ -66,7 +66,7 @@ public class FastChatAIEventSourceListener extends EventSourceListener {
log.info("Model={} is created at {}.", chatCompletions.getId(), log.info("Model={} is created at {}.", chatCompletions.getId(),
chatCompletions.getCreated()); chatCompletions.getCreated());
for (FastChatChoice choice : chatCompletions.getChoices()) { for (FastChatChoice choice : chatCompletions.getChoices()) {
FastChatMessage message = choice.getMessage(); FastChatMessage message = choice.getDelta();
if (message != null) { if (message != null) {
log.info("Index: {}, Chat Role: {}", choice.getIndex(), message.getRole()); log.info("Index: {}, Chat Role: {}", choice.getIndex(), message.getRole());
if (message.getContent() != null) { if (message.getContent() != null) {

View File

@ -30,8 +30,8 @@ public final class FastChatChoice {
/* /*
* The log probabilities model for tokens associated with this completions choice. * The log probabilities model for tokens associated with this completions choice.
*/ */
@JsonProperty(value = "message") @JsonProperty(value = "delta")
private FastChatMessage message; private FastChatMessage delta;
/* /*
* Reason for finishing * Reason for finishing
@ -44,18 +44,18 @@ public final class FastChatChoice {
* *
* @param text the text value to set. * @param text the text value to set.
* @param index the index value to set. * @param index the index value to set.
* @param message the message value to set * @param delta the message value to set
* @param finishReason the finishReason value to set. * @param finishReason the finishReason value to set.
*/ */
@JsonCreator @JsonCreator
private FastChatChoice( private FastChatChoice(
@JsonProperty(value = "text") String text, @JsonProperty(value = "text") String text,
@JsonProperty(value = "index") int index, @JsonProperty(value = "index") int index,
@JsonProperty(value = "message") FastChatMessage message, @JsonProperty(value = "delta") FastChatMessage delta,
@JsonProperty(value = "finish_reason") FastChatCompletionsFinishReason finishReason) { @JsonProperty(value = "finish_reason") FastChatCompletionsFinishReason finishReason) {
this.text = text; this.text = text;
this.index = index; this.index = index;
this.message = message; this.delta = delta;
this.finishReason = finishReason; this.finishReason = finishReason;
} }
@ -82,8 +82,8 @@ public final class FastChatChoice {
* *
* @return the logprobs value. * @return the logprobs value.
*/ */
public FastChatMessage getMessage() { public FastChatMessage getDelta() {
return this.message; return this.delta;
} }
/** /**

View File

@ -83,7 +83,7 @@ public class ConfigController {
saveChat2dbAIConfig(request); saveChat2dbAIConfig(request);
break; break;
case RESTAI: case RESTAI:
saveRestAIConfig(request); saveFastChatAIConfig(request);
break; break;
case AZUREAI: case AZUREAI:
saveAzureAIConfig(request); saveAzureAIConfig(request);
@ -330,12 +330,6 @@ public class ConfigController {
config.setModel(Objects.nonNull(azureDeployId.getData()) ? azureDeployId.getData().getContent() : ""); config.setModel(Objects.nonNull(azureDeployId.getData()) ? azureDeployId.getData().getContent() : "");
break; break;
case RESTAI: case RESTAI:
DataResult<Config> restAiUrl = configService.find(RestAIClient.REST_AI_URL);
DataResult<Config> restAiHttpMethod = configService.find(RestAIClient.REST_AI_STREAM_OUT);
config.setApiHost(Objects.nonNull(restAiUrl.getData()) ? restAiUrl.getData().getContent() : "");
config.setStream(Objects.nonNull(restAiHttpMethod.getData()) ? Boolean.valueOf(
restAiHttpMethod.getData().getContent()) : Boolean.TRUE);
break;
case FASTCHATAI: case FASTCHATAI:
DataResult<Config> fastChatApiKey = configService.find(FastChatAIClient.FASTCHAT_API_KEY); DataResult<Config> fastChatApiKey = configService.find(FastChatAIClient.FASTCHAT_API_KEY);
DataResult<Config> fastChatApiHost = configService.find(FastChatAIClient.FASTCHAT_HOST); DataResult<Config> fastChatApiHost = configService.find(FastChatAIClient.FASTCHAT_HOST);