File size: 1,855 Bytes
670dd87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1dec38c
670dd87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import re

from typing_extensions import override

from agency_swarm.agents import Agent
from agency_swarm.tools import FileSearch
from agency_swarm.util.validators import llm_validator


class Devid(Agent):
    def __init__(self):
        super().__init__(
            name="Devid",
            description="Devid is an AI software engineer capable of performing advanced coding tasks.",
            instructions="./instructions.md",
            files_folder="./files",
            schemas_folder="./schemas",
            tools=[FileSearch],
            tools_folder="./tools",
            validation_attempts=1,
            model="gpt-4o",
            temperature=0,
            max_prompt_tokens=25000,
        )

    @override
    def response_validator(self, message):
        pattern = r"(```)((.*\n){5,})(```)"

        if re.search(pattern, message):
            # take only first 100 characters
            raise ValueError(
                "You returned code snippet. Please never return code snippets to me. "
                "Use the FileWriter tool to write the code locally. Then, test it if possible. Continue."
            )

        llm_validator(
            statement="Verify whether the update from the AI Developer Agent confirms the task's "
            "successful completion. If the task remains unfinished, provide guidance "
            "within the 'reason' argument on the next steps the agent should take. For "
            "instance, if the agent encountered an error, advise the inclusion of debug "
            "statements for another attempt. Should the agent outline potential "
            "solutions or further actions, direct the agent to execute those plans. "
            "Message does not have to contain code snippets. Just confirmation.",
            client=self.client,
        )(message)

        return message