mirror of
https://github.com/yuruotong1/autoMate.git
synced 2025-12-26 05:16:21 +08:00
closes #20
This commit is contained in:
parent
ae04b04b3f
commit
8ceb1437cd
@ -55,7 +55,7 @@ export default()=>{
|
||||
// if (content) await navigator.clipboard.writeText(content)
|
||||
window.api.closeWindow('search')
|
||||
const category_id = data.find((item)=>item.id == id)?.category_id
|
||||
window.api.openWindow('code', `/${category_id}/content/${id}/${search}`)
|
||||
window.api.openWindow('code', `/${category_id}/content/${id}`)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -84,28 +84,28 @@ export function Setting(){
|
||||
<Button
|
||||
onClick={async () => {
|
||||
const hide = message.loading('检测中...', 0);
|
||||
try {
|
||||
const res = await fetch(`${localServerBaseUrl}/llm`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(
|
||||
{ "messages": [{ "role": "user", "content": "hello" }],
|
||||
"llm_config": JSON.stringify(form.getFieldValue("llm"))}),
|
||||
}
|
||||
)
|
||||
hide();
|
||||
if (res.ok) {
|
||||
message.success('连接成功')
|
||||
} else {
|
||||
message.error(`连接失败,请检查配置信息是否正确:\n${res.statusText}`)
|
||||
const res = await fetch(`${localServerBaseUrl}/llm`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(
|
||||
{ "messages": [{ "role": "user", "content": "hello" }],
|
||||
"llm_config": JSON.stringify(form.getFieldValue("llm"))}),
|
||||
}
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error(`连接失败,请检查配置信息是否正确:\n${error}`)
|
||||
)
|
||||
hide();
|
||||
const jsonResponse = await res.json()
|
||||
if (jsonResponse.status === 0) {
|
||||
message.success(`连接成功!`)
|
||||
} else {
|
||||
message.error(
|
||||
<span style={{ whiteSpace: 'pre-line' }}>
|
||||
{`连接失败!\n${jsonResponse.content}`}
|
||||
</span>)
|
||||
}
|
||||
|
||||
}}>检查连接</Button>
|
||||
</div>
|
||||
<Form.Item name="format" label="格式" rules={[{ required: true }]}>
|
||||
|
||||
@ -16,6 +16,7 @@ def llm():
|
||||
else:
|
||||
config = json.loads(get_config())["llm"]
|
||||
messages = [{"role": "system", "content": code_prompt.substitute()}] + messages
|
||||
# 暂时没有strem
|
||||
if isStream:
|
||||
def generate():
|
||||
response = completion(messages=messages, stream=True, **config)
|
||||
@ -23,5 +24,8 @@ def llm():
|
||||
yield part.choices[0].delta.content or ""
|
||||
return Response(generate(), mimetype='text/event-stream')
|
||||
else:
|
||||
res = completion(messages=messages, **config)
|
||||
return {"content": res.choices[0].message.content}
|
||||
try:
|
||||
res = completion(messages=messages, **config)
|
||||
return {"content": res.choices[0].message.content, "status": 0}
|
||||
except Exception as e:
|
||||
return {"content": str(e), "status": 1}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user