MCPcopy Create free account
hub / github.com/Tencent/digitalhuman / look_up_cache

Method look_up_cache

SWF/src/base.py:331–349  ·  view source on GitHub ↗

Look up task output in cache

(self, task_id, agent_name)

Source from the content-addressed store, hash-verified

329 return json.load(open(self.cache_file, 'r'))
330
331 def look_up_cache(self, task_id, agent_name) -> Response:
332 """
333 Look up task output in cache
334 """
335 model_name = self.map[agent_name]
336 responses = self.cache.get(task_id, {}).get(model_name, None)
337 idx = random.randint(0, 100000) % len(responses)
338 response = responses[idx]
339 if response is None:
340 return None
341 agent_resp = Response(
342 role=response['role'],
343 raw=response['raw'],
344 content=response['content'],
345 end=response['end'],
346 usage=response['usage'],
347 cost=0
348 )
349 return agent_resp
350
351 def get_env_feedback(self, reward_fn, response, name, task) -> dict:
352 """

Callers 3

runMethod · 0.95
_task_assignMethod · 0.80
_task_assignMethod · 0.80

Calls 2

ResponseClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected