mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-28 16:07:46 +00:00
faa2fb03ad
* fix isort & black & toml-sort & sphinx error * fix ci error * fix ci error * add comments * Update Makefile * change sphinx build command * add auto-lint * add black args * format with black * Auto Linting document * fix ci error --------- Co-authored-by: you-n-g <you-n-g@users.noreply.github.com> Co-authored-by: Young <afe.young@gmail.com>
34 lines
769 B
Python
34 lines
769 B
Python
"""
|
|
The output of a agent is very important.
|
|
|
|
We think this part can be shared.
|
|
"""
|
|
import re
|
|
from abc import abstractclassmethod
|
|
from typing import Any
|
|
|
|
from rdagent.utils.agent.tpl import T
|
|
|
|
|
|
class AgentOut:
|
|
@abstractclassmethod
|
|
def get_spec(cls, **context: Any) -> str:
|
|
raise NotImplementedError(f"Please implement the `get_spec` method")
|
|
|
|
@classmethod
|
|
def extract_output(cls, resp: str) -> Any:
|
|
raise resp
|
|
|
|
|
|
class PythonAgentOut(AgentOut):
|
|
@classmethod
|
|
def get_spec(cls):
|
|
return T(".tpl:PythonAgentOut").r()
|
|
|
|
@classmethod
|
|
def extract_output(cls, resp: str):
|
|
match = re.search(r".*```[Pp]ython\n(.*)\n```.*", resp, re.DOTALL)
|
|
if match:
|
|
code = match.group(1)
|
|
return code
|