bugfix
This commit is contained in:
parent
f3c330ca7f
commit
3c09e9f195
@ -4,6 +4,7 @@ import json
|
|||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
import asyncio
|
import asyncio
|
||||||
import yaml
|
import yaml
|
||||||
|
import inspect
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import hashlib
|
import hashlib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -247,13 +248,32 @@ class IndustrialSkillEngine:
|
|||||||
context = await self._get_expanded_context(skill_name, user_prompt, context=context)
|
context = await self._get_expanded_context(skill_name, user_prompt, context=context)
|
||||||
|
|
||||||
# 决策:是直接回答还是执行脚本
|
# 决策:是直接回答还是执行脚本
|
||||||
decision = await self.llm(f'上下文: {context}\n问题: {user_prompt}\n决定动作:EXEC: {{"cmd": 找到的命令, "params": 找到的参数字典}} 或 ANSWER: <text> 或 REPLY: <question>')
|
decision = await self.llm(f'上下文: {context}\n问题: {user_prompt}\n决定动作:EXEC: {{"cmd": 找到的命令, "params": 找到的参数字典}} 或 ANSWER: <text> 或 REPLY: <question> 或 CALL: {{"function", "params":找到的参数字典}}')
|
||||||
output = {
|
output = {
|
||||||
"status": "PROCESSING",
|
"status": "PROCESSING",
|
||||||
"hint": f"决策完成:{decision=}"
|
"hint": f"决策完成:{decision=}"
|
||||||
}
|
}
|
||||||
await self.write_output(output)
|
await self.write_output(output)
|
||||||
if "REPLY" in decision:
|
if "CALL: " in decision:
|
||||||
|
st = decision[6:]
|
||||||
|
d = DictObject(**json.loads(st))
|
||||||
|
env = self.request._run_ns
|
||||||
|
f = env.get(d.function)
|
||||||
|
if f is None:
|
||||||
|
e = Exception(f'function({d.function} is not in env')
|
||||||
|
exception(f'{e}')
|
||||||
|
raise e
|
||||||
|
ret = ''
|
||||||
|
if inspect.iscoroutinefunction(f):
|
||||||
|
ret = await f(self.request, params_kw=d.params)
|
||||||
|
else:
|
||||||
|
ret = f(self.request, params_kw=d.params)
|
||||||
|
await self.write_output({
|
||||||
|
"status": "SUCCEEDED",
|
||||||
|
"content": ret
|
||||||
|
})
|
||||||
|
return
|
||||||
|
if "REPLY: " in decision:
|
||||||
sessionkey = getID()
|
sessionkey = getID()
|
||||||
await self.write_output({
|
await self.write_output({
|
||||||
"status": "REPLY",
|
"status": "REPLY",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user