Release/v0.2.3 (#355)

* feat(web): add PageEmpty component

* feat(web): add PageTabs component

* feat(web): add PageEmpty component

* feat(web): add PageTabs component

* feat(prompt): add history tracking for prompt releases

* feat(web): add prompt menu

* refactor: The PageScrollList component supports two generic parameters

* feat(web): BodyWrapper compoent update PageLoading

* feat(web): add Ontology menu

* feat(web): memory management add scene

* feat(tasks): add celery task configuration for periodic jobs

- Add ignore_result=True to prevent storing results for periodic tasks
- Set max_retries=0 to skip failed periodic tasks without retry attempts
- Configure acks_late=False for immediate acknowledgment in beat tasks
- Add time_limit and soft_time_limit to regenerate_memory_cache task (3600s/3300s)
- Add time_limit and soft_time_limit to workspace_reflection_task (300s/240s)
- Add time_limit and soft_time_limit to run_forgetting_cycle_task (7200s/7000s)
- Improve task reliability and resource management for scheduled jobs

* feat(sandbox): add Node.js code execution support to sandbox

* Release/v0.2.2 (#260)

* [modify] migration script

* [add] migration script

* fix(web): change form message

* fix(web): the memoryContent field is compatible with numbers and strings

* feat(web): code node hidden

* fix(model):
1. create a basic model to check if the name and provider are duplicated.
2. The result shows error models because the provider created API Keys for all matching models.

---------

Co-authored-by: Mark <zhuwenhui5566@163.com>
Co-authored-by: zhaoying <yzhao96@best-inc.com>
Co-authored-by: yingzhao <zhaoyingyz@126.com>
Co-authored-by: Timebomb2018 <18868801967@163.com>

* Feature/ontology class clean (#249)

* [add] Complete ontology engineering feature implementation

* [add] Add ontology feature integration and validation utilities

* [add] Add OWL validator and validation utilities

* [fix] Add missing render_ontology_extraction_prompt function

* [fix]Add dependencies, fix functionality

* [add] migration script

* feat(celery): add dedicated periodic tasks worker and queue (#261)

* fix(web): conflict resolve

* Fix/v022 bug (#263)

* [fix]Fix the issue of inconsistent language in explicit and episodic memory.

* [fix]Fix the issue of inconsistent language in explicit and episodic memory.

* [add]Add scene_id

* [fix]Based on the AI review to fix the code

* Fix/develop memory reflex (#265)

* 遗漏的历史映射

* 遗漏的历史映射

* 反思后台报错处理

* [add] migration script

* fix: chat conversation_id add node_start

* feat(web): show code node

* fix(web): Restructure the CustomSelect component, repair the interface that is called multiple times when the form is updated

* feat(web): RadioGroupCard support block mode

* feat(web): create space add icon

* feat(app and model): token consumption statistics

* Add/develop memory (#264)

* 遗漏的历史映射

* 遗漏的历史映射

* 遗漏的历史映射

* 遗漏的历史映射

* 遗漏的历史映射

* 遗漏的历史映射

* 遗漏的历史映射

* 遗漏的历史映射

* 遗漏的历史映射

* 新增长期记忆功能

* 新增长期记忆功能

* 新增长期记忆功能

* 知识库检索多余字段

* 长期

* feat(app and model): token consumption statistics of the cluster

* memory_BUG_fix

* fix(web): prompt history remove pageLoading

* fix(prompt): remove hard-coded import of prompt file paths (#279)

* Fix/develop memory bug (#274)

* 遗漏的历史映射

* 遗漏的历史映射

* fix_timeline_memories

* fix(web): update retrieve_type key

* Fix/develop memory bug (#276)

* 遗漏的历史映射

* 遗漏的历史映射

* fix_timeline_memories

* fix_timeline_memories

* write_gragp/bug_fix

* write_gragp/bug_fix

* write_gragp/bug_fix

* chore(celery): disable periodic task scheduling

* fix(prompt): remove hard-coded import of prompt file paths

---------

Co-authored-by: lixinyue11 <94037597+lixinyue11@users.noreply.github.com>
Co-authored-by: zhaoying <yzhao96@best-inc.com>
Co-authored-by: yingzhao <zhaoyingyz@126.com>
Co-authored-by: Ke Sun <kesun5@illinois.edu>

* fix(web): remove delete confirm content

* refactor(workflow): relocate template directory into workflow

* feat(memory): add long-term storage task routing and batching

* fix(web): PageScrollList loading update

* fix(web): PageScrollList loading update

* Ontology v1 bug (#291)

* [changes]Add 'id' as the secondary sorting key, and 'scene_id' now returns a UUID object

* [fix]Fix the "end_user" return to be sorted by update time.

* [fix]Set the default values of the memory configuration model based on the spatial model.

* [fix]Remove the entity extraction check combination model, read the configuration list, and add the return of scene_id

* [fix]Fix the "end_user" return to be sorted by update time.

* [fix]

* fix(memory): add Redis session validation

- Add macOS fork() safety configuration in celery_app.py to prevent initialization issues
- Add null/False checks for Redis session queries in term_memory_save to handle missing sessions gracefully
- Add null/False checks in memory_long_term_storage to prevent processing empty Redis results
- Add null/False checks in aggregate_judgment before format_parsing to avoid errors on missing data
- Initialize redis_messages variable in window_dialogue for consistency
- Add debug logging when no existing session found in Redis for better troubleshooting
- Add TODO comments for magic numbers (scope=6, time=5) to be extracted as constants
- Improve error handling when Redis returns False or empty results instead of crashing

* fix(web): PageScrollList style update

* fix(workflow): fix argument passing in code execution nodes

* fix(web): prompt add disabled

* fix(web): space icon required

* feat(app): modify the key of the token

* fix(fix the key of the app's token):

* fix(workflow): switch code input encoding to base64+URL encoding

* [add]The main project adds multi-API Key load balancing.

* [changes]Attribute security access, secure numerical conversion, unified use of local variables

* fix(web): save add session update

* fix(web): language editor support paste

* [changes]Active status filtering logic, API Key selection strategy

* memory_BUG

* memory_BUG_long_term

* [changes]

* memory_BUG_long_term

* memory_BUG_long_term

* Fix/release memory bug (#306)

* memory_BUG_fix

* memory_BUG

* memory_BUG_long_term

* memory_BUG_long_term

* memory_BUG_long_term

* knowledge_retrieval/bug/fix

* knowledge_retrieval/bug/fix

* knowledge_retrieval/bug/fix

* [fix]1.The "read_all_config" interface returns "scene_name";2.Memory configuration for lightweight query ontology scenarios

* fix(web): replace code editor

* [changes]Modify the description of the time for the recent event

* [changes]Modify the code based on the AI review

* feat(web): update memory config ontology api

* fix(web): ui update

* knowledge_retrieval/bug/fix

* knowledge_retrieval/bug/fix

* knowledge_retrieval/bug/fix

* feat(workflow): add token usage statistics for question classifier and parameter extraction

* feat(web): move prompt menu

* Multiple independent transactions - single transaction

* Multiple independent transactions - single transaction

* Multiple independent transactions - single transaction

* Multiple independent transactions - single transaction

* Write Missing None (#321)

* Write Missing None

* Write Missing None

* Write Missing None

* Apply suggestion from @sourcery-ai[bot]

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Write Missing None

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Fix/release memory bug (#324)

* Write Missing None

* Write Missing None

* Write Missing None

* Apply suggestion from @sourcery-ai[bot]

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Write Missing None

* redis update

* redis update

* redis update

* redis update

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Fix/writer memory bug (#326)

* [fix]Fix the bug

* [fix]Fix the bug

* [fix]Correct the direction indication.

* fix(web): markdown table ui update

* Fix/release memory bug (#332)

* Write Missing None

* Write Missing None

* Write Missing None

* Apply suggestion from @sourcery-ai[bot]

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Write Missing None

* redis update

* redis update

* redis update

* redis update

* writer_dup_bug/fix

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Fix/fact summary (#333)

* [fix]Disable the contents related to fact_summary

* [fix]Disable the contents related to fact_summary

* [fix]Modify the code based on the AI review

* Fix/release memory bug (#335)

* Write Missing None

* Write Missing None

* Write Missing None

* Apply suggestion from @sourcery-ai[bot]

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Write Missing None

* redis update

* redis update

* redis update

* redis update

* writer_dup_bug/fix

* writer_graph_bug/fix

* writer_graph_bug/fix

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Revert "feat(web): move prompt menu"

This reverts commit 9e6e8f50f8.

* fix(web): ui update

* fix(web): update text

* fix(web): ui update

* fix(model): change the "vl" model type of dashscope to "chat"

* fix(model): change the "vl" model type of dashscope to "chat"

---------

Co-authored-by: zhaoying <yzhao96@best-inc.com>
Co-authored-by: Eternity <1533512157@qq.com>
Co-authored-by: Mark <zhuwenhui5566@163.com>
Co-authored-by: yingzhao <zhaoyingyz@126.com>
Co-authored-by: Timebomb2018 <18868801967@163.com>
Co-authored-by: 乐力齐 <162269739+lanceyq@users.noreply.github.com>
Co-authored-by: lixinyue11 <94037597+lixinyue11@users.noreply.github.com>
Co-authored-by: lixinyue <2569494688@qq.com>
Co-authored-by: Eternity <61316157+myhMARS@users.noreply.github.com>
Co-authored-by: lanceyq <1982376970@qq.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This commit is contained in:
Ke Sun
2026-02-06 19:01:57 +08:00
committed by GitHub
parent eab7225d83
commit 79ab929fb0
187 changed files with 12252 additions and 1656 deletions

View File

@@ -44,7 +44,7 @@ class CodeNodeConfig(BaseNodeConfig):
description="code content"
)
language: Literal['python3', 'nodejs'] = Field(
language: Literal['python3', 'javascript'] = Field(
...,
description="language"
)

View File

@@ -2,6 +2,7 @@ import base64
import json
import logging
import re
import urllib.parse
from string import Template
from textwrap import dedent
from typing import Any
@@ -14,7 +15,7 @@ from app.core.workflow.nodes.code.config import CodeNodeConfig
logger = logging.getLogger(__name__)
SCRIPT_TEMPLATE = Template(dedent("""
PYTHON_SCRIPT_TEMPLATE = Template(dedent("""
$code
import json
@@ -32,6 +33,20 @@ result = "<<RESULT>>" + output_json + "<<RESULT>>"
print(result)
"""))
NODEJS_SCRIPT_TEMPLATE = Template(dedent("""
$code
// decode and prepare input object
var inputs_obj = JSON.parse(Buffer.from('$inputs_variable', 'base64').toString('utf-8'))
// execute main function
var output_obj = main(inputs_obj)
// convert output to json and print
var output_json = JSON.stringify(output_obj)
var result = `<<RESULT>>$${output_json}<<RESULT>>`
console.log(result)
"""))
class CodeNode(BaseNode):
def __init__(self, node_config: dict[str, Any], workflow_config: dict[str, Any]):
@@ -83,18 +98,27 @@ class CodeNode(BaseNode):
input_variable_dict = {}
for input_variable in self.typed_config.input_variables:
input_variable_dict[input_variable.name] = self.get_variable(input_variable.variable, state)
code = base64.b64decode(
self.typed_config.code
).decode("utf-8")
code = urllib.parse.unquote(code, encoding='utf-8')
input_variable_dict = base64.b64encode(
json.dumps(input_variable_dict).encode("utf-8")
).decode("utf-8")
final_script = SCRIPT_TEMPLATE.substitute(
code=code,
inputs_variable=input_variable_dict,
)
if self.typed_config.language == "python3":
final_script = PYTHON_SCRIPT_TEMPLATE.substitute(
code=code,
inputs_variable=input_variable_dict,
)
elif self.typed_config.language == 'javascript':
final_script = NODEJS_SCRIPT_TEMPLATE.substitute(
code=code,
inputs_variable=input_variable_dict,
)
else:
raise ValueError(f"Unsupported language: {self.typed_config.language}")
async with httpx.AsyncClient() as client:
response = await client.post(

View File

@@ -23,6 +23,18 @@ class ParameterExtractorNode(BaseNode):
def __init__(self, node_config: dict[str, Any], workflow_config: dict[str, Any]):
super().__init__(node_config, workflow_config)
self.typed_config: ParameterExtractorNodeConfig | None = None
self.response_metadata = {}
def _extract_token_usage(self, business_result: Any) -> dict[str, int] | None:
if self.response_metadata:
usage = self.response_metadata.get('token_usage')
if usage:
return {
"prompt_tokens": usage.get('prompt_tokens', 0),
"completion_tokens": usage.get('completion_tokens', 0),
"total_tokens": usage.get('total_tokens', 0)
}
return None
@staticmethod
def _get_prompt():
@@ -171,6 +183,7 @@ class ParameterExtractorNode(BaseNode):
])
model_resp = await llm.ainvoke(messages)
self.response_metadata = model_resp.response_metadata
result = json_repair.repair_json(model_resp.content, return_objects=True)
logger.info(f"node: {self.node_id} get params:{result}")

View File

@@ -23,6 +23,18 @@ class QuestionClassifierNode(BaseNode):
super().__init__(node_config, workflow_config)
self.typed_config: QuestionClassifierNodeConfig | None = None
self.category_to_case_map = {}
self.response_metadata = {}
def _extract_token_usage(self, business_result: Any) -> dict[str, int] | None:
if self.response_metadata:
usage = self.response_metadata.get('token_usage')
if usage:
return {
"prompt_tokens": usage.get('prompt_tokens', 0),
"completion_tokens": usage.get('completion_tokens', 0),
"total_tokens": usage.get('total_tokens', 0)
}
return None
def _get_llm_instance(self) -> RedBearLLM:
"""获取LLM实例"""
@@ -112,6 +124,7 @@ class QuestionClassifierNode(BaseNode):
response = await llm.ainvoke(messages)
result = response.content.strip()
self.response_metadata = response.response_metadata
if result in category_names:
category = result

View File

@@ -4,16 +4,19 @@
从文件系统加载预定义的工作流模板
"""
import os
from pathlib import Path
from typing import Optional
import yaml
TEMPLATE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
class TemplateLoader:
"""工作流模板加载器"""
def __init__(self, templates_dir: str = "app/templates/workflows"):
def __init__(self, templates_dir: str = TEMPLATE_DIR):
"""初始化模板加载器
Args:
@@ -22,7 +25,7 @@ class TemplateLoader:
self.templates_dir = Path(templates_dir)
if not self.templates_dir.exists():
raise ValueError(f"模板目录不存在: {templates_dir}")
def list_templates(self) -> list[dict]:
"""列出所有可用的模板
@@ -30,22 +33,22 @@ class TemplateLoader:
模板列表,每个模板包含 id, name, description 等信息
"""
templates = []
# 遍历模板目录
for template_dir in self.templates_dir.iterdir():
if not template_dir.is_dir():
continue
# 检查是否有 template.yml 文件
template_file = template_dir / "template.yml"
if not template_file.exists():
continue
try:
# 读取模板配置
with open(template_file, 'r', encoding='utf-8') as f:
template_data = yaml.safe_load(f)
# 提取模板信息
templates.append({
"id": template_dir.name,
@@ -59,9 +62,9 @@ class TemplateLoader:
except Exception as e:
print(f"加载模板 {template_dir.name} 失败: {e}")
continue
return templates
def load_template(self, template_id: str) -> Optional[dict]:
"""加载指定的模板
@@ -73,14 +76,14 @@ class TemplateLoader:
"""
template_dir = self.templates_dir / template_id
template_file = template_dir / "template.yml"
if not template_file.exists():
return None
try:
with open(template_file, 'r', encoding='utf-8') as f:
template_data = yaml.safe_load(f)
# 返回工作流配置部分
return {
"name": template_data.get("name", template_id),
@@ -94,7 +97,7 @@ class TemplateLoader:
except Exception as e:
print(f"加载模板 {template_id} 失败: {e}")
return None
def get_template_readme(self, template_id: str) -> Optional[str]:
"""获取模板的 README 文档
@@ -106,10 +109,10 @@ class TemplateLoader:
"""
template_dir = self.templates_dir / template_id
readme_file = template_dir / "README.md"
if not readme_file.exists():
return None
try:
with open(readme_file, 'r', encoding='utf-8') as f:
return f.read()

View File

@@ -0,0 +1,219 @@
# 智能客服工作流模板
id: customer_service_v1
name: 智能客服工作流
description: 智能客服场景,包含意图识别、知识库查询和回复生成
category: customer_service
version: "1.0.0"
author: RedBear Memory Team
tags:
- 客服
- 意图识别
- 知识库
- 多步骤
# 工作流配置
nodes:
- id: start
type: start
name: 开始
position:
x: 100
y: 200
- id: intent_recognition
type: llm
name: 意图识别
config:
prompt: |
分析用户的问题,识别意图类型。
用户问题:{{ var.user_message }}
请从以下类型中选择一个:
- product_inquiry: 产品咨询
- technical_support: 技术支持
- complaint: 投诉建议
- other: 其他
只返回类型名称,不要其他内容。
model: gpt-3.5-turbo
temperature: 0.3
max_tokens: 50
position:
x: 300
y: 200
- id: intent_router
type: condition
name: 意图路由
position:
x: 500
y: 200
- id: product_handler
type: llm
name: 产品咨询处理
config:
prompt: |
用户咨询产品相关问题。
问题:{{ var.user_message }}
意图:{{ node.intent_recognition.output }}
请提供专业、友好的产品咨询回复。
model: gpt-3.5-turbo
temperature: 0.7
max_tokens: 500
position:
x: 700
y: 100
- id: support_handler
type: llm
name: 技术支持处理
config:
prompt: |
用户需要技术支持。
问题:{{ var.user_message }}
意图:{{ node.intent_recognition.output }}
请提供详细的技术支持方案。
model: gpt-3.5-turbo
temperature: 0.5
max_tokens: 800
position:
x: 700
y: 200
- id: complaint_handler
type: llm
name: 投诉处理
config:
prompt: |
用户提出投诉或建议。
问题:{{ var.user_message }}
意图:{{ node.intent_recognition.output }}
请以同理心回应,并提供解决方案。
model: gpt-3.5-turbo
temperature: 0.8
max_tokens: 600
position:
x: 700
y: 300
- id: general_handler
type: llm
name: 通用处理
config:
prompt: |
用户的问题类型:其他
问题:{{ var.user_message }}
请提供友好的回复。
model: gpt-3.5-turbo
temperature: 0.7
max_tokens: 400
position:
x: 700
y: 400
- id: end
type: end
name: 结束
position:
x: 900
y: 200
edges:
- source: start
target: intent_recognition
label: 开始分析
- source: intent_recognition
target: intent_router
label: 识别完成
- source: intent_router
target: product_handler
condition: "'product_inquiry' in node['intent_recognition']['output']"
label: 产品咨询
- source: intent_router
target: support_handler
condition: "'technical_support' in node['intent_recognition']['output']"
label: 技术支持
- source: intent_router
target: complaint_handler
condition: "'complaint' in node['intent_recognition']['output']"
label: 投诉建议
- source: intent_router
target: general_handler
condition: "True" # 默认路径
label: 其他
- source: product_handler
target: end
label: 完成
- source: support_handler
target: end
label: 完成
- source: complaint_handler
target: end
label: 完成
- source: general_handler
target: end
label: 完成
# 变量定义
variables:
- name: user_message
type: string
required: true
description: 用户的消息
default: ""
- name: user_name
type: string
required: false
description: 用户姓名(可选)
default: "客户"
# 执行配置
execution_config:
max_execution_time: 120
max_iterations: 10
# 触发器
triggers: []
# 使用示例
examples:
- name: 产品咨询
description: 用户咨询产品功能
input:
user_message: "你们的产品支持多语言吗?"
user_name: "张三"
expected_output: "产品功能介绍"
- name: 技术支持
description: 用户遇到技术问题
input:
user_message: "我无法登录系统,一直显示密码错误"
user_name: "李四"
expected_output: "技术支持方案"
- name: 投诉处理
description: 用户提出投诉
input:
user_message: "你们的服务态度太差了,我要投诉"
user_name: "王五"
expected_output: "同理心回应和解决方案"

View File

@@ -0,0 +1,131 @@
# 数据处理工作流模板
id: data_processing_v1
name: 数据处理工作流
description: 数据提取、转换和分析的完整流程
category: data_processing
version: "1.0.0"
author: RedBear Memory Team
tags:
- 数据处理
- ETL
- 分析
- Transform
# 工作流配置
nodes:
- id: start
type: start
name: 开始
position:
x: 100
y: 200
- id: extract_data
type: transform
name: 数据提取
config:
expression: |
{
"raw_text": var['input_text'],
"length": len(var['input_text']),
"timestamp": sys['execution_id']
}
position:
x: 300
y: 200
- id: analyze_data
type: llm
name: 数据分析
config:
prompt: |
请分析以下数据:
原始文本:{{ node.extract_data.raw_text }}
文本长度:{{ node.extract_data.length }}
请提供:
1. 主题分类
2. 情感分析
3. 关键信息提取
以 JSON 格式返回结果。
model: gpt-3.5-turbo
temperature: 0.3
max_tokens: 500
position:
x: 500
y: 200
- id: transform_result
type: transform
name: 结果转换
config:
expression: |
{
"original_length": node['extract_data']['length'],
"analysis": node['analyze_data']['output'],
"processed_at": sys['execution_id'],
"status": "completed"
}
position:
x: 700
y: 200
- id: end
type: end
name: 结束
position:
x: 900
y: 200
edges:
- source: start
target: extract_data
label: 开始提取
- source: extract_data
target: analyze_data
label: 开始分析
- source: analyze_data
target: transform_result
label: 转换结果
- source: transform_result
target: end
label: 完成
# 变量定义
variables:
- name: input_text
type: string
required: true
description: 待处理的文本数据
default: ""
# 执行配置
execution_config:
max_execution_time: 180
max_iterations: 5
# 触发器
triggers: []
# 使用示例
examples:
- name: 文本分析
description: 分析一段文本
input:
input_text: "今天天气真好,心情也很愉快。我们公司推出了新产品,市场反响热烈。"
expected_output:
original_length: 35
analysis: "主题:天气和产品,情感:积极"
status: "completed"
- name: 长文本处理
description: 处理较长的文本
input:
input_text: "这是一段很长的文本..."
expected_output:
status: "completed"

View File

@@ -0,0 +1,99 @@
# 多步骤问答工作流
# 演示节点输出参数的使用
id: multi_step_qa_v1
name: 多步骤问答工作流
description: 先分析问题,再生成答案,展示节点间的数据传递
category: advanced
version: "1.0.0"
author: RedBear Memory Team
tags:
- 问答
- 多步骤
- LLM
# 工作流配置
nodes:
- id: start
type: start
name: 开始
position:
x: 100
y: 100
- id: analyze_question
type: llm
name: 分析问题
description: 分析用户问题的类型和意图
config:
model_id: gpt-3.5-turbo
temperature: 0.3
max_tokens: 500
messages:
- role: system
content: |
你是一个问题分析专家。请分析用户的问题,提取以下信息:
1. 问题类型(事实性、观点性、操作性等)
2. 问题领域(科技、历史、文化等)
3. 关键词
- role: user
content: "{{ sys.message }}"
position:
x: 300
y: 100
- id: generate_answer
type: llm
name: 生成答案
description: 根据问题分析结果生成详细答案
config:
model_id: gpt-3.5-turbo
temperature: 0.7
max_tokens: 1000
messages:
- role: system
content: |
你是一个专业的AI助手。根据问题分析结果生成准确、详细的答案。
问题分析结果:
{{ analyze_question.output }}
- role: user
content: "{{ sys.message }}"
position:
x: 500
y: 100
- id: end
type: end
name: 结束
config:
output: "{{ generate_answer.output }}"
position:
x: 700
y: 100
edges:
- source: start
target: analyze_question
label: 开始分析
- source: analyze_question
target: generate_answer
label: 生成答案
- source: generate_answer
target: end
label: 完成
# 变量定义
variables:
- name: user_question
type: string
required: true
description: 用户的问题
default: ""
# 执行配置
execution_config:
max_execution_time: 120
max_iterations: 1

View File

@@ -0,0 +1,93 @@
# 简单问答工作流模板
id: simple_qa_v1
name: 简单问答工作流
description: 最基础的问答工作流,适合快速开始
category: basic
version: "1.0.0"
author: RedBear Memory Team
tags:
- 问答
- 基础
- LLM
# 工作流配置
nodes:
- id: start
type: start
name: 开始
position:
x: 100
y: 100
- id: llm_qa
type: llm
name: LLM 问答
config:
# 使用 LangChain 标准的消息格式
messages:
- role: system
content: |
你是一个专业、友好且乐于助人的 AI 助手。
你的职责:
- 准确理解用户的问题并提供有价值的回答
- 保持回答的专业性和准确性
- 如果不确定答案,诚实地告知用户
- 使用清晰、易懂的语言进行交流
回答风格:
- 简洁明了,直击要点
- 必要时提供详细解释和示例
- 使用友好、礼貌的语气
- 适当使用格式化(如列表、段落)提高可读性
model_id: null
temperature: 0.7
max_tokens: 1000
position:
x: 500
y: 100
- id: end
type: end
name: 结束
config:
output: "{{llm_qa.output}}"
position:
x: 900
y: 100
edges:
- source: start
target: llm_qa
label: 开始处理
- source: llm_qa
target: end
label: 完成
# 变量定义
variables: []
# 执行配置
execution_config:
max_execution_time: 60
max_iterations: 1
# 触发器(可选)
triggers: []
# 使用示例
examples:
- name: 基础问答
description: 询问一个简单的问题
input:
user_question: "什么是人工智能?"
expected_output: "关于人工智能的解释"
- name: 技术咨询
description: 询问技术问题
input:
user_question: "如何学习 Python 编程?"
expected_output: "Python 学习建议"