-
Notifications
You must be signed in to change notification settings - Fork 101
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 { | ||
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"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.