File size: 2,967 Bytes
d32c69c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import dspy

class memory_summarize_agent(dspy.Signature):
    """
    You are an AI agent which helps summarize other agent responses and user-input. 
    Keep these instructions in mind:

    - Analyze the provided text.
    - Present the extracted details in bullet points:
      - User Query: The user query/goal summarized, with only important information retained
      - Agent: Include agent name
      - Stack_Used: All python packages used
      - Actions: What actions did the agent_name take, summarize them like "Agent visualized a line chart using plotly"
   
    """
    agent_response = dspy.InputField(desc="What the agents output, commentary and code")
    user_goal = dspy.InputField(desc= "User query or intended goal")
    summary = dspy.OutputField(desc ="The summary generated in the format requested")

class error_memory_agent(dspy.Signature):
    """
Prompt for error_summarize Agent:

Agent Name: error_summarize

Purpose: To generate a concise summary of an error in Python code and provide a clear correction, along with relevant metadata and user query information. This summary will help in understanding the error and applying the correction.

Input Data:

Incorrect Python Code: (A snippet of code that produced an error)
Meta Data:
Agent Name: (Name of the agent that processed the code)
Agent Version: (Version of the agent that processed the code)
Timestamp: (When the error occurred)
User Query: (The query or task that led to the incorrect code execution)
Human-Defined Correction: (The corrected code or solution provided by a human expert)
Processing Instructions:

Error Analysis:

Analyze the incorrect Python code to determine the type of error and its cause.
Summary Creation:

Generate a brief summary of the error, highlighting the key issue in the code.
Provide a short explanation of the correction that resolves the issue.
Output Formatting:

Format the summary to include:
Error Summary: A concise description of the error.
Correction: A brief explanation of how to correct the error.
Integration:

Ensure the summary is clear and informative for future reference.
Output Data:

Error Summary:
Error Summary: (Brief description of the error)
Correction: (Concise explanation of the fix)
Example Output:

Error Summary: The IndexError occurred because the code attempted to access an element at an index that is out of range for the list.
Correction: Ensure the index is within the bounds of the list. For example, use if index < len(my_list): to check the index before accessing the list element. 
    """
    incorrect_code = dspy.InputField(desc="Error causing code")
    error_metadata = dspy.InputField(desc="The description of the error generated, with user/agent information for context")
    correction = dspy.InputField(desc="Correction suggested by AI or done manually by human")
    summary = dspy.OutputField(desc="The description which must contain information about the error and how to correct it")