mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-20 09:25:34 +00:00
Merge branch 'main' into stream_mode
This commit is contained in:
commit
9e40e979be
5 changed files with 410 additions and 298 deletions
103
.github/workflows/codeql.yml
vendored
Normal file
103
.github/workflows/codeql.yml
vendored
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL Advanced"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: '42 22 * * 5'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze (${{ matrix.language }})
|
||||
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
||||
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
||||
# - https://gh.io/supported-runners-and-hardware-resources
|
||||
# - https://gh.io/using-larger-runners (GitHub.com only)
|
||||
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
|
||||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
||||
permissions:
|
||||
# required for all workflows
|
||||
security-events: write
|
||||
|
||||
# required to fetch internal or private CodeQL packs
|
||||
packages: read
|
||||
|
||||
# only required for workflows in private repositories
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- language: actions
|
||||
build-mode: none
|
||||
- language: javascript-typescript
|
||||
build-mode: none
|
||||
- language: python
|
||||
build-mode: none
|
||||
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
|
||||
# Use `c-cpp` to analyze code written in C, C++ or both
|
||||
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
|
||||
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
||||
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
|
||||
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
|
||||
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
|
||||
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Add any setup steps before running the `github/codeql-action/init` action.
|
||||
# This includes steps like installing compilers or runtimes (`actions/setup-node`
|
||||
# or others). This is typically only required for manual builds.
|
||||
# - name: Setup runtime (example)
|
||||
# uses: actions/setup-example@v1
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v4
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
build-mode: ${{ matrix.build-mode }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
|
||||
# If the analyze step fails for one of the languages you are analyzing with
|
||||
# "We were unable to automatically build your code", modify the matrix above
|
||||
# to set the build mode to "manual" for that language. Then modify this step
|
||||
# to build your code.
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
- name: Run manual build steps
|
||||
if: matrix.build-mode == 'manual'
|
||||
shell: bash
|
||||
run: |
|
||||
echo 'If you are using a "manual" build mode for one or more of the' \
|
||||
'languages you are analyzing, replace this with the commands to build' \
|
||||
'your code, for example:'
|
||||
echo ' make bootstrap'
|
||||
echo ' make release'
|
||||
exit 1
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v4
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
|
@ -1521,7 +1521,6 @@ async def get_toolkits(tools: list[str], agent_name: str, api_task_id: str):
|
|||
toolkit_tools = await toolkit_tools if asyncio.iscoroutine(toolkit_tools) else toolkit_tools
|
||||
res.extend(toolkit_tools)
|
||||
else:
|
||||
logger.warning(f"Toolkit {item} not found, please check your configuration.")
|
||||
traceroot_logger.warning(f"Toolkit {item} not found for agent {agent_name}")
|
||||
return res
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,23 @@ def sync_step(func):
|
|||
value_json_str = value[len("data: ") :].strip()
|
||||
else:
|
||||
value_json_str = value
|
||||
json_data = json.loads(value_json_str)
|
||||
|
||||
|
||||
try:
|
||||
json_data = json.loads(value_json_str)
|
||||
except json.JSONDecodeError as e:
|
||||
logger.error(f"Failed to parse JSON in sync_step: {e}. Value: {value_json_str}")
|
||||
yield value
|
||||
continue
|
||||
|
||||
if "step" not in json_data or "data" not in json_data:
|
||||
logger.error(f"Missing 'step' or 'data' key in sync_step JSON. Keys: {list(json_data.keys())}")
|
||||
yield value
|
||||
continue
|
||||
|
||||
# Dynamic task_id extraction - prioritize runtime data over static args
|
||||
chat: Chat = args[0] if args and hasattr(args[0], 'task_id') else None
|
||||
task_id = None
|
||||
|
||||
|
||||
if chat is not None:
|
||||
task_lock = get_task_lock_if_exists(chat.project_id)
|
||||
if task_lock is not None:
|
||||
|
|
@ -38,7 +49,7 @@ def sync_step(func):
|
|||
else:
|
||||
logger.warning(f"Task lock not found for project_id {chat.project_id}, using chat.task_id")
|
||||
task_id = chat.task_id
|
||||
|
||||
|
||||
if task_id:
|
||||
asyncio.create_task(
|
||||
send_to_api(
|
||||
|
|
@ -62,4 +73,4 @@ async def send_to_api(url, data):
|
|||
res = await client.post(url, json=data)
|
||||
# logger.info(res)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error(f"Failed to sync step to {url}: {type(e).__name__}: {e}")
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ export default function SettingModels() {
|
|||
INIT_PROVODERS.filter((p) => p.id !== "local").map(() => false)
|
||||
);
|
||||
const [loading, setLoading] = useState<number | null>(null);
|
||||
const [errors, setErrors] = useState<
|
||||
{ apiKey?: string; apiHost?: string; model_type?: string; externalConfig?: string }[]
|
||||
>(() =>
|
||||
const [errors, setErrors] = useState<
|
||||
{ apiKey?: string; apiHost?: string; model_type?: string; externalConfig?: string }[]
|
||||
>(() =>
|
||||
INIT_PROVODERS.filter((p) => p.id !== "local").map(() => ({
|
||||
apiKey: "",
|
||||
apiHost: "",
|
||||
|
|
@ -123,14 +123,14 @@ const [errors, setErrors] = useState<
|
|||
model_type: found.model_type ?? "",
|
||||
externalConfig: fi.externalConfig
|
||||
? fi.externalConfig.map((ec) => {
|
||||
if (
|
||||
found.encrypted_config &&
|
||||
found.encrypted_config[ec.key] !== undefined
|
||||
) {
|
||||
return { ...ec, value: found.encrypted_config[ec.key] };
|
||||
}
|
||||
return ec;
|
||||
})
|
||||
if (
|
||||
found.encrypted_config &&
|
||||
found.encrypted_config[ec.key] !== undefined
|
||||
) {
|
||||
return { ...ec, value: found.encrypted_config[ec.key] };
|
||||
}
|
||||
return ec;
|
||||
})
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
|
@ -146,8 +146,8 @@ const [errors, setErrors] = useState<
|
|||
setLocalEndpoint(local.endpoint_url || "");
|
||||
setLocalPlatform(
|
||||
local.encrypted_config?.model_platform ||
|
||||
local.provider_name ||
|
||||
"ollama"
|
||||
local.provider_name ||
|
||||
"ollama"
|
||||
);
|
||||
setLocalType(local.encrypted_config?.model_type || "llama3.2");
|
||||
setLocalEnabled(local.is_valid ?? true);
|
||||
|
|
@ -216,7 +216,7 @@ const [errors, setErrors] = useState<
|
|||
}
|
||||
|
||||
console.log(form[idx]);
|
||||
try {
|
||||
try {
|
||||
const res = await fetchPost("/model/validate", {
|
||||
model_platform: item.id,
|
||||
model_type: form[idx].model_type,
|
||||
|
|
@ -224,7 +224,7 @@ const [errors, setErrors] = useState<
|
|||
url: form[idx].apiHost,
|
||||
extra_params: external,
|
||||
});
|
||||
if (res.is_tool_calls && res.is_valid) {
|
||||
if (res.is_tool_calls && res.is_valid) {
|
||||
console.log("success");
|
||||
toast(t("setting.validate-success"), {
|
||||
description: t(
|
||||
|
|
@ -233,27 +233,27 @@ const [errors, setErrors] = useState<
|
|||
closeButton: true,
|
||||
});
|
||||
} else {
|
||||
console.log("failed", res.message);
|
||||
// Surface error inline on API Key input
|
||||
setErrors((prev) => {
|
||||
const next = [...prev];
|
||||
if (!next[idx]) next[idx] = {} as any;
|
||||
next[idx].apiKey = getValidateMessage(res);
|
||||
return next;
|
||||
});
|
||||
return;
|
||||
console.log("failed", res.message);
|
||||
// Surface error inline on API Key input
|
||||
setErrors((prev) => {
|
||||
const next = [...prev];
|
||||
if (!next[idx]) next[idx] = {} as any;
|
||||
next[idx].apiKey = getValidateMessage(res);
|
||||
return next;
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log(res);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
// Network/exception case: show inline error
|
||||
setErrors((prev) => {
|
||||
const next = [...prev];
|
||||
if (!next[idx]) next[idx] = {} as any;
|
||||
next[idx].apiKey = getValidateMessage(e);
|
||||
return next;
|
||||
});
|
||||
return;
|
||||
console.log(e);
|
||||
// Network/exception case: show inline error
|
||||
setErrors((prev) => {
|
||||
const next = [...prev];
|
||||
if (!next[idx]) next[idx] = {} as any;
|
||||
next[idx].apiKey = getValidateMessage(e);
|
||||
return next;
|
||||
});
|
||||
return;
|
||||
} finally {
|
||||
setLoading(null);
|
||||
}
|
||||
|
|
@ -296,14 +296,14 @@ const [errors, setErrors] = useState<
|
|||
prefer: found.prefer ?? false,
|
||||
externalConfig: fi.externalConfig
|
||||
? fi.externalConfig.map((ec) => {
|
||||
if (
|
||||
found.encrypted_config &&
|
||||
found.encrypted_config[ec.key] !== undefined
|
||||
) {
|
||||
return { ...ec, value: found.encrypted_config[ec.key] };
|
||||
}
|
||||
return ec;
|
||||
})
|
||||
if (
|
||||
found.encrypted_config &&
|
||||
found.encrypted_config[ec.key] !== undefined
|
||||
) {
|
||||
return { ...ec, value: found.encrypted_config[ec.key] };
|
||||
}
|
||||
return ec;
|
||||
})
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
|
@ -436,8 +436,8 @@ const [errors, setErrors] = useState<
|
|||
setLocalPrefer(local.prefer ?? false);
|
||||
setLocalPlatform(
|
||||
local.encrypted_config?.model_platform ||
|
||||
local.provider_name ||
|
||||
localPlatform
|
||||
local.provider_name ||
|
||||
localPlatform
|
||||
);
|
||||
await handleLocalSwitch(true, local.id);
|
||||
}
|
||||
|
|
@ -583,7 +583,7 @@ const [errors, setErrors] = useState<
|
|||
}
|
||||
};
|
||||
|
||||
// removed bulk reset; only single-provider delete is supported
|
||||
// removed bulk reset; only single-provider delete is supported
|
||||
|
||||
const checkHasSearchKey = async () => {
|
||||
const configsRes = await proxyFetchGet("/api/configs");
|
||||
|
|
@ -630,37 +630,37 @@ const [errors, setErrors] = useState<
|
|||
<div className="flex-1 justify-center text-body-lg text-text-heading font-bold">
|
||||
{t("setting.eigent-cloud-version")}
|
||||
</div>
|
||||
{cloudPrefer ? (
|
||||
<Button
|
||||
variant="success"
|
||||
size="sm"
|
||||
className="focus-none"
|
||||
onClick={() => {
|
||||
// currently selected -> unselect
|
||||
setCloudPrefer(false);
|
||||
setModelType("custom");
|
||||
}}
|
||||
>
|
||||
Default
|
||||
<Check/>
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="!text-text-label"
|
||||
onClick={() => {
|
||||
// not selected -> select cloud prefer
|
||||
setLocalPrefer(false);
|
||||
setActiveModelIdx(null);
|
||||
setForm((f) => f.map((fi) => ({ ...fi, prefer: false })));
|
||||
setCloudPrefer(true);
|
||||
setModelType("cloud");
|
||||
}}
|
||||
>
|
||||
Set as Default
|
||||
</Button>
|
||||
)}
|
||||
{cloudPrefer ? (
|
||||
<Button
|
||||
variant="success"
|
||||
size="sm"
|
||||
className="focus-none"
|
||||
onClick={() => {
|
||||
// currently selected -> unselect
|
||||
setCloudPrefer(false);
|
||||
setModelType("custom");
|
||||
}}
|
||||
>
|
||||
Default
|
||||
<Check />
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="!text-text-label"
|
||||
onClick={() => {
|
||||
// not selected -> select cloud prefer
|
||||
setLocalPrefer(false);
|
||||
setActiveModelIdx(null);
|
||||
setForm((f) => f.map((fi) => ({ ...fi, prefer: false })));
|
||||
setCloudPrefer(true);
|
||||
setModelType("cloud");
|
||||
}}
|
||||
>
|
||||
Set as Default
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div className="self-stretch justify-center">
|
||||
<span className="text-text-label text-body-sm">
|
||||
|
|
@ -726,20 +726,22 @@ const [errors, setErrors] = useState<
|
|||
{cloud_model_type === "gpt-4.1-mini"
|
||||
? t("setting.gpt-4.1-mini")
|
||||
: cloud_model_type === "gpt-4.1"
|
||||
? t("setting.gpt-4.1")
|
||||
: cloud_model_type === "claude-sonnet-4-5"
|
||||
? t("setting.claude-sonnet-4-5")
|
||||
: cloud_model_type === "claude-sonnet-4-20250514"
|
||||
? t("setting.claude-sonnet-4")
|
||||
: cloud_model_type === "claude-3-5-haiku-20241022"
|
||||
? t("setting.claude-3.5-haiku")
|
||||
: cloud_model_type === "gemini-3-pro-preview"
|
||||
? t("setting.gemini-3-pro-preview")
|
||||
: cloud_model_type === "gpt-5"
|
||||
? t("setting.gpt-5")
|
||||
: cloud_model_type === "gpt-5-mini"
|
||||
? t("setting.gpt-5-mini")
|
||||
: t("setting.gemini-2.5-pro")}
|
||||
? t("setting.gpt-4.1")
|
||||
: cloud_model_type === "claude-sonnet-4-5"
|
||||
? t("setting.claude-sonnet-4-5")
|
||||
: cloud_model_type === "claude-sonnet-4-20250514"
|
||||
? t("setting.claude-sonnet-4")
|
||||
: cloud_model_type === "claude-3-5-haiku-20241022"
|
||||
? t("setting.claude-3.5-haiku")
|
||||
: cloud_model_type === "gemini-3-pro-preview"
|
||||
? t("setting.gemini-3-pro-preview")
|
||||
: cloud_model_type === "gpt-5"
|
||||
? t("setting.gpt-5")
|
||||
: cloud_model_type === "gpt-5-mini"
|
||||
? t("setting.gpt-5-mini")
|
||||
: cloud_model_type === "gemini-3-flash-preview"
|
||||
? t("setting.gemini-3-flash-preview")
|
||||
: t("setting.gemini-2.5-pro")}
|
||||
</span>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
|
|
@ -756,6 +758,7 @@ const [errors, setErrors] = useState<
|
|||
<SelectItem value="gemini/gemini-2.5-pro">Gemini 2.5 Pro</SelectItem>
|
||||
<SelectItem value="gemini-2.5-flash">Gemini 2.5 Flash</SelectItem>
|
||||
<SelectItem value="gemini-3-pro-preview">Gemini 3 Pro Preview</SelectItem>
|
||||
<SelectItem value="gemini-3-flash-preview">Gemini 3 Flash Preview</SelectItem>
|
||||
<SelectItem value="gpt-4.1-mini">GPT-4.1 mini</SelectItem>
|
||||
<SelectItem value="gpt-4.1">GPT-4.1</SelectItem>
|
||||
<SelectItem value="gpt-5">GPT-5</SelectItem>
|
||||
|
|
@ -779,14 +782,14 @@ const [errors, setErrors] = useState<
|
|||
<div className="self-stretch my-2 border-border-disabled inline-flex flex-col justify-start items-start border-x-0 border-solid">
|
||||
{/* header */}
|
||||
<div className="sticky top-[87px] py-2 z-10 bg-surface-tertiary self-stretch inline-flex justify-start items-start gap-2 pl-6 pr-2 my-6 border-y-0 border-r-0 border-solid border-border-secondary">
|
||||
<div className="flex flex-col w-full items-start gap-1">
|
||||
<span className="justify-center text-text-body text-body-md font-bold">
|
||||
{t("setting.custom-model")}
|
||||
</span>
|
||||
<span className="justify-center text-text-body text-label-sm font-normal">
|
||||
{t("setting.use-your-own-api-keys-or-set-up-a-local-model")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-col w-full items-start gap-1">
|
||||
<span className="justify-center text-text-body text-body-md font-bold">
|
||||
{t("setting.custom-model")}
|
||||
</span>
|
||||
<span className="justify-center text-text-body text-label-sm font-normal">
|
||||
{t("setting.use-your-own-api-keys-or-set-up-a-local-model")}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="md"
|
||||
|
|
@ -806,11 +809,10 @@ const [errors, setErrors] = useState<
|
|||
|
||||
{/* model list */}
|
||||
<div
|
||||
className={`self-stretch inline-flex flex-col justify-start items-start gap-8 transition-all duration-300 ease-in-out overflow-hidden ${
|
||||
collapsed
|
||||
? "max-h-0 opacity-0 pointer-events-none"
|
||||
: "opacity-100"
|
||||
}`}
|
||||
className={`self-stretch inline-flex flex-col justify-start items-start gap-8 transition-all duration-300 ease-in-out overflow-hidden ${collapsed
|
||||
? "max-h-0 opacity-0 pointer-events-none"
|
||||
: "opacity-100"
|
||||
}`}
|
||||
style={{
|
||||
transform: collapsed ? "translateY(-10px)" : "translateY(0)",
|
||||
}}
|
||||
|
|
@ -823,119 +825,116 @@ const [errors, setErrors] = useState<
|
|||
className="w-full bg-surface-secondary rounded-2xl overflow-hidden"
|
||||
>
|
||||
<div className="flex flex-col justify-between items-start gap-1 px-6 py-4">
|
||||
<div className="self-stretch inline-flex justify-between items-center gap-2">
|
||||
<div className="self-stretch inline-flex justify-between items-center gap-2">
|
||||
<div className="flex-1 justify-center text-body-lg text-text-heading font-bold">
|
||||
{item.name}
|
||||
</div>
|
||||
{form[idx].prefer ? (
|
||||
<Button
|
||||
variant="success"
|
||||
size="sm"
|
||||
className="focus-none"
|
||||
disabled={!canSwitch || loading === idx}
|
||||
onClick={() => handleSwitch(idx, false)}
|
||||
>
|
||||
Default
|
||||
<Check />
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={!canSwitch || loading === idx}
|
||||
onClick={() => handleSwitch(idx, true)}
|
||||
className={canSwitch ? "!text-text-label" : ""}
|
||||
>
|
||||
{!canSwitch ? "Not Configured" : "Set as Default"}
|
||||
</Button>
|
||||
)}
|
||||
{form[idx].prefer ? (
|
||||
<Button
|
||||
variant="success"
|
||||
size="sm"
|
||||
className="focus-none"
|
||||
disabled={!canSwitch || loading === idx}
|
||||
onClick={() => handleSwitch(idx, false)}
|
||||
>
|
||||
Default
|
||||
<Check />
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={!canSwitch || loading === idx}
|
||||
onClick={() => handleSwitch(idx, true)}
|
||||
className={canSwitch ? "!text-text-label" : ""}
|
||||
>
|
||||
{!canSwitch ? "Not Configured" : "Set as Default"}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-body-sm text-text-label">
|
||||
{item.description}
|
||||
</div>
|
||||
{item.description}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col w-full items-center gap-4 px-6">
|
||||
{/* API Key Setting */}
|
||||
<Input
|
||||
id={`apiKey-${item.id}`}
|
||||
type={showApiKey[idx] ? "text" : "password"}
|
||||
size="default"
|
||||
title="API Key Setting"
|
||||
state={errors[idx]?.apiKey ? "error" : "default"}
|
||||
note={errors[idx]?.apiKey ?? undefined}
|
||||
placeholder={` ${t("setting.enter-your-api-key")} ${
|
||||
item.name
|
||||
} ${t("setting.key")}`}
|
||||
backIcon={showApiKey[idx] ? <Eye className="w-5 h-5" /> : <EyeOff className="w-5 h-5" />}
|
||||
onBackIconClick={() =>
|
||||
setShowApiKey((arr) => arr.map((v, i) => (i === idx ? !v : v)))
|
||||
}
|
||||
value={form[idx].apiKey}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
setForm((f) =>
|
||||
f.map((fi, i) =>
|
||||
i === idx ? { ...fi, apiKey: v } : fi
|
||||
)
|
||||
);
|
||||
setErrors((errs) =>
|
||||
errs.map((er, i) =>
|
||||
i === idx ? { ...er, apiKey: "" } : er
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/* API Host Setting */}
|
||||
<Input
|
||||
id={`apiHost-${item.id}`}
|
||||
size="default"
|
||||
title="API Host Setting"
|
||||
state={errors[idx]?.apiHost ? "error" : "default"}
|
||||
note={errors[idx]?.apiHost ?? undefined}
|
||||
placeholder={`${t("setting.enter-your-api-host")} ${
|
||||
item.name
|
||||
{/* API Key Setting */}
|
||||
<Input
|
||||
id={`apiKey-${item.id}`}
|
||||
type={showApiKey[idx] ? "text" : "password"}
|
||||
size="default"
|
||||
title="API Key Setting"
|
||||
state={errors[idx]?.apiKey ? "error" : "default"}
|
||||
note={errors[idx]?.apiKey ?? undefined}
|
||||
placeholder={` ${t("setting.enter-your-api-key")} ${item.name
|
||||
} ${t("setting.key")}`}
|
||||
backIcon={showApiKey[idx] ? <Eye className="w-5 h-5" /> : <EyeOff className="w-5 h-5" />}
|
||||
onBackIconClick={() =>
|
||||
setShowApiKey((arr) => arr.map((v, i) => (i === idx ? !v : v)))
|
||||
}
|
||||
value={form[idx].apiKey}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
setForm((f) =>
|
||||
f.map((fi, i) =>
|
||||
i === idx ? { ...fi, apiKey: v } : fi
|
||||
)
|
||||
);
|
||||
setErrors((errs) =>
|
||||
errs.map((er, i) =>
|
||||
i === idx ? { ...er, apiKey: "" } : er
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/* API Host Setting */}
|
||||
<Input
|
||||
id={`apiHost-${item.id}`}
|
||||
size="default"
|
||||
title="API Host Setting"
|
||||
state={errors[idx]?.apiHost ? "error" : "default"}
|
||||
note={errors[idx]?.apiHost ?? undefined}
|
||||
placeholder={`${t("setting.enter-your-api-host")} ${item.name
|
||||
} ${t("setting.url")}`}
|
||||
value={form[idx].apiHost}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
setForm((f) =>
|
||||
f.map((fi, i) =>
|
||||
i === idx ? { ...fi, apiHost: v } : fi
|
||||
)
|
||||
);
|
||||
setErrors((errs) =>
|
||||
errs.map((er, i) =>
|
||||
i === idx ? { ...er, apiHost: "" } : er
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/* Model Type Setting */}
|
||||
<Input
|
||||
id={`modelType-${item.id}`}
|
||||
size="default"
|
||||
title="Model Type Setting"
|
||||
state={errors[idx]?.model_type ? "error" : "default"}
|
||||
note={errors[idx]?.model_type ?? undefined}
|
||||
placeholder={`${t("setting.enter-your-model-type")} ${
|
||||
item.name
|
||||
value={form[idx].apiHost}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
setForm((f) =>
|
||||
f.map((fi, i) =>
|
||||
i === idx ? { ...fi, apiHost: v } : fi
|
||||
)
|
||||
);
|
||||
setErrors((errs) =>
|
||||
errs.map((er, i) =>
|
||||
i === idx ? { ...er, apiHost: "" } : er
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/* Model Type Setting */}
|
||||
<Input
|
||||
id={`modelType-${item.id}`}
|
||||
size="default"
|
||||
title="Model Type Setting"
|
||||
state={errors[idx]?.model_type ? "error" : "default"}
|
||||
note={errors[idx]?.model_type ?? undefined}
|
||||
placeholder={`${t("setting.enter-your-model-type")} ${item.name
|
||||
} ${t("setting.model-type")}`}
|
||||
value={form[idx].model_type}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
setForm((f) =>
|
||||
f.map((fi, i) =>
|
||||
i === idx ? { ...fi, model_type: v } : fi
|
||||
)
|
||||
);
|
||||
setErrors((errs) =>
|
||||
errs.map((er, i) =>
|
||||
i === idx ? { ...er, model_type: "" } : er
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/* externalConfig render */}
|
||||
value={form[idx].model_type}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
setForm((f) =>
|
||||
f.map((fi, i) =>
|
||||
i === idx ? { ...fi, model_type: v } : fi
|
||||
)
|
||||
);
|
||||
setErrors((errs) =>
|
||||
errs.map((er, i) =>
|
||||
i === idx ? { ...er, model_type: "" } : er
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/* externalConfig render */}
|
||||
{item.externalConfig &&
|
||||
form[idx].externalConfig &&
|
||||
form[idx].externalConfig.map((ec, ecIdx) => (
|
||||
|
|
@ -948,14 +947,14 @@ const [errors, setErrors] = useState<
|
|||
f.map((fi, i) =>
|
||||
i === idx
|
||||
? {
|
||||
...fi,
|
||||
externalConfig: fi.externalConfig?.map(
|
||||
(eec, i2) =>
|
||||
i2 === ecIdx
|
||||
? { ...eec, value: v }
|
||||
: eec
|
||||
),
|
||||
}
|
||||
...fi,
|
||||
externalConfig: fi.externalConfig?.map(
|
||||
(eec, i2) =>
|
||||
i2 === ecIdx
|
||||
? { ...eec, value: v }
|
||||
: eec
|
||||
),
|
||||
}
|
||||
: fi
|
||||
)
|
||||
);
|
||||
|
|
@ -985,14 +984,14 @@ const [errors, setErrors] = useState<
|
|||
f.map((fi, i) =>
|
||||
i === idx
|
||||
? {
|
||||
...fi,
|
||||
externalConfig: fi.externalConfig?.map(
|
||||
(eec, i2) =>
|
||||
i2 === ecIdx
|
||||
? { ...eec, value: v }
|
||||
: eec
|
||||
),
|
||||
}
|
||||
...fi,
|
||||
externalConfig: fi.externalConfig?.map(
|
||||
(eec, i2) =>
|
||||
i2 === ecIdx
|
||||
? { ...eec, value: v }
|
||||
: eec
|
||||
),
|
||||
}
|
||||
: fi
|
||||
)
|
||||
);
|
||||
|
|
@ -1002,9 +1001,9 @@ const [errors, setErrors] = useState<
|
|||
</div>
|
||||
))}
|
||||
</div>
|
||||
{/* Action Button */}
|
||||
{/* Action Button */}
|
||||
<div className="flex justify-end mt-6 px-6 py-4 gap-2 border-b-0 border-x-0 border-solid border-border-secondary">
|
||||
<Button variant="ghost" size="sm" className="!text-text-label" onClick={() => handleDelete(idx)}>{t("setting.reset")}</Button>
|
||||
<Button variant="ghost" size="sm" className="!text-text-label" onClick={() => handleDelete(idx)}>{t("setting.reset")}</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
size="sm"
|
||||
|
|
@ -1050,48 +1049,48 @@ const [errors, setErrors] = useState<
|
|||
</div>
|
||||
<div className="flex flex-col gap-4 px-6">
|
||||
|
||||
<Select
|
||||
value={localPlatform}
|
||||
onValueChange={(v) => {
|
||||
console.log(v);
|
||||
setLocalPlatform(v);
|
||||
}}
|
||||
disabled={!localEnabled}
|
||||
>
|
||||
<SelectTrigger size="default" title={t("setting.model-platform")} state={localInputError ? "error" : undefined} note={localError ?? undefined}>
|
||||
<SelectValue placeholder="Select platform" />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="bg-white-100%">
|
||||
<SelectItem value="ollama">Ollama</SelectItem>
|
||||
<SelectItem value="vllm">vLLM</SelectItem>
|
||||
<SelectItem value="sglang">Sglang</SelectItem>
|
||||
<SelectItem value="lmstudio">LMStudio</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select
|
||||
value={localPlatform}
|
||||
onValueChange={(v) => {
|
||||
console.log(v);
|
||||
setLocalPlatform(v);
|
||||
}}
|
||||
disabled={!localEnabled}
|
||||
>
|
||||
<SelectTrigger size="default" title={t("setting.model-platform")} state={localInputError ? "error" : undefined} note={localError ?? undefined}>
|
||||
<SelectValue placeholder="Select platform" />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="bg-white-100%">
|
||||
<SelectItem value="ollama">Ollama</SelectItem>
|
||||
<SelectItem value="vllm">vLLM</SelectItem>
|
||||
<SelectItem value="sglang">Sglang</SelectItem>
|
||||
<SelectItem value="lmstudio">LMStudio</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
<Input
|
||||
size="default"
|
||||
title={t("setting.model-endpoint-url")}
|
||||
state={localInputError ? "error" : "default"}
|
||||
value={localEndpoint}
|
||||
onChange={(e) => {
|
||||
setLocalEndpoint(e.target.value);
|
||||
setLocalInputError(false);
|
||||
setLocalError(null);
|
||||
}}
|
||||
disabled={!localEnabled}
|
||||
placeholder="http://localhost:11434/v1"
|
||||
note={localError ?? undefined}
|
||||
/>
|
||||
<Input
|
||||
size="default"
|
||||
title={t("setting.model-type")}
|
||||
state={localInputError ? "error" : "default"}
|
||||
placeholder={t("setting.enter-your-local-model-type")}
|
||||
value={localType}
|
||||
onChange={(e) => setLocalType(e.target.value)}
|
||||
disabled={!localEnabled}
|
||||
/>
|
||||
<Input
|
||||
size="default"
|
||||
title={t("setting.model-endpoint-url")}
|
||||
state={localInputError ? "error" : "default"}
|
||||
value={localEndpoint}
|
||||
onChange={(e) => {
|
||||
setLocalEndpoint(e.target.value);
|
||||
setLocalInputError(false);
|
||||
setLocalError(null);
|
||||
}}
|
||||
disabled={!localEnabled}
|
||||
placeholder="http://localhost:11434/v1"
|
||||
note={localError ?? undefined}
|
||||
/>
|
||||
<Input
|
||||
size="default"
|
||||
title={t("setting.model-type")}
|
||||
state={localInputError ? "error" : "default"}
|
||||
placeholder={t("setting.enter-your-local-model-type")}
|
||||
value={localType}
|
||||
onChange={(e) => setLocalType(e.target.value)}
|
||||
disabled={!localEnabled}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-end mt-2 px-6 py-4 gap-2 border-b-0 border-x-0 border-solid border-border-secondary">
|
||||
<Button variant="ghost" size="sm" className="!text-text-label" onClick={handleLocalReset}>{t("setting.reset")}</Button>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { persist } from 'zustand/middleware';
|
|||
// type definition
|
||||
type InitState = 'permissions' | 'carousel' | 'done';
|
||||
type ModelType = 'cloud' | 'local' | 'custom';
|
||||
type CloudModelType = 'gemini/gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-3-pro-preview' | 'gpt-4.1-mini' | 'gpt-4.1' | 'claude-sonnet-4-5' | 'claude-sonnet-4-20250514' | 'claude-3-5-haiku-20241022' | 'gpt-5' | 'gpt-5-mini';
|
||||
type CloudModelType = 'gemini/gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-3-pro-preview' | 'gemini-3-flash-preview' | 'gpt-4.1-mini' | 'gpt-4.1' | 'claude-sonnet-4-5' | 'claude-sonnet-4-20250514' | 'claude-3-5-haiku-20241022' | 'gpt-5' | 'gpt-5-mini';
|
||||
|
||||
// auth info interface
|
||||
interface AuthInfo {
|
||||
|
|
@ -21,7 +21,7 @@ interface AuthState {
|
|||
username: string | null;
|
||||
email: string | null;
|
||||
user_id: number | null;
|
||||
|
||||
|
||||
// application settings
|
||||
appearance: string;
|
||||
language: string;
|
||||
|
|
@ -29,21 +29,21 @@ interface AuthState {
|
|||
modelType: ModelType;
|
||||
cloud_model_type: CloudModelType;
|
||||
initState: InitState;
|
||||
|
||||
|
||||
// shared token
|
||||
share_token?: string | null;
|
||||
|
||||
|
||||
// local proxy value recorded at login
|
||||
localProxyValue?: string | null;
|
||||
|
||||
|
||||
// worker list data
|
||||
workerListData: { [key: string]: Agent[] };
|
||||
|
||||
// auth related methods
|
||||
setAuth: (auth: AuthInfo) => void;
|
||||
logout: () => void;
|
||||
setLocalProxyValue: (value: string | null) => void;
|
||||
|
||||
|
||||
// auth related methods
|
||||
setAuth: (auth: AuthInfo) => void;
|
||||
logout: () => void;
|
||||
setLocalProxyValue: (value: string | null) => void;
|
||||
|
||||
// set related methods
|
||||
setAppearance: (appearance: string) => void;
|
||||
setLanguage: (language: string) => void;
|
||||
|
|
@ -51,7 +51,7 @@ interface AuthState {
|
|||
setModelType: (modelType: ModelType) => void;
|
||||
setCloudModelType: (cloud_model_type: CloudModelType) => void;
|
||||
setIsFirstLaunch: (isFirstLaunch: boolean) => void;
|
||||
|
||||
|
||||
// worker related methods
|
||||
setWorkerList: (workerList: Agent[]) => void;
|
||||
checkAgentTool: (tool: string) => void;
|
||||
|
|
@ -75,7 +75,7 @@ const authStore = create<AuthState>()(
|
|||
share_token: null,
|
||||
localProxyValue: null,
|
||||
workerListData: {},
|
||||
|
||||
|
||||
// auth related methods
|
||||
setAuth: ({ token, username, email, user_id }) =>
|
||||
set({ token, username, email, user_id }),
|
||||
|
|
@ -89,25 +89,25 @@ const authStore = create<AuthState>()(
|
|||
initState: 'carousel',
|
||||
localProxyValue: null
|
||||
}),
|
||||
|
||||
|
||||
// set related methods
|
||||
setAppearance: (appearance) => set({ appearance }),
|
||||
|
||||
|
||||
setLanguage: (language) => set({ language }),
|
||||
|
||||
|
||||
setInitState: (initState) => {
|
||||
console.log('set({ initState })', initState);
|
||||
set({ initState });
|
||||
},
|
||||
|
||||
|
||||
setModelType: (modelType) => set({ modelType }),
|
||||
|
||||
|
||||
setCloudModelType: (cloud_model_type) => set({ cloud_model_type }),
|
||||
|
||||
|
||||
setIsFirstLaunch: (isFirstLaunch) => set({ isFirstLaunch }),
|
||||
|
||||
|
||||
setLocalProxyValue: (value) => set({ localProxyValue: value }),
|
||||
|
||||
|
||||
// worker related methods
|
||||
setWorkerList: (workerList) => {
|
||||
const { email } = get();
|
||||
|
|
@ -119,15 +119,15 @@ const authStore = create<AuthState>()(
|
|||
}
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
checkAgentTool: (tool) => {
|
||||
const { email } = get();
|
||||
set((state) => {
|
||||
const currentEmail = email as string;
|
||||
const originalList = state.workerListData[currentEmail] ?? [];
|
||||
|
||||
|
||||
console.log("tool!!!", tool);
|
||||
|
||||
|
||||
const updatedList = originalList
|
||||
.map((worker) => {
|
||||
const filteredTools = worker.tools?.filter((t) => t !== tool) ?? [];
|
||||
|
|
@ -135,9 +135,9 @@ const authStore = create<AuthState>()(
|
|||
return { ...worker, tools: filteredTools };
|
||||
})
|
||||
.filter((worker) => worker.tools.length > 0);
|
||||
|
||||
|
||||
console.log("updatedList", updatedList);
|
||||
|
||||
|
||||
return {
|
||||
...state,
|
||||
workerListData: {
|
||||
|
|
@ -182,4 +182,4 @@ export const useWorkerList = (): Agent[] => {
|
|||
const { email, workerListData } = getAuthStore();
|
||||
const workerList = workerListData[email as string];
|
||||
return workerList ?? EMPTY_LIST;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue