refactor: rename default_model->model, add thinking_type support, fix pet urlopen error handling
This commit is contained in:
@@ -774,4 +774,4 @@ if __name__ == '__main__':
|
||||
pet = MacPet()
|
||||
pet.run()
|
||||
else:
|
||||
pet = WinPet()
|
||||
pet = WinPet('vita')
|
||||
|
||||
@@ -1222,7 +1222,7 @@ class ChatPanel(QWidget):
|
||||
|
||||
for idx, tc in enumerate(self.agent.llmclients):
|
||||
b = tc.backend
|
||||
name = f"{type(b).__name__}/{b.default_model}"
|
||||
name = f"{type(b).__name__}/{b.model}"
|
||||
is_current = idx == self.agent.llm_no
|
||||
|
||||
row = QWidget()
|
||||
@@ -1296,9 +1296,9 @@ class ChatPanel(QWidget):
|
||||
reply = backend.ask("你好", stream=False)
|
||||
text = str(reply).strip() if reply else ""
|
||||
ok = len(text) > 0 and not text.startswith("Error") and not text.startswith("[")
|
||||
print(f"[HealthCheck] Backend #{idx} {type(backend).__name__}/{backend.default_model}: {'OK' if ok else 'FAIL'} -> {text[:60]}")
|
||||
print(f"[HealthCheck] Backend #{idx} {type(backend).__name__}/{backend.model}: {'OK' if ok else 'FAIL'} -> {text[:60]}")
|
||||
except Exception as e:
|
||||
print(f"[HealthCheck] Backend #{idx} {type(backend).__name__}/{backend.default_model}: ERROR -> {e}")
|
||||
print(f"[HealthCheck] Backend #{idx} {type(backend).__name__}/{backend.model}: ERROR -> {e}")
|
||||
ok = False
|
||||
if hasattr(backend, 'raw_msgs') and backend.raw_msgs:
|
||||
backend.raw_msgs = [m for m in backend.raw_msgs if m.get("prompt") != "你好"]
|
||||
|
||||
@@ -48,7 +48,11 @@ def render_sidebar():
|
||||
pet_script = os.path.join(os.path.dirname(__file__), 'desktop_pet_v2.pyw')
|
||||
if not os.path.exists(pet_script): pet_script = os.path.join(os.path.dirname(__file__), 'desktop_pet.pyw')
|
||||
subprocess.Popen([sys.executable, pet_script], **kwargs)
|
||||
def _pet_req(q): threading.Thread(target=lambda: urlopen(f'http://127.0.0.1:51983/?{q}', timeout=2), daemon=True).start()
|
||||
def _pet_req(q):
|
||||
def _do():
|
||||
try: urlopen(f'http://127.0.0.1:51983/?{q}', timeout=2)
|
||||
except Exception: pass
|
||||
threading.Thread(target=_do, daemon=True).start()
|
||||
agent._pet_req = _pet_req
|
||||
if not hasattr(agent, '_turn_end_hooks'): agent._turn_end_hooks = {}
|
||||
def _pet_hook(ctx):
|
||||
|
||||
Reference in New Issue
Block a user