初始化批量执行器 Args: model_url: 模型服务地址 data_base_dir: 数据保存基目录
(self, model_url: str, data_base_dir: str = "data_uitars-test")
| 43 | """批量任务执行器""" |
| 44 | |
| 45 | def __init__(self, model_url: str, data_base_dir: str = "data_uitars-test"): |
| 46 | """初始化批量执行器 |
| 47 | |
| 48 | Args: |
| 49 | model_url: 模型服务地址 |
| 50 | data_base_dir: 数据保存基目录 |
| 51 | """ |
| 52 | self.model_url = model_url |
| 53 | self.data_base_dir = data_base_dir |
| 54 | |
| 55 | # 设置默认的模板路径(参考mobiagent) |
| 56 | current_file_path = Path(__file__).resolve() |
| 57 | current_dir = current_file_path.parent |
| 58 | self.default_template_path = current_dir.parent.parent / "utils" / "experience" / "templates-new.json" |
| 59 | |
| 60 | # 加载planner prompt模板 |
| 61 | self.planner_prompt_template = load_prompt("planner_oneshot.md") |
| 62 | |
| 63 | # 初始化模型客户端用于智能应用选择(使用专门的模型) |
| 64 | try: |
| 65 | self.app_selection_client = OpenAI( |
| 66 | api_key = API_KEY, |
| 67 | base_url = BASE_URL |
| 68 | ) |
| 69 | self.app_selection_model = "gemini-2.5-pro-preview-06-05" |
| 70 | logger.info(f"已连接到应用选择模型服务: http://ipads.chat.gpt:3006/v1") |
| 71 | except Exception as e: |
| 72 | logger.warning(f"应用选择模型客户端初始化失败,将只使用预定义包名映射: {e}") |
| 73 | self.app_selection_client = None |
| 74 | self.app_selection_model = None |
| 75 | |
| 76 | # 应用包名映射(从open_app.py参考) |
| 77 | self.app_packages = { |
| 78 | "微信": "com.tencent.mm", |
| 79 | "QQ": "com.tencent.mobileqq", |
| 80 | "新浪微博": "com.sina.weibo", |
| 81 | "饿了么": "me.ele", |
| 82 | "美团": "com.sankuai.meituan", |
| 83 | "bilibili": "tv.danmaku.bili", |
| 84 | "爱奇艺": "com.qiyi.video", |
| 85 | "腾讯视频": "com.tencent.qqlive", |
| 86 | "优酷": "com.youku.phone", |
| 87 | "淘宝": "com.taobao.taobao", |
| 88 | "京东": "com.jingdong.app.mall", |
| 89 | "携程": "ctrip.android.view", |
| 90 | "同城": "com.tongcheng.android", |
| 91 | "飞猪": "com.taobao.trip", |
| 92 | "去哪儿": "com.Qunar", |
| 93 | "华住会": "com.htinns", |
| 94 | "知乎": "com.zhihu.android", |
| 95 | "小红书": "com.xingin.xhs", |
| 96 | "QQ音乐": "com.tencent.qqmusic", |
| 97 | "网易云音乐": "com.netease.cloudmusic", |
| 98 | "酷狗音乐": "com.kugou.android", |
| 99 | "高德": "com.autonavi.minimap" |
| 100 | } |
| 101 | |
| 102 | def parse_json_response(self, response_str: str) -> dict: |
nothing calls this directly
no test coverage detected