diff --git a/agency_swarm/agents/Devid/tools/FileWriter.py b/agency_swarm/agents/Devid/tools/FileWriter.py index e300f35c..cee61d17 100644 --- a/agency_swarm/agents/Devid/tools/FileWriter.py +++ b/agency_swarm/agents/Devid/tools/FileWriter.py @@ -12,7 +12,7 @@ history = [ { - "role": "system", + "role": "user", "content": "As a top-tier software engineer focused on developing programs incrementally, you are entrusted with the creation or modification of files based on user requirements. It's imperative to operate under the assumption that all necessary dependencies are pre-installed and accessible, and the file in question will be deployed in an appropriate environment. Furthermore, it is presumed that all other modules or files upon which this file relies are accurate and error-free. Your output should be encapsulated within a code block, without specifying the programming language. Prior to embarking on the coding process, you must outline a methodical, step-by-step plan to precisely fulfill the requirements — no more, no less. It is crucial to ensure that the final code block is a complete file, without any truncation. This file should embody a flawless, fully operational program, inclusive of all requisite imports and functions, devoid of any placeholders, unless specified otherwise by the user.", }, ] @@ -58,7 +58,7 @@ class FileWriter(BaseTool): ) class ToolConfig: - one_call_at_a_time = True + one_call_at_a_time: bool = True def run(self): client = get_openai_client() @@ -84,7 +84,7 @@ def run(self): message += f"\nDocumentation: {self.documentation}" if self.mode == "modify": - message += f"\nThe existing file content is as follows:" + message += "\nThe existing file content is as follows:" try: with open(self.file_path, "r") as file: @@ -109,14 +109,14 @@ def run(self): if self.mode == "modify": resp = client.chat.completions.create( messages=messages, - model="gpt-4o", + model="o1-mini", temperature=0, prediction={"type": "content", "content": file_content}, ) else: resp = client.chat.completions.create( messages=messages, - model="gpt-4o", + model="o1-mini", temperature=0, ) @@ -144,7 +144,7 @@ def run(self): messages.append( { "role": "user", - "content": f"Error: Could not find the code block in the response. Please try again.", + "content": "Error: Could not find the code block in the response. Please try again.", } ) @@ -181,8 +181,7 @@ def validate_content(self, v): llm_validator( statement="Check if the code is bug-free. Code should be considered in isolation, with the understanding that it is part of a larger, fully developed program that strictly adheres to these standards of completeness and correctness. All files, elements, components, functions, or modules referenced within this snippet are assumed to exist in other parts of the project and are also devoid of any errors, ensuring a cohesive and error-free integration across the entire software solution. Certain placeholders may be present.", client=client, - model="gpt-4o", - temperature=0, + model="o1-mini", allow_override=False, )(v) diff --git a/agency_swarm/util/validators.py b/agency_swarm/util/validators.py index 86130f44..4faf1b28 100644 --- a/agency_swarm/util/validators.py +++ b/agency_swarm/util/validators.py @@ -11,7 +11,6 @@ class Validator(BaseModel): Validate if an attribute is correct and if not, return a new value with an error message """ - reason: str = Field( ..., description="Step-by-step reasoning why the attribute could be valid or not with a conclussion at the end.", @@ -69,20 +68,21 @@ class User(BaseTool): client = get_openai_client() def llm(v: str) -> str: + system_content = "You are a world class validation model, capable to determine if the following value is valid or not for a given statement. Before providing a response, you must think step by step about the validation." + user_content = f"Does `{v}` follow the rules: {statement}" + messages = [ + {"role": "system", "content": system_content}, + {"role": "user", "content": user_content} + ] + + if model.startswith("o1"): + messages = [{"role": "user", "content": system_content + "\n\n" + user_content}] + resp = client.beta.chat.completions.parse( response_format=Validator, - messages=[ - { - "role": "system", - "content": "You are a world class validation model, capable to determine if the following value is valid or not for a given statement. Before providing a response, you must think step by step about the validation.", - }, - { - "role": "user", - "content": f"Does `{v}` follow the rules: {statement}", - }, - ], + messages=messages, model=model, - temperature=temperature, + temperature=None if model.startswith("o1") else temperature, ) if resp.choices[0].message.refusal: