File size: 2,910 Bytes
03e71c3
1c98c9a
ef94807
 
1c98c9a
 
 
03e71c3
1c98c9a
c19d193
8fe992b
1c98c9a
 
9b5b26a
 
03e71c3
ef94807
1c98c9a
 
 
 
 
 
 
 
 
03e71c3
ef94807
9b5b26a
1c98c9a
03e71c3
1c98c9a
9b5b26a
1c98c9a
9b5b26a
1c98c9a
9b5b26a
03e71c3
ef94807
9b5b26a
1c98c9a
ef94807
1c98c9a
9b5b26a
1c98c9a
ef94807
 
9b5b26a
ef94807
8c01ffb
03e71c3
ef94807
1c98c9a
 
 
 
 
03e71c3
1c98c9a
 
8c01ffb
03e71c3
ef94807
1c98c9a
 
 
 
 
 
 
 
ae7a494
03e71c3
ef94807
1c98c9a
 
 
 
 
 
 
 
ae7a494
03e71c3
 
e121372
03e71c3
 
 
1c98c9a
13d500a
8c01ffb
03e71c3
861422e
 
1c98c9a
ef94807
03e71c3
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99


# app.py

# AI Agent Framework Imports
from smolagents import CodeAgent, HfApiModel, tool, load_tool

# Standard Library Imports (allowed)
import time
import yaml

# Final Answer and UI Handling
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI

# --------------------------------------------
# Tool: detect_ambiguity
@tool
def detect_ambiguity(content: str) -> str:
    """Checks for vague instructions and suggests clarifications.
    
    Args:
        content: Text to analyze.
    """
    return "Ambiguity detected. Click 'Is this ambiguous?' for help."

# --------------------------------------------
# Tool: explain_assumed_knowledge
@tool
def explain_assumed_knowledge(term: str) -> str:
    """Defines technical terms in a simple way.
    
    Args:
        term: The term to explain.
    """
    return f"Definition of '{term}': [Detailed beginner-friendly explanation here]"

# --------------------------------------------
# Tool: highlight_elements (modified to a placeholder)
@tool
def highlight_elements(step: str, element: str, auto_execute: bool = False) -> str:
    """(Placeholder) Highlights a UI element and optionally performs an action.
    
    Args:
        step: The current step in the guide.
        element: The UI element to highlight (as an identifier).
        auto_execute: If True, the agent would auto-click the element.
    """
    return "Highlight functionality is currently not available."

# --------------------------------------------
# Tool: explain_code_line
@tool
def explain_code_line(line: str) -> str:
    """Explains what a line of code does in simple terms.
    
    Args:
        line: The code line to explain.
    """
    return f"Explanation for: {line} [Insert explanation here]"

# --------------------------------------------
# Tool: teacher_box_query
@tool
def teacher_box_query(question: str) -> str:
    """Allows users to ask the AI questions while browsing.
    
    Args:
        question: User's query.
    """
    return f"AI Answer: [Response for '{question}']"

# --------------------------------------------
# Tool: toggle_auto_execution
@tool
def toggle_auto_execution(enable: bool) -> str:
    """Lets the user turn automatic navigation on or off.
    
    Args:
        enable: True for auto-mode, False for manual steps.
    """
    return "Auto-execution enabled." if enable else "Manual step-by-step mode enabled."

# --------------------------------------------
# Configure the AI Model.
model = HfApiModel(
    max_tokens=2096,                       # Maximum response length.
    temperature=0.5,                       # Controls response randomness.
    model_id='Qwen/Qwen2.5-Coder-32B-Instruct',  # Selected model.
    custom_role_conversions=None
)

# Load prompt templates from a YAML configuration file.
with open("prompts.yaml", 'r') as stream:
    prompt_templates = yaml.safe_load(stream)

#