refactor: improve comment formatting and streamline AI handling in findings processing
This commit is contained in:
+3
-4
@@ -29,12 +29,11 @@ export async function chat(systemPrompt, userContent) {
|
||||
}
|
||||
|
||||
export async function chatJSON(systemPrompt, userContent) {
|
||||
const text = await chat(systemPrompt, userContent);
|
||||
try {
|
||||
let text = await chat(systemPrompt, userContent);
|
||||
text = text.trim().replace(/^```[^\n]*\n?/, '').replace(/```$/, '').trim();
|
||||
return JSON.parse(text);
|
||||
return JSON.parse(text.trim().replace(/^```[^\n]*\n?/, '').replace(/```$/, '').trim());
|
||||
} catch (e) {
|
||||
console.log(` [LLM] 解析失敗: ${e.message}`);
|
||||
console.log(` [LLM] JSON 解析失敗: ${e.message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user