Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/global/support/wallet/usage/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export enum UsageSourceEnum {
pdfParse = 'pdfParse',
mcp = 'mcp',
evaluation = 'evaluation',
optimize_prompt = 'optimize_prompt'
optimize_prompt = 'optimize_prompt',
code_copilot = 'code_copilot',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

仅保留 code_copilot

code_test = 'code_test'
}

export const UsageSourceMap = {
Expand Down Expand Up @@ -59,5 +61,11 @@ export const UsageSourceMap = {
},
[UsageSourceEnum.optimize_prompt]: {
label: i18nT('common:support.wallet.usage.Optimize Prompt')
},
[UsageSourceEnum.code_copilot]: {
label: i18nT('common:support.wallet.usage.Code Copilot')
},
[UsageSourceEnum.code_test]: {
label: i18nT('common:support.wallet.usage.Code Test')
}
};
1 change: 1 addition & 0 deletions packages/web/components/common/Icon/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const iconPaths = {
close: () => import('./icons/close.svg'),
closeSolid: () => import('./icons/closeSolid.svg'),
code: () => import('./icons/code.svg'),
codeCopilot: () => import('./icons/codeCopilot.svg'),
collectionLight: () => import('./icons/collectionLight.svg'),
collectionSolid: () => import('./icons/collectionSolid.svg'),
comment: () => import('./icons/comment.svg'),
Expand Down
46 changes: 46 additions & 0 deletions packages/web/components/common/Icon/icons/codeCopilot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 13 additions & 7 deletions packages/web/components/common/Textarea/PromptEditor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

import { useMemo, useState, useTransition } from 'react';
import { CSSProperties, useMemo, useState, useTransition } from 'react';
import { LexicalComposer } from '@lexical/react/LexicalComposer';
import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
Expand All @@ -31,6 +31,7 @@ import { VariableLabelNode } from './plugins/VariableLabelPlugin/node';
import VariableLabelPlugin from './plugins/VariableLabelPlugin';
import { useDeepCompareEffect } from 'ahooks';
import VariablePickerPlugin from './plugins/VariablePickerPlugin';
import KeyDownPlugin from './plugins/KeyDownPlugin';

export type EditorProps = {
variables?: EditorVariablePickerType[];
Expand All @@ -41,12 +42,14 @@ export type EditorProps = {
maxH?: number;
maxLength?: number;
placeholder?: string;
placeholderPadding?: string;
isInvalid?: boolean;

onKeyDown?: (e: React.KeyboardEvent) => void;
ExtensionPopover?: ((e: {
onChangeText: (text: string) => void;
iconButtonStyle: Record<string, any>;
}) => React.ReactNode)[];
boxStyle?: CSSProperties;
};

export default function Editor({
Expand All @@ -62,10 +65,12 @@ export default function Editor({
onBlur,
value,
placeholder = '',
placeholderPadding = '12px 14px',
bg = 'white',
isInvalid,

ExtensionPopover
onKeyDown,
ExtensionPopover,
boxStyle
}: EditorProps &
FormPropsType & {
onOpenModal?: () => void;
Expand Down Expand Up @@ -131,7 +136,8 @@ export default function Editor({
className={isInvalid ? styles.contentEditable_invalid : styles.contentEditable}
style={{
minHeight: `${minH}px`,
maxHeight: `${maxH}px`
maxHeight: `${maxH}px`,
...boxStyle
}}
/>
}
Expand All @@ -142,8 +148,7 @@ export default function Editor({
left={0}
right={0}
bottom={0}
py={3}
px={3.5}
p={placeholderPadding}
pointerEvents={'none'}
overflow={'hidden'}
>
Expand Down Expand Up @@ -178,6 +183,7 @@ export default function Editor({
<VariableLabelPickerPlugin variables={variableLabels} isFocus={focus} />
<VariablePickerPlugin variables={variableLabels.length > 0 ? [] : variables} />
<OnBlurPlugin onBlur={onBlur} />
<KeyDownPlugin onKeyDown={onKeyDown} />
</LexicalComposer>

{onChangeText &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const PromptEditor = ({
value,
onChange,
onBlur,
onKeyDown,
title,
isDisabled,
...props
Expand Down Expand Up @@ -59,6 +60,7 @@ const PromptEditor = ({
onChange={onChangeInput}
onChangeText={onChange}
onBlur={onBlurInput}
onKeyDown={onKeyDown}
/>
{isDisabled && (
<Box
Expand Down Expand Up @@ -91,6 +93,7 @@ const PromptEditor = ({
onChange={onChangeInput}
onChangeText={onChange}
onBlur={onBlurInput}
onKeyDown={onKeyDown}
/>
</ModalBody>
<ModalFooter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
import { KEY_DOWN_COMMAND, COMMAND_PRIORITY_HIGH } from 'lexical';
import { useEffect } from 'react';

export default function KeyDownPlugin({
onKeyDown
}: {
onKeyDown?: (e: React.KeyboardEvent) => void;
}) {
const [editor] = useLexicalComposerContext();

useEffect(() => {
if (!onKeyDown) return;

return editor.registerCommand(
KEY_DOWN_COMMAND,
(event: KeyboardEvent) => {
const syntheticEvent = {
key: event.key,
shiftKey: event.shiftKey,
ctrlKey: event.ctrlKey,
metaKey: event.metaKey,
altKey: event.altKey,
preventDefault: () => event.preventDefault(),
stopPropagation: () => event.stopPropagation(),
nativeEvent: event
} as React.KeyboardEvent;

onKeyDown(syntheticEvent);

return event.defaultPrevented;
},
COMMAND_PRIORITY_HIGH
);
}, [editor, onKeyDown]);

return null;
}
7 changes: 7 additions & 0 deletions packages/web/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
"app.version_past": "Previously Published",
"app.version_publish_tips": "This version will be saved to the team cloud, synchronized with the entire team, and update the app version on all release channels.",
"app_detail": "Application Details",
"apply_code": "Apply",
"auto_execute": "Automatic execution",
"auto_execute_default_prompt_placeholder": "Default questions sent when executing automatically",
"auto_execute_tip": "After turning it on, the workflow will be automatically triggered when the user enters the conversation interface. \nExecution order: 1. Dialogue starter; 2. Global variables; 3. Automatic execution.",
"auto_save": "Auto save",
"chat_debug": "Chat Preview",
"chat_logs": "Logs",
"chat_logs_tips": "Logs will record the online, shared, and API (requires chatId) conversation records of this app.",
"code_function_describe": "Describe your code function, enter \"/\" to select the variable",
"config_ai_model_params": "Click to configure AI model related properties",
"config_file_upload": "Click to Configure File Upload Rules",
"config_question_guide": "Configuration guess you want to ask",
Expand Down Expand Up @@ -256,6 +258,11 @@
"template_market": "Templates",
"template_market_description": "Explore more features in the template market, with configuration tutorials and usage guides to help you understand and get started with various applications.",
"template_market_empty_data": "No suitable templates found",
"test_all_passed": "All tests passed",
"test_code": "Test",
"test_code_incomplete": "The code parsing is incomplete and cannot be tested",
"test_execution_failed": "Test execution failed",
"test_failed_with_progress": "Test failed {{passed}}/{{total}}",
"time_zone": "Time Zone",
"too_to_active": "Active",
"tool_active_manual_config_desc": "The temporary key is saved in this application and is only for use by this application.",
Expand Down
7 changes: 7 additions & 0 deletions packages/web/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"all_result": "Full Results",
"app_evaluation": "App Evaluation(Beta)",
"app_not_version": "This application has not been published, please publish it first",
"apply_code_failed": "Failed to apply code",
"auth_config": "Authentication",
"auth_type": "Authentication type",
"auth_type.Custom": "Customize",
Expand All @@ -124,6 +125,7 @@
"click_select_avatar": "Click to Select Avatar",
"click_to_copy": "Click to copy",
"click_to_resume": "Click to Resume",
"code_applied_successfully": "Code applied successfully",
"code_editor": "Code Editor",
"code_error.account_error": "Incorrect account name or password",
"code_error.account_exist": "Account has been registered",
Expand Down Expand Up @@ -701,6 +703,7 @@
"core.workflow.Change input type tip": "Changing the input type will clear the filled values, please confirm!",
"core.workflow.Check Failed": "Workflow verification failed, please check whether the value is missing, and whether the connection is normal.",
"core.workflow.Confirm stop debug": "Confirm to Stop Debugging? Debug Information Will Not Be Retained.",
"core.workflow.Copilot": "AI Generation",
"core.workflow.Copy node": "Node Copied",
"core.workflow.Custom inputs": "Custom Inputs",
"core.workflow.Custom outputs": "Custom Outputs",
Expand Down Expand Up @@ -926,6 +929,7 @@
"next_step": "Next",
"no": "No",
"no_child_folder": "No Subdirectories, Place Here",
"no_code_to_apply": "No code to apply",
"no_intro": "No Introduction Available",
"no_laf_env": "System Not Configured with Laf Environment",
"no_more_data": "No More Data",
Expand Down Expand Up @@ -1012,6 +1016,7 @@
"read_quote": "View citations",
"redo_tip": "Redo ctrl shift z",
"redo_tip_mac": "Redo ⌘ shift z",
"reference_variable": "Reference variables",
"request_end": "All Loaded",
"request_error": "request_error",
"request_more": "Click to Load More",
Expand Down Expand Up @@ -1213,6 +1218,8 @@
"support.wallet.usage.App name": "App Name",
"support.wallet.usage.Audio Speech": "Voice Playback",
"support.wallet.usage.Bill Module": "Billing Module",
"support.wallet.usage.Code Copilot": "Code Copilot",
"support.wallet.usage.Code Test": "Generate test cases",
"support.wallet.usage.Duration": "Duration (seconds)",
"support.wallet.usage.Module name": "Module Name",
"support.wallet.usage.Optimize Prompt": "Prompt word optimization",
Expand Down
8 changes: 8 additions & 0 deletions packages/web/i18n/zh-CN/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
"app.version_past": "发布过",
"app.version_publish_tips": "该版本将被保存至团队云端,同步给整个团队,同时更新所有发布渠道的应用版本",
"app_detail": "应用详情",
"apply_code": "应用",
"auto_execute": "自动执行",
"auto_execute_default_prompt_placeholder": "自动执行时,发送的默认问题",
"auto_execute_tip": "开启后,用户进入对话界面将自动触发工作流。执行顺序:1、对话开场白;2、全局变量;3、自动执行。",
"auto_save": "自动保存",
"chat_debug": "调试预览",
"chat_logs": "对话日志",
"chat_logs_tips": "日志会记录该应用的在线、分享和 API(需填写 chatId)对话记录",
"code_function_describe": "描述你的代码功能,输入“/”可选择变量",
"config_ai_model_params": "点击配置 AI 模型相关属性",
"config_file_upload": "点击配置文件上传规则",
"config_question_guide": "配置猜你想问",
Expand Down Expand Up @@ -265,6 +267,12 @@
"template_market": "模板市场",
"template_market_description": "在模板市场探索更多玩法,配置教程与使用引导,带你理解并上手各种应用",
"template_market_empty_data": "找不到合适的模板",
"test_all_passed": "测试全部通过",
"test_code": "测试",
"test_code_incomplete": "代码解析不完整,无法进行测试",
"test_execution_failed": "测试执行失败",
"test_failed_with_progress": "测试失败 {{passed}}/{{total}}",
"testing": "测试中",
"time_zone": "时区",
"too_to_active": "去激活",
"tool_active_manual_config_desc": "临时密钥保存在本应用中,仅供该应用使用",
Expand Down
7 changes: 7 additions & 0 deletions packages/web/i18n/zh-CN/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"all_result": "完整结果",
"app_evaluation": "应用评测(Beta)",
"app_not_version": " 该应用未发布过,请先发布应用",
"apply_code_failed": "应用代码失败",
"auth_config": "鉴权配置",
"auth_type": "鉴权类型",
"auth_type.Custom": "自定义",
Expand All @@ -124,6 +125,7 @@
"click_select_avatar": "点击选择头像",
"click_to_copy": "点击复制",
"click_to_resume": "点击恢复",
"code_applied_successfully": "代码应用成功",
"code_editor": "代码编辑",
"code_error.account_error": "账号名或密码错误",
"code_error.account_exist": "账号已注册",
Expand Down Expand Up @@ -701,6 +703,7 @@
"core.workflow.Change input type tip": "修改输入类型会清空已填写的值,请确认!",
"core.workflow.Check Failed": "工作流校验失败,请检查是否缺失、缺值,连线是否正常",
"core.workflow.Confirm stop debug": "确认终止调试?调试信息将会不保留。",
"core.workflow.Copilot": "AI 生成",
"core.workflow.Copy node": "已复制节点",
"core.workflow.Custom inputs": "自定义输入",
"core.workflow.Custom outputs": "自定义输出",
Expand Down Expand Up @@ -926,6 +929,7 @@
"next_step": "下一步",
"no": "否",
"no_child_folder": "没有子目录了,就放这里吧",
"no_code_to_apply": "没有可应用的代码",
"no_intro": "暂无介绍",
"no_laf_env": "系统未配置Laf环境",
"no_more_data": "没有更多了~",
Expand Down Expand Up @@ -1012,6 +1016,7 @@
"read_quote": "查看引用",
"redo_tip": "恢复 ctrl shift z",
"redo_tip_mac": "恢复 ⌘ shift z",
"reference_variable": "引用变量",
"request_end": "已加载全部",
"request_error": "请求异常",
"request_more": "点击加载更多",
Expand Down Expand Up @@ -1214,6 +1219,8 @@
"support.wallet.usage.App name": "应用名",
"support.wallet.usage.Audio Speech": "语音播放",
"support.wallet.usage.Bill Module": "扣费模块",
"support.wallet.usage.Code Copilot": "代码助手",
"support.wallet.usage.Code Test": "生成测试用例",
"support.wallet.usage.Duration": "时长(秒)",
"support.wallet.usage.Module name": "模块名",
"support.wallet.usage.Optimize Prompt": "提示词优化",
Expand Down
Loading
Loading