Files
multi-agent-bidding/app/__pycache__/worker.cpython-310.pyc
T

63 lines
5.2 KiB
Plaintext
Raw Normal View History

2026-04-12 01:55:34 +08:00
o
Ô‰ÚiSã@s˜dZddlZddlZddlmZmZmZmZddlm Z m
Z
m Z m Z ddl
mZddlmZmZGdd „d ƒZGd
d d ƒZdd ed
edefddZdS)u4
执行Agent (Worker) - ç«žæ ‡ä»»åŠ¡ã€æ‰§è¡Œäº¤ä»˜
éN)ÚDictÚListÚOptionalÚAnyé)ÚTaskÚBidÚ ExecutionÚ AgentProfile)Ú TaskBoard)Ú LLMClientÚdefault_clientc@sdeZdZdZ ddededefddZded e e
fd
d Z ded e
d e fd
dZ
d efddZdS)ÚWorkeru 执行AgentNÚprofileÚ
task_boardÚ
llm_clientcCs,||_||_|p t|_|j |¡i|_dS©N)rrr
ÚllmÚregister_agentÚ
current_tasks)Úselfrrr©rúL/home/xian/.openclaw/workspace-coder/works/multi-agent-bidding/app/worker.pyÚ__init__s

 
zWorker.__init__ÚtaskÚreturnc Cs z<|j | ¡|j ¡¡}t|j|jjt| dd¡ƒt| dd¡ƒt| dd¡ƒ| dd¡| dg¡| d g¡d
}|WSt yO}zWYd }~d Sd }~ww) uˆ
为任务竞标
Args:
task: 任务
Returns:
竞标书或None
Úcapability_matchgà?Úestimated_timeé<Ú
confidenceÚapproachÚÚ
prerequisitesÚalternative_approaches)Útask_idÚagent_idrrrr r"r#N)
rÚ generate_bidÚto_dictrrÚidÚfloatÚgetÚintÚ Exception)rrÚbid_dataÚbidÚerrrÚ bid_for_task"s"



ø ÿzWorker.bid_for_taskr.c
CsBt|j|jj|jdd}||j|j<|j |¡zz3|j | ¡|j ¡}d|_
t   ¡|_ | 
d¡p2||_|j |¡|j |j}|jj|jjd|dWn5ty}z)d|_
t   ¡|_ t|ƒ|_|j |¡|jj|jjdt   ¡|jdWYd }~nd }~wwW|j |jd ¡|SW|j |jd ¡|S|j |jd ¡w)
执行任务
Args:
task: 任务
bid: 竞标书
Returns:
Execution对象
Úrunning)r$r%Úbid_idÚstatusÚ completedÚresultT)ÚsuccessÚdurationÚfailedFN)r r(rrrÚ
add_executionrÚ execute_taskr'r r3ÚtimeÚend_timer*r5Úupdate_executionÚ
start_timeÚupdate_agent_statsr,ÚstrÚerrorÚpop)rrr.Ú executionr5r7r/rrrr:BsN ü  
  
ý

  ýøú÷þzWorker.execute_taskcCs&|j ¡t|jƒt|jƒ|jjkdœS)u获åWorker状æ€)rrÚis_busy)rr'ÚlenrÚmax_concurrent_tasks©rrrrÚ
get_status|sýzWorker.get_statusr)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r
r r rrrrr0r r:rrHrrrrr
süþý
ü :rc@speZdZdZdefddZddededefd d
Z d e