fix:ai测试

上级 319121f1
...@@ -10,24 +10,23 @@ import java.util.List; ...@@ -10,24 +10,23 @@ import java.util.List;
public class Main { public class Main {
/** /**
* # 公司的key
* os.environ["OPENAI_API_KEY"] = '' * os.environ["OPENAI_API_KEY"] = ''
* os.environ["OPENAI_API_BASE"] = 'https://opencatgpt.openai.azure.com/' * os.environ["OPENAI_API_BASE"] = 'https://opencatgpt.openai.azure.com/'
* os.environ["OPENAI_API_TYPE"] = 'azure' * os.environ["OPENAI_API_TYPE"] = 'azure'
* os.environ["OPENAI_API_VERSION"] = '2023-05-15' * os.environ["OPENAI_API_VERSION"] = '2023-05-15'
*/ */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
final String question = "请解释一下java的多态";
// 装配请求集合 // 装配请求集合
List<AzureAIMessage> azureAiMessageList = new ArrayList<>(); List<AzureAIMessage> azureAiMessageList = new ArrayList<>();
AzureAIChatRequest azureAiChatRequest = new AzureAIChatRequest(); AzureAIChatRequest azureAiChatRequest = new AzureAIChatRequest();
AzureAIMessage azureAIMessage0 = new AzureAIMessage(); AzureAIMessage azureAIMessage0 = new AzureAIMessage();
azureAIMessage0.setRole(AzureAIRole.SYSTEM.toString()); azureAIMessage0.setRole(AzureAIRole.SYSTEM.toString());
azureAIMessage0.setContent("你是一个AI机器人,请根据提问进行回答"); azureAIMessage0.setContent("你是一个AI机器人,请根据提问进行详细回答");
azureAiMessageList.add(azureAIMessage0); azureAiMessageList.add(azureAIMessage0);
execute(azureAiMessageList, azureAiChatRequest, "请解释一下java的多态"); execute(azureAiMessageList, azureAiChatRequest, question);
} }
private static void execute(List<AzureAIMessage> azureAiMessageList, AzureAIChatRequest azureAiChatRequest private static void execute(List<AzureAIMessage> azureAiMessageList, AzureAIChatRequest azureAiChatRequest
...@@ -45,7 +44,7 @@ public class Main { ...@@ -45,7 +44,7 @@ public class Main {
azureAiChatRequest.setFrequencyPenalty(0); azureAiChatRequest.setFrequencyPenalty(0);
azureAiChatRequest.setStop(null); azureAiChatRequest.setStop(null);
AzureAIClient azureAIClient = new AzureAIClient("https://opencatgpt.openai.azure.com/", "", AzureAIClient azureAIClient = new AzureAIClient("https://opencatgpt.openai.azure.com/", "70846324f01c4e5cb3cc11da28a1e091",
"gpt-35-turbo", "2023-05-15"); "gpt-35-turbo", "2023-05-15");
AzureAIChatResponse azureAIChatResponse = azureAIClient.sendChatRequest(azureAiChatRequest); AzureAIChatResponse azureAIChatResponse = azureAIClient.sendChatRequest(azureAiChatRequest);
System.out.println(azureAIChatResponse.getChoices().get(0).getMessage()); System.out.println(azureAIChatResponse.getChoices().get(0).getMessage());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册