mirror of
https://gitee.com/agents-flex/agents-flex.git
synced 2024-11-29 18:38:17 +08:00
This commit is contained in:
parent
d98c059ffb
commit
bd82f97d33
@ -17,56 +17,68 @@
|
||||
package com.agentsflex.core.llm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class LlmConfig implements Serializable {
|
||||
|
||||
private String model;
|
||||
private String model;
|
||||
|
||||
private String endpoint;
|
||||
private String endpoint;
|
||||
|
||||
private String apiKey;
|
||||
private String apiKey;
|
||||
|
||||
private String apiSecret;
|
||||
private String apiSecret;
|
||||
|
||||
private boolean debug;
|
||||
private boolean debug;
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
private Consumer<Map<String, String>> headersConfig;
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public void setEndpoint(String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
public void setEndpoint(String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public String getApiSecret() {
|
||||
return apiSecret;
|
||||
}
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public void setApiSecret(String apiSecret) {
|
||||
this.apiSecret = apiSecret;
|
||||
}
|
||||
public String getApiSecret() {
|
||||
return apiSecret;
|
||||
}
|
||||
|
||||
public void setApiSecret(String apiSecret) {
|
||||
this.apiSecret = apiSecret;
|
||||
}
|
||||
|
||||
public Consumer<Map<String, String>> getHeadersConfig() {
|
||||
return headersConfig;
|
||||
}
|
||||
|
||||
public void setHeadersConfig(Consumer<Map<String, String>> headersConfig) {
|
||||
this.headersConfig = headersConfig;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import com.alibaba.fastjson.JSONPath;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class OpenAiLlm extends BaseLlm<OpenAiLlmConfig> {
|
||||
|
||||
@ -72,6 +73,11 @@ public class OpenAiLlm extends BaseLlm<OpenAiLlmConfig> {
|
||||
headers.put("Content-Type", "application/json");
|
||||
headers.put("Authorization", "Bearer " + getConfig().getApiKey());
|
||||
|
||||
Consumer<Map<String, String>> headersConfig = config.getHeadersConfig();
|
||||
if (headersConfig != null) {
|
||||
headersConfig.accept(headers);
|
||||
}
|
||||
|
||||
String payload = OpenAiLLmUtil.promptToPayload(prompt, config, options, false);
|
||||
String endpoint = config.getEndpoint();
|
||||
String response = httpClient.post(endpoint + "/v1/chat/completions", headers, payload);
|
||||
|
Loading…
Reference in New Issue
Block a user