Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft PR for exception GPT analyze #537

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.microsoft.hydralab.center.service;

import com.microsoft.hydralab.center.openai.AzureOpenAIServiceClient;
import com.microsoft.hydralab.center.openai.ChatMessage;
import com.microsoft.hydralab.center.openai.ChatRequest;

import java.util.Arrays;

public class GptSuggestionService {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 请用UT来示例使用方法
  • 请增加模板文件来存放prompt

AzureOpenAIServiceClient client;
String exceptionAnalyzePrompt =
" I will give you a test with failure exception information with stack trace.\n" +
" I will give you a logcat log which records logs before this exception.\n" +
" Do 3 things for me:\n" +
" 1. Give me a summary about this exception.\n" +
" 2. Assume root cause of this exception.\n" +
" 3. Propose potential solution to fix this exception.\n";

Copy link
Member

@hydraxman hydraxman Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面的prompt是最终版的么?看起来也是过于简单。可以参考 https://www.bilibili.com/video/BV1jm4y1y7rA 学习prompt技巧

String ExceptionAnalyze(String exceptionStr, String logPath) {
client = new AzureOpenAIServiceClient(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不应该在方法中实例化这个类

"key", "deployment", "endpoint", "api-version");

String logContent = "";
ChatRequest req = new ChatRequest();
req.setMessages(Arrays.asList(
new ChatMessage("system", exceptionAnalyzePrompt),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么prompt通过system身份传入?

new ChatMessage("user", "exception: " + exceptionStr),
new ChatMessage("user", "log: " + logContent)
));
return client.chatCompletion(req);
}
}