diff --git a/apps/common/config.py b/apps/common/config.py
index a3f3b742862c235b4bb39946e872aca1015931bb..d7f3c23da3a6876b376ea5ab00acd45e47f6c0f3 100644
--- a/apps/common/config.py
+++ b/apps/common/config.py
@@ -17,7 +17,7 @@ class ConfigModel(BaseModel):
DEPLOY_MODE: str = Field(description="oidc 部署方式", default="online")
COOKIE_MODE: str = Field(description="COOKIE SET 方式", default="domain")
# WEB
- WEB_FRONT_URL: str = Field(description="web前端地址")
+ WEB_FRONT_URL: str = Field(description="web前端跳转地址", default="/")
# Redis
REDIS_HOST: str = Field(description="Redis主机名")
REDIS_PORT: int = Field(description="Redis端口号", default=6379)
diff --git a/apps/llm/patterns/recommend.py b/apps/llm/patterns/recommend.py
index fd1e2d1d68d1498afebd592f96ddd4e1b98d75b8..79978a505143a7c6416215c2369640f6dc1b9629 100644
--- a/apps/llm/patterns/recommend.py
+++ b/apps/llm/patterns/recommend.py
@@ -25,10 +25,10 @@ class Recommend(CorePattern):
1. 从用户角度生成预测问题。
2. 预测问题应为疑问句或祈使句,必须少于30字。
3. 预测问题应优先贴合工具描述,特别是工具描述与背景或倾向无关时。
- 5. 预测问题必须精简,不得输出非必要信息。
+ 5. 预测问题必须精简,不得输出非必要信息,不得输出除问题以外的文字。
6. 预测问题不得与“用户历史提问”重复或相似。
- ==示例==
+ ==以下是一个例子==
工具描述:调用API,查询天气数据
用户历史提问:
@@ -40,9 +40,9 @@ class Recommend(CorePattern):
生成的预测问题:
杭州西湖景区的门票价格是多少?
- ==结束示例==
-
+ ==例子结束==
+ 现在,进行问题生成:
工具描述:{action_description}
用户历史提问:
@@ -76,16 +76,10 @@ class Recommend(CorePattern):
else:
history_questions = kwargs["history_questions"]
- if "shown_questions" not in kwargs or not kwargs["shown_questions"]:
- shown_questions = "[Empty]"
- else:
- shown_questions = kwargs["shown_questions"]
-
user_input = self.user_prompt.format(
action_description=action_description,
history_questions=history_questions,
recent_question=kwargs["recent_question"],
- shown_questions=shown_questions,
user_preference=user_preference,
)
@@ -95,7 +89,7 @@ class Recommend(CorePattern):
]
result = ""
- async for chunk in ReasoningLLM().call(task_id, messages, streaming=False, temperature=1.0):
+ async for chunk in ReasoningLLM().call(task_id, messages, streaming=False, temperature=0.7, result_only=True):
result += chunk
return result
diff --git a/apps/llm/reasoning.py b/apps/llm/reasoning.py
index 568735e49a2e9e3cde9c35b7402aafacee846dcb..bc32b345dcab9523dccc52a93da52109d79b7d52 100644
--- a/apps/llm/reasoning.py
+++ b/apps/llm/reasoning.py
@@ -57,7 +57,7 @@ class ReasoningLLM(metaclass=Singleton):
async def call(self, task_id: str, messages: list[dict[str, str]], # noqa: C901, PLR0912
max_tokens: Optional[int] = None, temperature: Optional[float] = None,
- *, streaming: bool = True) -> AsyncGenerator[str, None]:
+ *, streaming: bool = True, result_only: bool = True) -> AsyncGenerator[str, None]:
"""调用大模型,分为流式和非流式两种"""
input_tokens = self._calculate_token_length(messages)
try:
@@ -80,40 +80,80 @@ class ReasoningLLM(metaclass=Singleton):
stream=True,
) # type: ignore[]
+ reasoning_content = ""
result = ""
+ is_first_chunk = True
+ is_reasoning = True
+ reasoning_type = ""
+
async for chunk in stream:
- content = chunk.choices[0].delta.content or ""
+ # 当前Chunk内的信息
reason = ""
- if hasattr(chunk.choices[0].delta, "reasoning_content"):
- reason = chunk.choices[0].delta.reasoning_content or ""
-
- if reason:
- if "" not in result:
- reason = "" + reason
- result += reason
- if streaming:
- yield reason
- continue
- else:
- if "" in result and "" not in result:
- result += ""
- if streaming:
- yield ""
-
- for token in REASONING_BEGIN_TOKEN:
- if token in content:
- content = content.replace(token, "")
-
- for token in REASONING_END_TOKEN:
- if token in content:
- content = content.replace(token, "")
-
- result += content
- if streaming:
- yield content
+ text = ""
+
+ if is_first_chunk:
+ if hasattr(chunk.choices[0].delta, "reasoning_content"):
+ reason = "" + chunk.choices[0].delta.reasoning_content or ""
+ reasoning_type = "args"
+ 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 ""
+ reasoning_type = "tokens"
+ is_reasoning = True
+ break
+
+ # 当前已经不是第一个Chunk了
+ is_first_chunk = False
+
+ # 当前处于推理状态
+ if not is_first_chunk and is_reasoning:
+ # 如果推理内容用特殊参数传递
+ if reasoning_type == "args":
+ # 还在推理
+ if hasattr(chunk.choices[0].delta, "reasoning_content"):
+ reason = chunk.choices[0].delta.reasoning_content or ""
+ # 推理结束
+ 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 "":
+ is_reasoning = False
+ reason, text = (chunk.choices[0].delta.content or "").split(token)
+ reason += ""
+ break
+ # 还在推理
+ if is_reasoning:
+ reason = chunk.choices[0].delta.content or ""
+
+ # 当前是正常问答
+ if not is_reasoning:
+ text = chunk.choices[0].delta.content or ""
+
+ # 推送消息
+ if streaming:
+ # 如果需要推送推理内容
+ if reason and not result_only:
+ yield reason
+
+ # 推送text
+ yield text
+
+ # 整理结果
+ reasoning_content += reason
+ result += text
if not streaming:
+ if not result_only:
+ yield reasoning_content
yield result
output_tokens = self._calculate_token_length([{"role": "assistant", "content": result}], pure_text=True)
diff --git a/apps/main.py b/apps/main.py
index fe4bab93e5370ce769cac047e04446a6eb05abf6..704fb17197d0e3bca6caf8f8dbddf29830424caf 100644
--- a/apps/main.py
+++ b/apps/main.py
@@ -31,7 +31,7 @@ app = FastAPI(docs_url=None, redoc_url=None)
# 定义FastAPI全局中间件
app.add_middleware(
CORSMiddleware,
- allow_origins=[config["WEB_FRONT_URL"]],
+ allow_origins=[config["DOMAIN"]],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
diff --git a/apps/service/suggestion.py b/apps/service/suggestion.py
index 53293e11c70845c0e8a4417c16a27a59197d919b..3f86252a9076d87ecfab0dd2e711f880af608e50 100644
--- a/apps/service/suggestion.py
+++ b/apps/service/suggestion.py
@@ -48,7 +48,6 @@ async def plan_next_flow(user_sub: str, task_id: str, queue: MessageQueue, user_
Question: {task.record.content.question}
Answer: {task.record.content.answer}
""")
- generated_questions = ""
records = await RecordManager.query_record_by_conversation_id(user_sub, task.record.conversation_id, HISTORY_QUESTIONS_NUM)
last_n_questions = ""
@@ -64,9 +63,7 @@ async def plan_next_flow(user_sub: str, task_id: str, queue: MessageQueue, user_
history_questions=last_n_questions,
recent_question=current_record,
user_preference=user_domain,
- shown_questions=generated_questions,
)
- generated_questions += f"{question}\n"
content = SuggestContent(
question=question,
plugin_id="",
@@ -101,9 +98,7 @@ async def plan_next_flow(user_sub: str, task_id: str, queue: MessageQueue, user_
history_questions=last_n_questions,
recent_question=current_record,
user_preference=str(user_domain),
- shown_questions=generated_questions,
)
- generated_questions += f"{rewrite_question}\n"
content = SuggestContent(
plugin_id=plugin_id,
@@ -153,9 +148,7 @@ async def plan_next_flow(user_sub: str, task_id: str, queue: MessageQueue, user_
history_questions=last_n_questions,
recent_question=current_record,
user_preference=str(user_domain),
- shown_questions=generated_questions,
)
- generated_questions += f"{rewrite_question}\n"
content = SuggestContent(
plugin_id=next_flow_plugin_id,
flow_id=next_flow.id,
diff --git a/deploy/chart/authhub/templates/secrets.yaml b/deploy/chart/authhub/templates/secrets.yaml
index 62a3e43316345f28d20c50a0708711f896a07fb1..a274f0973ccfec72963b7fac4efb4866e5d2f22b 100644
--- a/deploy/chart/authhub/templates/secrets.yaml
+++ b/deploy/chart/authhub/templates/secrets.yaml
@@ -9,7 +9,7 @@ metadata:
helm.sh/resource-policy: keep
type: Opaque
stringData:
- mysql-password: {{ $authhubSecret.data.mysql-password | b64dec }}
+ mysql-password: {{ index $authhubSecret.data "mysql-password" | b64dec }}
{{- else -}}
apiVersion: v1
kind: Secret
diff --git a/deploy/chart/databases/templates/secrets.yaml b/deploy/chart/databases/templates/secrets.yaml
index 36f993783969b17f62495aa4a9618562b3f3290d..e2a4a071a87678b81b18c9e530f7707d24ba4ae2 100644
--- a/deploy/chart/databases/templates/secrets.yaml
+++ b/deploy/chart/databases/templates/secrets.yaml
@@ -9,10 +9,10 @@ metadata:
helm.sh/resource-policy: keep
type: Opaque
stringData:
- redis-password: {{ $databaseSecret.data.redis-password | b64dec }}
- mongo-password: {{ $databaseSecret.data.mongo-password | b64dec }}
- minio-password: {{ $databaseSecret.data.minio-password | b64dec }}
- pgsql-password: {{ $databaseSecret.data.pgsql-password | b64dec }}
+ redis-password: {{ index $databaseSecret.data "redis-password" | b64dec }}
+ mongo-password: {{ index $databaseSecret.data "mongo-password" | b64dec }}
+ minio-password: {{ index $databaseSecret.data "minio-password" | b64dec }}
+ pgsql-password: {{ index $databaseSecret.data "pgsql-password" | b64dec }}
{{- else -}}
apiVersion: v1
kind: Secret
diff --git a/deploy/chart/euler_copilot/configs/framework/.env b/deploy/chart/euler_copilot/configs/framework/.env
index ac40de311757ef09c68bbbfd9ebde75087ead251..99e48bca0862ffe202c92144df1afebab1bf484f 100644
--- a/deploy/chart/euler_copilot/configs/framework/.env
+++ b/deploy/chart/euler_copilot/configs/framework/.env
@@ -2,9 +2,6 @@
DEPLOY_MODE=local
COOKIE_MODE=domain
-# Web
-WEB_FRONT_URL={{ .Values.euler_copilot.framework.web_url }}
-
# Redis
REDIS_HOST=redis-db.{{ .Release.Namespace }}.svc.cluster.local
REDIS_PORT=6379
diff --git a/deploy/chart/euler_copilot/templates/secrets.yaml b/deploy/chart/euler_copilot/templates/secrets.yaml
index db56b807470247120058d8d4e7347a3ea47722e4..c92948cfa4b84818b6555be18f0b6f9bcc11bfd3 100644
--- a/deploy/chart/euler_copilot/templates/secrets.yaml
+++ b/deploy/chart/euler_copilot/templates/secrets.yaml
@@ -5,28 +5,32 @@ kind: Secret
metadata:
name: euler-copilot-system
namespace: {{ .Release.Namespace }}
+ annotations:
+ helm.sh/resource-policy: keep
type: Opaque
stringData:
- jwtKey: {{ $systemSecret.data.jwtKey | b64dec }}
- halfKey1: {{ $systemSecret.data.halfKey1 | b64dec }}
- halfKey2: {{ $systemSecret.data.halfKey2 | b64dec }}
- halfKey3: {{ $systemSecret.data.halfKey3 | b64dec }}
- csrfKey: {{ $systemSecret.data.csrfKey | b64dec }}
- clientId: {{ $systemSecret.data.clientId | b64dec }}
- clientSecret: {{ $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
metadata:
name: euler-copilot-system
namespace: {{ .Release.Namespace }}
+ annotations:
+ helm.sh/resource-policy: keep
type: Opaque
stringData:
jwtKey: {{ randAlphaNum 32 | b64enc }}
halfKey1: {{ randAlphaNum 32 }}
halfKey2: {{ randAlphaNum 32 }}
halfKey3: {{ randAlphaNum 32 }}
- csrfKey: {{ randAlphaNum 32 }}
+ csrfKey: {{ randAlphaNum 32 | b64enc}}
clientId: {{ .Values.login.client.id }}
clientSecret: {{ .Values.login.client.secret }}
{{- end -}}
diff --git a/deploy/chart/euler_copilot/values.yaml b/deploy/chart/euler_copilot/values.yaml
index a8d2c038b4bdddede67d1453505996aa9a7ac4f7..7392263c5f0ed802b47aeb11a53c9114d5c47d5b 100644
--- a/deploy/chart/euler_copilot/values.yaml
+++ b/deploy/chart/euler_copilot/values.yaml
@@ -29,7 +29,7 @@ models:
# API Key;不填则与问答模型一致
key:
# 模型名称;不填则与问答模型一致
- model:
+ name:
# 模型最大上下文数;不填则与问答模型一致
ctx_length:
# 模型最大输出长度;不填则与问答模型一致