diff --git a/apps/llm/patterns/recommend.py b/apps/llm/patterns/recommend.py index 79978a505143a7c6416215c2369640f6dc1b9629..7d33a3dde79660e739a61fc87afaf73fe8a93cc8 100644 --- a/apps/llm/patterns/recommend.py +++ b/apps/llm/patterns/recommend.py @@ -15,18 +15,18 @@ class Recommend(CorePattern): """系统提示词""" user_prompt: str = r""" - 根据对话上文、工具描述和用户倾向,生成预测问题。 + 根据上面的历史对话、结合给出的工具描述和用户倾向,生成预测问题。 信息说明: - - [Empty]标识空信息,如“工具描述: [Empty]”表示当前未使用工具。 + - [Empty]的含义是“空信息”,如“工具描述: [Empty]”表示当前未使用工具。 - 历史提问信息为背景参考作用,最多提供4条。 生成时需要遵循的要求: 1. 从用户角度生成预测问题。 2. 预测问题应为疑问句或祈使句,必须少于30字。 - 3. 预测问题应优先贴合工具描述,特别是工具描述与背景或倾向无关时。 - 5. 预测问题必须精简,不得输出非必要信息,不得输出除问题以外的文字。 - 6. 预测问题不得与“用户历史提问”重复或相似。 + 3. 预测问题应优先贴合工具描述,特别是工具描述与历史对话或用户倾向无关时。 + 4. 预测问题必须精简,不得输出非必要信息,不得输出除问题以外的文字。 + 5. 预测问题不得与“用户历史提问”重复或相似。 ==以下是一个例子== 工具描述:调用API,查询天气数据 @@ -79,11 +79,10 @@ class Recommend(CorePattern): user_input = self.user_prompt.format( action_description=action_description, history_questions=history_questions, - recent_question=kwargs["recent_question"], user_preference=user_preference, ) - messages = [ + messages = kwargs["recent_question"] + [ {"role": "system", "content": self.system_prompt}, {"role": "user", "content": user_input}, ] diff --git a/apps/llm/reasoning.py b/apps/llm/reasoning.py index bc32b345dcab9523dccc52a93da52109d79b7d52..64daccdedaa31fad7d68187dc9e33281cf330a0e 100644 --- a/apps/llm/reasoning.py +++ b/apps/llm/reasoning.py @@ -99,8 +99,8 @@ class ReasoningLLM(metaclass=Singleton): is_reasoning = True else: for token in REASONING_BEGIN_TOKEN: - if token in chunk.choices[0].delta.content or "": - reason = "" + chunk.choices[0].delta.content or "" + if token == (chunk.choices[0].delta.content or ""): + reason = "" reasoning_type = "tokens" is_reasoning = True break @@ -108,6 +108,10 @@ class ReasoningLLM(metaclass=Singleton): # 当前已经不是第一个Chunk了 is_first_chunk = False + # 当前是正常问答 + if not is_reasoning: + text = chunk.choices[0].delta.content or "" + # 当前处于推理状态 if not is_first_chunk and is_reasoning: # 如果推理内容用特殊参数传递 @@ -119,25 +123,20 @@ class ReasoningLLM(metaclass=Singleton): else: is_reasoning = False reason = "" - text = chunk.choices[0].delta.content or "" # 如果推理内容用特殊token传递 elif reasoning_type == "tokens": # 结束推理 for token in REASONING_END_TOKEN: - if token in chunk.choices[0].delta.content or "": + if token == (chunk.choices[0].delta.content or ""): is_reasoning = False - reason, text = (chunk.choices[0].delta.content or "").split(token) - reason += "" + reason = "" + text = "" break # 还在推理 if is_reasoning: reason = chunk.choices[0].delta.content or "" - # 当前是正常问答 - if not is_reasoning: - text = chunk.choices[0].delta.content or "" - # 推送消息 if streaming: # 如果需要推送推理内容 diff --git a/apps/service/suggestion.py b/apps/service/suggestion.py index 3f86252a9076d87ecfab0dd2e711f880af608e50..d3481d835a6de6a3d64a2f0f69742e9de71d0105 100644 --- a/apps/service/suggestion.py +++ b/apps/service/suggestion.py @@ -3,7 +3,6 @@ Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. """ import json -from textwrap import dedent from apps.common.queue import MessageQueue from apps.common.security import Security @@ -44,10 +43,16 @@ async def plan_next_flow(user_sub: str, task_id: str, queue: MessageQueue, user_ task = await TaskManager.get_task(task_id) # 获取当前用户的领域 user_domain = await UserDomainManager.get_user_domain_by_user_sub_and_topk(user_sub, USER_TOP_DOMAINS_NUM) - current_record = dedent(f""" - Question: {task.record.content.question} - Answer: {task.record.content.answer} - """) + current_record = [ + { + "role": "user", + "content": task.record.content.question, + }, + { + "role": "assistant", + "content": task.record.content.answer, + }, + ] records = await RecordManager.query_record_by_conversation_id(user_sub, task.record.conversation_id, HISTORY_QUESTIONS_NUM) last_n_questions = "" diff --git a/deploy/chart/authhub/Chart.yaml b/deploy/chart/authhub/Chart.yaml index 613a6c25f1f1f9cde514f000e4cb684839b42036..382f2bcaa9584cdc867f21b8c43ef2bf5dc983ea 100644 --- a/deploy/chart/authhub/Chart.yaml +++ b/deploy/chart/authhub/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: authhub-chart description: AuthHub Helm部署包 type: application -version: 0.9.3 -appVersion: "0.9.3" +version: 0.9.4 +appVersion: "0.9.4" diff --git a/deploy/chart/authhub/templates/NOTES.txt b/deploy/chart/authhub/templates/NOTES.txt index cf3cd2f05e113b5763bc86ae79720b610a93a819..931c97d60f20b8bbb08b4ba26125df3805ac341f 100644 --- a/deploy/chart/authhub/templates/NOTES.txt +++ b/deploy/chart/authhub/templates/NOTES.txt @@ -1,5 +1,5 @@ 感谢您使用Euler Copilot! -当前为Euler Copilot 0.9.1版本。 +当前为Euler Copilot 0.9.4版本。 当前Chart的功能为:AuthHub统一登录系统部署。 说明: diff --git a/deploy/chart/databases/Chart.yaml b/deploy/chart/databases/Chart.yaml index dd995ba86cb0a62036c49ed173376ea36c52bc81..476f7f60ea5ef3ea94bc3773e1918b7f2fcfde4c 100644 --- a/deploy/chart/databases/Chart.yaml +++ b/deploy/chart/databases/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: euler-copilot-databases description: Euler Copilot 数据库 Helm部署包 type: application -version: 0.9.3 -appVersion: "0.9.3" +version: 0.9.4 +appVersion: "0.9.4" diff --git a/deploy/chart/databases/templates/NOTES.txt b/deploy/chart/databases/templates/NOTES.txt index ca199936fa75e624fd5d4392d2e6d7d1d00dee72..dc55c5bfbc46ed342644fc0935cf24bfd0cea171 100644 --- a/deploy/chart/databases/templates/NOTES.txt +++ b/deploy/chart/databases/templates/NOTES.txt @@ -1,3 +1,3 @@ 感谢您使用Euler Copilot! -当前为Euler Copilot 0.9.3版本。 +当前为Euler Copilot 0.9.4版本。 当前Chart的功能为:数据库部署。 \ No newline at end of file diff --git a/deploy/chart/databases/values.yaml b/deploy/chart/databases/values.yaml index f4d140919cef2fe1f3848bbb1698a136cf5c62f6..99ca53190811af6a4dc537ed1415c421d8b6eacf 100644 --- a/deploy/chart/databases/values.yaml +++ b/deploy/chart/databases/values.yaml @@ -75,7 +75,7 @@ databases: pgsql: # [必填] 是否部署PostgreSQL实例 enabled: true - # 镜像设置,默认为hub.oepkgsnet/neocopilot/pgsql-empty:pg16 + # 镜像设置,默认为hub.oepkgs.net/neocopilot/pgsql-empty:pg16 # 镜像版本: ["pg16", "pg16-arm"] image: # 性能限制设置 diff --git a/deploy/chart/euler_copilot/Chart.yaml b/deploy/chart/euler_copilot/Chart.yaml index b48072c2abd639f481d5e2556a970d96b159dc5d..1910e80d7f40f4a48b47e9115173ac2e4b8dca5a 100644 --- a/deploy/chart/euler_copilot/Chart.yaml +++ b/deploy/chart/euler_copilot/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: euler-copilot description: Euler Copilot Helm部署包 type: application -version: 0.9.3 -appVersion: "0.9.3" +version: 0.9.4 +appVersion: "0.9.4" diff --git a/deploy/chart/euler_copilot/templates/NOTES.txt b/deploy/chart/euler_copilot/templates/NOTES.txt index 52dd575768724dd865a75f7c806efe2fa02d51ae..f2411ee41b63a11a2aa2704f4c4786019999f8f2 100644 --- a/deploy/chart/euler_copilot/templates/NOTES.txt +++ b/deploy/chart/euler_copilot/templates/NOTES.txt @@ -1,5 +1,5 @@ 感谢您使用Euler Copilot! -当前为Euler Copilot 0.9.1版本。 +当前为Euler Copilot 0.9.4版本。 当前Chart的功能为:Euler Copilot核心组件部署。 更多项目动态和分享会议,请关注openEuler sig-intelligence:https://www.openeuler.org/en/sig/sig-detail/?name=sig-intelligence \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml index c5ebfaebedc753318b53b42af53afe38662613d3..2f6f515ae5008f567bd60f537c109b620972afe5 100644 --- a/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml +++ b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml @@ -22,10 +22,10 @@ metadata: namespace: {{ .Release.Namespace }} spec: rules: - - host: {{ default "witchaind.eulercopilot.local" .Values.domain.witchaind }} + - host: {{ default "www.eulercopilot.local" .Values.domain.euler_copilot }} http: paths: - - path: {{ default "/" .Values.euler_copilot.rag_web.ingress.prefix }} + - path: {{ default "/witchaind" .Values.euler_copilot.rag_web.ingress.prefix }} pathType: Prefix backend: service: diff --git a/deploy/chart/euler_copilot/templates/rag/rag.yaml b/deploy/chart/euler_copilot/templates/rag/rag.yaml index 1c443b45e55b7162e08cf79a1285fb62318bf597..b75f7287d7f4995568b8a4e342944be665fbc386 100644 --- a/deploy/chart/euler_copilot/templates/rag/rag.yaml +++ b/deploy/chart/euler_copilot/templates/rag/rag.yaml @@ -37,7 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: rag - image: {{ default "hub.oepkgs.net/neocopilot/data_chain_agent:0.9.3-x86" .Values.euler_copilot.rag.image }} + image: {{ default "hub.oepkgs.net/neocopilot/data_chain_back_end:0.9.3-x86" .Values.euler_copilot.rag.image }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 9988 diff --git a/deploy/chart/euler_copilot/templates/secrets.yaml b/deploy/chart/euler_copilot/templates/secrets.yaml index c92948cfa4b84818b6555be18f0b6f9bcc11bfd3..221cb4f03aa9ff1d65914533ed27d10c79380e11 100644 --- a/deploy/chart/euler_copilot/templates/secrets.yaml +++ b/deploy/chart/euler_copilot/templates/secrets.yaml @@ -9,13 +9,13 @@ metadata: helm.sh/resource-policy: keep type: Opaque stringData: - jwtKey: {{ index $systemSecret.data "jwtKey" | b64dec }} - halfKey1: {{ index $systemSecret.data "halfKey1" | b64dec }} - halfKey2: {{ index $systemSecret.data "halfKey2" | b64dec }} - halfKey3: {{ index $systemSecret.data "halfKey3" | b64dec }} - csrfKey: {{ index $systemSecret.data "csrfKey" | b64dec }} - clientId: {{ index $systemSecret.data "clientId" | b64dec }} - clientSecret: {{ index $systemSecret.data "clientSecret" | b64dec }} + jwtKey: {{ index $systemSecret.data.jwtKey | b64dec }} + halfKey1: {{ index $systemSecret.data.halfKey1 | b64dec }} + halfKey2: {{ index $systemSecret.data.halfKey2 | b64dec }} + halfKey3: {{ index $systemSecret.data.halfKey3 | b64dec }} + csrfKey: {{ index $systemSecret.data.csrfKey | b64dec }} + clientId: {{ index $systemSecret.data.clientId | b64dec }} + clientSecret: {{ index $systemSecret.data.clientSecret | b64dec }} {{- else -}} apiVersion: v1 kind: Secret diff --git a/deploy/chart/euler_copilot/values.yaml b/deploy/chart/euler_copilot/values.yaml index 7392263c5f0ed802b47aeb11a53c9114d5c47d5b..9343db4ab38bc497b77d8457fe4fea2088691c01 100644 --- a/deploy/chart/euler_copilot/values.yaml +++ b/deploy/chart/euler_copilot/values.yaml @@ -9,7 +9,7 @@ globals: models: # 用于问答的大模型;需要为OpenAI兼容接口 answer: - # [必填] 接口URL;需要带上“v1”等后缀 + # [必填] 接口URL(无需带上“v1”后缀) url: # [必填] 接口API Key;默认置空 key: @@ -36,7 +36,7 @@ models: max_tokens: # 用于数据向量化(Embedding)的模型 embedding: - # [必填] Embedding URL;需要带上“v1”等后缀 + # [必填] Embedding URL(无需带上“v1”后缀) url: # [必填] Embedding 模型API Key key: @@ -69,8 +69,6 @@ login: # 域名设置 domain: - # 用于WitchainD的域名;默认为witchaind.eulercopilot.local - witchaind: # 用于EulerCopilot的域名;默认为www.eulercopilot.local euler_copilot: # 部署authhub时使用的域名;默认为suthhub.eulercopilot.local