1908
async function askDeepSeek(fullContext) {
1909
1910
1911
const requestBody =
{
1912
model: DEEPSEEK_CONFIG.MODEL,
1913
messages: [
1914
{
1915
role: "system",
1916
content: `你是一个专注的定积分助手。遵循下规则:
1917
1.
严格围绕当前上下文(题目或知识点)回答问题,无论用户提什么问题;
1918
2.
使用准确的LaTeX公式格式并必须正确使用双美元符号$$包装。例如:
1919
定积分:
$\\int_{a}^{b} f(x) dx$或#$$\\int_{a}^{b} f(x) dx$$
1920
不定积分: $\\int
f(x) dx$或#$$\\int f(x) dx$$
1921
3.
总是以用户当前所看的内容为基础进行回答,遇到无关问题,不要脱离上下文;
1922
4. 复杂公式推导时使用清晰的步骤展示`
1923
},
1924
{
1925
role: "user",
1926
content: fullContext
1927
}
1928
],
1929
temperature: 0.3,
1930
max_tokens: 1500
1931
};
1932
1933
try {
1934
const response = await fetch(DEEPSEEK_CONFIG.API_URL, {
1935
method: 'POST',
1936
headers: {
1937
'Content-Type':
'application/json',
1938
'Authorization':
`Bearer ${DEEPSEEK_CONFIG.API_KEY}`
1939
},
1940
body: JSON.stringify(requestBody)
1941
});
1942
const data =
await response.json();
1943
return data.choices[0].message.content;
1944
} catch (error) {
1945
console.error('DeepSeek API调用失败:', error);
1946
return '抱歉,AI助手暂时无法响应。';
1947
}
1948
}