diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 6ff2d37..07ccbf0 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -408,15 +408,15 @@ INTENT_PROMPT = """你是一个开发产线意图分类器。分析用户输入 - chat: 开发相关的一般对话 - answer_question: 用户在回答角色Agent此前提出的问题(见「待客户回答的问题」) - out_of_scope: 完全无关软件开发 -- add_repo: 为当前项目添加代码仓库(如\"仓库地址 git@git.xxx:org/repo.git\"\"添加仓库\"\"关联仓库\") -- show_repos: 查看当前项目关联的仓库(如\"有哪些仓库\"\"显示仓库\") +- add_repo: 为当前项目添加代码仓库(如"仓库地址 git@git.xxx:org/repo.git""添加仓库""关联仓库"),从消息中提取repo_url和repo_name +- show_repos: 查看当前项目关联的仓库(如"有哪些仓库""显示仓库") 当前上下文:项目={ctx},迭代={iter} 待客户回答的问题(角色Agent执行任务中提出):{questions} 若用户消息是在回答上述问题之一,intent应为answer_question,并把回答内容填入description。 返回纯JSON(不要markdown包裹): -{"intent":"...","confidence":0.8,"project_name":"...","iteration_name":"...","title":"...","description":"...","source_path":"...","role":"...","missing_info":"...","question_id":"..."}""" +{"intent":"...","confidence":0.8,"project_name":"...","iteration_name":"...","title":"...","description":"...","source_path":"...","role":"...","missing_info":"...","question_id":"...","repo_url":"...","repo_name":"..."}""" async def _classify_intent(model_info, message, ctx, history_msgs, questions_text='无'): @@ -963,15 +963,12 @@ if action == 'send_message': if not pid: agent_reply = "请先切换到项目。" else: - import re - repo_url = '' - repo_name = '' - m = re.search(r'(git@[\w.]+:[\w./-]+\.git|https?://[\w./-]+\.git)', message_text) - if m: - repo_url = m.group(0) - repo_name = repo_url.rstrip('/').split('/')[-1].replace('.git', '') + repo_url = (intent.get('repo_url') or '').strip() + repo_name = (intent.get('repo_name') or '').strip() if not repo_url: agent_reply = "请提供 git 仓库地址,例如:仓库 git@git.opencomputing.cn:org/repo.git" + elif not repo_name: + repo_name = repo_url.rstrip('/').split('/')[-1].replace('.git', '') else: existing = await sor.sqlExe( "SELECT id FROM sd_project_repos WHERE project_id=${pid}$ AND repo_url=${url}$",