rc-plugin/utils/llm-util.js

40 lines
1.0 KiB
JavaScript

import { retryFetch } from "./common.js";
import { PearAPI_CRAWLER, PearAPI_DEEPSEEK } from "../constants/tools.js";
/**
* LLM 爬虫
* @param summaryLink
* @returns {Promise<string>}
*/
export async function llmRead(summaryLink) {
const llmCrawler = await retryFetch(PearAPI_CRAWLER.replace("{}", summaryLink));
return (await llmCrawler.json())?.data;
}
/**
* DeepSeek对话
* @param content
* @param prompt
* @returns {Promise<string>}
*/
export async function deepSeekChat(content, prompt) {
const deepseekFreeSummary = await fetch(PearAPI_DEEPSEEK, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
"messages": [
{
"role": "system",
"content": prompt
},
{
"role": "user",
"content": content,
}]
}),
});
return (await deepseekFreeSummary.json())?.message;
}