add some logger
This commit is contained in:
@@ -433,31 +433,20 @@ class HSAEngineClient(ASEngineClient):
|
||||
super().__init__(server_url, namespace, id)
|
||||
self.chatmanager = chatmanager
|
||||
def loadmarkdown(self, fmd, fmdp, fsp):
|
||||
# 保存app实例以便在回调中使用
|
||||
app = self.chatmanager.app
|
||||
|
||||
def log_info(message):
|
||||
"""安全的日志记录函数,确保在任何线程中都能使用"""
|
||||
try:
|
||||
with app.app_context():
|
||||
app.logger.info(message)
|
||||
except Exception as e:
|
||||
print(f"Log error: {e}")
|
||||
print(f"Message: {message}")
|
||||
|
||||
now = time.time()
|
||||
# 并行发送三个消息,获取事件对象和ack_id
|
||||
event1, ack_id1 = self.send_text('markdown-in', fmd, self.id, wait_for_ack=True, return_event=True)
|
||||
event2, ack_id2 = self.send_text('markdown-prompt-in', fmdp, self.id, wait_for_ack=True, return_event=True)
|
||||
event3, ack_id3 = self.send_text('score-prompt-in', fsp, self.id, wait_for_ack=True, return_event=True)
|
||||
log_info(f"Load markdown time cost: {time.time() - now}")
|
||||
print(f"Load markdown time cost: {time.time() - now}")
|
||||
now = time.time()
|
||||
# 等待所有事件完成
|
||||
timeout = 5 # 超时时间
|
||||
success1 = event1.wait(timeout=timeout)
|
||||
success2 = event2.wait(timeout=timeout)
|
||||
success3 = event3.wait(timeout=timeout)
|
||||
log_info(f"Wait markdown time cost: {time.time() - now}")
|
||||
print(f"Wait markdown time cost: {time.time() - now}")
|
||||
now = time.time()
|
||||
# 清理ACK事件
|
||||
if ack_id1 in self.ack_events:
|
||||
|
||||
@@ -129,8 +129,8 @@ class ChatManager:
|
||||
self.chapter_chain_now = chapter_index
|
||||
self.chapter_chain[chapter_index].Focus()
|
||||
|
||||
def load_next_chapter(self):
|
||||
print(f"now load next chapter markdown {self.chapter_chain_now}")
|
||||
def load_now_chapter(self):
|
||||
print(f"now load now chapter markdown {self.chapter_chain_now}")
|
||||
self.ase_client.loadmarkdown(self.chapter_chain[self.chapter_chain_now].chapter, self.chapter_chain[self.chapter_chain_now].chapter_prompt, self.chapter_chain[self.chapter_chain_now].score_prompt)
|
||||
self.load_code_in_markdown()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user