mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 04:57:18 +08:00
update fewshot
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
Recording manager for autoMate
|
||||
Handles recording and demonstration functionality
|
||||
"""
|
||||
import yaml
|
||||
from auto_control.agent.few_shot_generate_agent import FewShotGenerateAgent
|
||||
from util.auto_control import AutoControl
|
||||
from ui.recording_panel import RecordingIndicator
|
||||
from ui.demonstration_panel import DemonstrationPanel
|
||||
from PyQt6.QtCore import QThread, pyqtSignal
|
||||
import time
|
||||
|
||||
import os
|
||||
class ActionListenThread(QThread):
|
||||
finished_signal = pyqtSignal()
|
||||
|
||||
@@ -81,4 +82,16 @@ class RecordingManager:
|
||||
"""process all recorded actions"""
|
||||
# get all collected actions
|
||||
recorded_actions = self.action_listen.auto_list
|
||||
print("recorded_actions: ", recorded_actions)
|
||||
few_shot_generate_agent = FewShotGenerateAgent()
|
||||
few_shot = few_shot_generate_agent(recorded_actions)
|
||||
# Save few shot examples to ~/.automate directory
|
||||
|
||||
# Create .automate directory if not exists
|
||||
automate_dir = os.path.expanduser("~/.automate")
|
||||
if not os.path.exists(automate_dir):
|
||||
os.makedirs(automate_dir)
|
||||
# Save few shot examples
|
||||
few_shot_path = os.path.join(automate_dir, "few_shot.yaml")
|
||||
with open(few_shot_path, "w", encoding="utf-8") as f:
|
||||
yaml.dump(few_shot, f, allow_unicode=True)
|
||||
print(f"Few shot examples saved to {few_shot_path}")
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
"""
|
||||
Recording indicator panel for autoMate
|
||||
"""
|
||||
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QApplication
|
||||
from PyQt6.QtCore import Qt, QPoint
|
||||
|
||||
class RecordingIndicator(QWidget):
|
||||
def __init__(self, parent=None, stop_callback=None):
|
||||
super().__init__(parent, Qt.WindowType.WindowStaysOnTopHint | Qt.WindowType.FramelessWindowHint)
|
||||
self.stop_callback = stop_callback
|
||||
self.setup_ui()
|
||||
self.position_to_bottom_right()
|
||||
|
||||
def setup_ui(self):
|
||||
layout = QVBoxLayout()
|
||||
|
||||
# Recording status label
|
||||
self.status_label = QLabel("Recording in progress")
|
||||
self.status_label.setStyleSheet("color: red; font-weight: bold;")
|
||||
layout.addWidget(self.status_label)
|
||||
|
||||
# Stop button
|
||||
self.stop_button = QPushButton("Stop Recording")
|
||||
self.stop_button.clicked.connect(self.on_stop_clicked)
|
||||
layout.addWidget(self.stop_button)
|
||||
|
||||
self.setLayout(layout)
|
||||
self.resize(200, 100)
|
||||
self.setStyleSheet("background-color: #f0f0f0; border: 1px solid #999;")
|
||||
|
||||
def position_to_bottom_right(self):
|
||||
screen = QApplication.primaryScreen()
|
||||
screen_geometry = screen.availableGeometry()
|
||||
window_geometry = self.frameGeometry()
|
||||
position = QPoint(
|
||||
screen_geometry.width() - window_geometry.width() - 20,
|
||||
screen_geometry.height() - window_geometry.height() - 20
|
||||
)
|
||||
self.move(position)
|
||||
|
||||
def on_stop_clicked(self):
|
||||
if self.stop_callback:
|
||||
self.stop_callback()
|
||||
@@ -1,9 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
|
||||
from auto_control.agent.few_shot_generate_agent import FewShotGenerateAgent
|
||||
# Add the project root directory to Python path
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from pynput import mouse, keyboard
|
||||
@@ -33,7 +30,6 @@ class ActionRecord:
|
||||
class AutoControl:
|
||||
def __init__(self):
|
||||
self.auto_list = []
|
||||
self.tmp_auto_list = []
|
||||
self.text_buffer = [] # Buffer for collecting continuous text input
|
||||
self.last_key_time = 0 # Timestamp of last keypress
|
||||
self.input_timeout = 1.0 # Input timeout in seconds
|
||||
@@ -170,8 +166,7 @@ class AutoControl:
|
||||
"""Stop listening and prepare data for LLM analysis"""
|
||||
self.keyboard_listener.stop()
|
||||
self.mouse_listener.stop()
|
||||
few_shot_generate_agent = FewShotGenerateAgent()
|
||||
return few_shot_generate_agent(self.auto_list)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
auto_control = AutoControl()
|
||||
|
||||
Reference in New Issue
Block a user