优化autogen的使用

这个提交包含在:
binary-husky
2023-10-23 01:56:18 +08:00
父节点 e2b3c47186
当前提交 27c4e3ef4f
共有 9 个文件被更改,包括 108 次插入54 次删除

查看文件

@@ -1,6 +1,7 @@
from toolbox import update_ui
from toolbox import CatchException, get_conf, markdown_convertion
from crazy_functions.crazy_utils import input_clipping
from crazy_functions.agent_fns.watchdog import WatchDog
from request_llm.bridge_all import predict_no_ui_long_connection
import threading, time
import numpy as np
@@ -8,32 +9,6 @@ from .live_audio.aliyunASR import AliyunASR
import json
import re
class WatchDog():
def __init__(self, timeout, bark_fn, interval=3, msg="") -> None:
self.last_feed = None
self.timeout = timeout
self.bark_fn = bark_fn
self.interval = interval
self.msg = msg
self.kill_dog = False
def watch(self):
while True:
if self.kill_dog: break
if time.time() - self.last_feed > self.timeout:
if len(self.msg) > 0: print(self.msg)
self.bark_fn()
break
time.sleep(self.interval)
def begin_watch(self):
self.last_feed = time.time()
th = threading.Thread(target=self.watch)
th.daemon = True
th.start()
def feed(self):
self.last_feed = time.time()
def chatbot2history(chatbot):
history = []