mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
Fix linting
This commit is contained in:
@@ -28,41 +28,48 @@ class CodeFlowAgentActionProposal(BaseModel):
|
||||
immediate_plan: str = Field(
|
||||
...,
|
||||
description="We will be running an iterative process to execute the plan, "
|
||||
"Write the partial / immediate plan to execute your plan as detailed and efficiently as possible without the help of the reasoning/intelligence. "
|
||||
"The plan should describe the output of the immediate plan, so that the next iteration can be executed by taking the output into account. "
|
||||
"Try to do as much as possible without making any assumption or uninformed guesses. Avoid large output at all costs!!!"
|
||||
"Format: Objective[Objective of this iteration, explain what's the use of this iteration for the next one] Plan[Plan that does not require any reasoning or intelligence] Output[Output of the plan / should be small, avoid whole file output]",
|
||||
)
|
||||
"Write the partial / immediate plan to execute your plan as detailed and "
|
||||
"efficiently as possible without the help of the reasoning/intelligence. "
|
||||
"The plan should describe the output of the immediate plan, so that the next "
|
||||
"iteration can be executed by taking the output into account. "
|
||||
"Try to do as much as possible without making any assumption or uninformed "
|
||||
"guesses. Avoid large output at all costs!!!\n"
|
||||
"Format: Objective[Objective of this iteration, explain what's the use of this "
|
||||
"iteration for the next one] Plan[Plan that does not require any reasoning or "
|
||||
"intelligence] Output[Output of the plan / should be small, avoid whole file "
|
||||
"output]", )
|
||||
python_code: str = Field(
|
||||
...,
|
||||
description=(
|
||||
"Write the fully-functional Python code of the immediate plan. The output will be an `async def main() -> str` function of the immediate plan that return the string output, the output will be passed into the LLM context window so avoid returning the whole content!. "
|
||||
..., description=(
|
||||
"Write the fully-functional Python code of the immediate plan. "
|
||||
"The output will be an `async def main() -> str` function of the immediate "
|
||||
"plan that return the string output, the output will be passed into the "
|
||||
"LLM context window so avoid returning the whole content!. "
|
||||
"Use ONLY the listed available functions and built-in Python features. "
|
||||
"Leverage the given magic functions to implement function calls for which the "
|
||||
"arguments can't be determined yet. Example:`async def main() -> str:\n return await provided_function('arg1', 'arg2').split('\\n')[0]`"
|
||||
),
|
||||
)
|
||||
"Leverage the given magic functions to implement function calls for which "
|
||||
"the arguments can't be determined yet. "
|
||||
"Example:`async def main() -> str:\n"
|
||||
" return await provided_function('arg1', 'arg2').split('\\n')[0]`"), )
|
||||
|
||||
|
||||
FINAL_INSTRUCTION: str = (
|
||||
"You have to give the answer in the from of JSON schema specified previously. "
|
||||
"For the `python_code` field, you have to write Python code to execute your plan as efficiently as possible. "
|
||||
"Your code will be executed directly without any editing: "
|
||||
"if it doesn't work you will be held responsible. "
|
||||
"For the `python_code` field, you have to write Python code to execute your plan "
|
||||
"as efficiently as possible. Your code will be executed directly without any "
|
||||
"editing, if it doesn't work you will be held responsible. "
|
||||
"Use ONLY the listed available functions and built-in Python features. "
|
||||
"Do not make uninformed assumptions (e.g. about the content or format of an unknown file). "
|
||||
"Leverage the given magic functions to implement function calls for which the "
|
||||
"arguments can't be determined yet. Reduce the amount of unnecessary data passed into "
|
||||
"these magic functions where possible, because magic costs money and magically "
|
||||
"processing large amounts of data is expensive. "
|
||||
"If you think are done with the task, you can simply call "
|
||||
"Do not make uninformed assumptions "
|
||||
"(e.g. about the content or format of an unknown file). Leverage the given magic "
|
||||
"functions to implement function calls for which the arguments can't be determined "
|
||||
"yet. Reduce the amount of unnecessary data passed into these magic functions "
|
||||
"where possible, because magic costs money and magically processing large amounts "
|
||||
"of data is expensive. If you think are done with the task, you can simply call "
|
||||
"finish(reason='your reason') to end the task, "
|
||||
"a function that has one `finish` command, don't mix finish with other functions! "
|
||||
"If you still need to do other functions, let the next cycle execute the `finish` function. "
|
||||
"If you still need to do other functions, "
|
||||
"let the next cycle execute the `finish` function. "
|
||||
"Avoid hard-coding input values as input, and avoid returning large outputs. "
|
||||
"The code that you have been executing in the past cycles can also be buggy, "
|
||||
"so if you see undesired output, you can always try to re-plan, and re-code. "
|
||||
)
|
||||
"so if you see undesired output, you can always try to re-plan, and re-code. ")
|
||||
|
||||
|
||||
class CodeFlowAgentPromptStrategy(PromptStrategy):
|
||||
|
||||
@@ -29,7 +29,8 @@ _RESPONSE_INTERFACE_NAME = "AssistantResponse"
|
||||
class AssistantThoughts(ModelWithSummary):
|
||||
past_action_summary: str = Field(
|
||||
...,
|
||||
description="Summary of the last action you took, if there is none, you can leave it empty",
|
||||
description="Summary of the last action you took, if there is none, "
|
||||
"you can leave it empty",
|
||||
)
|
||||
observations: str = Field(
|
||||
..., description="Relevant observations from your last actions (if any)"
|
||||
@@ -39,7 +40,8 @@ class AssistantThoughts(ModelWithSummary):
|
||||
self_criticism: str = Field(..., description="Constructive self-criticism")
|
||||
plan: list[str] = Field(
|
||||
...,
|
||||
description="Short list that conveys the long-term plan, considering the progress on your task so far",
|
||||
description="Short list that conveys the long-term plan, "
|
||||
"considering the progress on your task so far",
|
||||
)
|
||||
speak: str = Field(..., description="Summary of thoughts, to say to user")
|
||||
|
||||
|
||||
@@ -51,13 +51,12 @@ async def test_code_flow_build_prompt():
|
||||
|
||||
prompt = str(
|
||||
prompt_strategy.build_prompt(
|
||||
task="Figure out from file1.csv and file2.csv how much was spent on utilities",
|
||||
task="Figure out from file.csv how much was spent on utilities",
|
||||
messages=[],
|
||||
ai_profile=ai_profile,
|
||||
ai_directives=ai_directives,
|
||||
commands=commands,
|
||||
)
|
||||
)
|
||||
))
|
||||
assert "DummyGPT" in prompt
|
||||
assert "async def web_search(query: str, num_results: int = None)" in prompt
|
||||
|
||||
@@ -79,7 +78,7 @@ async def test_code_flow_parse_response():
|
||||
],
|
||||
"speak": "This is what the AI would say."
|
||||
},
|
||||
"immediate_plan": "Objective[objective1] Plan[plan1] Output[out1]",
|
||||
"immediate_plan": "Objective[objective1] Plan[plan1] Output[out1]",
|
||||
"python_code": "async def main() -> str:\n return 'You passed the test.'",
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@ async def test_code_validation():
|
||||
},
|
||||
return_type="str",
|
||||
return_desc="Information matching the query",
|
||||
function_desc="Read a webpage and return the information matching the query",
|
||||
function_desc="Read a webpage and return the info matching the query",
|
||||
is_async=True,
|
||||
),
|
||||
"web_search": FunctionDef(
|
||||
@@ -34,7 +34,7 @@ async def test_code_validation():
|
||||
arg_descs={},
|
||||
return_type="str",
|
||||
return_desc="Answer in the text format",
|
||||
function_desc="Get the number of contributors to the autogpt github repository",
|
||||
function_desc="Get the num of contributors to the autogpt github repo",
|
||||
is_async=False,
|
||||
),
|
||||
},
|
||||
@@ -47,7 +47,7 @@ def crawl_info(url: str, query: str) -> str | None:
|
||||
if info:
|
||||
return info
|
||||
|
||||
urls = await read_webpage(url, "Find (if any) possible relevant URLS to crawl for finding the info of " + query + " return list of URLs separated by newline")
|
||||
urls = await read_webpage(url, "autogpt github contributor page")
|
||||
for url in urls.split('\\n'):
|
||||
info = await crawl_info(url, query)
|
||||
if info:
|
||||
@@ -59,7 +59,7 @@ def hehe():
|
||||
return 'hehe'
|
||||
|
||||
def main() -> str:
|
||||
query = "Find the number of contributors to the autogpt github repository, or if any, list of urls that can be crawled to find the number of contributors"
|
||||
query = "Find the number of contributors to the autogpt github repository"
|
||||
for title, url in ("autogpt github contributor page"):
|
||||
info = await crawl_info(url, query)
|
||||
if info:
|
||||
|
||||
Reference in New Issue
Block a user