diff --git a/src/lib/common/LiveChatEntry.svelte b/src/lib/common/LiveChatEntry.svelte index 34debebf..4ea9c074 100644 --- a/src/lib/common/LiveChatEntry.svelte +++ b/src/lib/common/LiveChatEntry.svelte @@ -2,19 +2,15 @@ import { fade } from 'svelte/transition'; import { onMount } from 'svelte'; import { PUBLIC_LIVECHAT_HOST, PUBLIC_LIVECHAT_ENTRY_ICON } from '$env/static/public'; - import { getAgents } from '$lib/services/agent-service.js' + import { getSettingDetail } from '$lib/services/setting-service'; let showChatIcon = false; let showChatBox = false; let chatUrl = PUBLIC_LIVECHAT_HOST; - /** @type {import('$types').AgentModel} */ - let agent; - onMount(async () => { - let agents = await getAgents({isRouter: true}); - agent = agents[0]; - chatUrl = `${PUBLIC_LIVECHAT_HOST}/chat/${agent.id}`; + const agentSettings = await getSettingDetail("Agent"); + chatUrl = `${PUBLIC_LIVECHAT_HOST}/chat/${agentSettings.hostAgentId}`; showChatIcon = true; }); diff --git a/src/lib/helpers/types.js b/src/lib/helpers/types.js index c10d4c75..002d5c04 100644 --- a/src/lib/helpers/types.js +++ b/src/lib/helpers/types.js @@ -55,6 +55,7 @@ * @property {string} name * @property {string} content */ + /** * @typedef {Object} AgentLlmConfig * @property {boolean} is_inherit - Inherited from default Agent settings @@ -62,6 +63,12 @@ * @property {string} model */ +/** + * @typedef {Object} LlmModelSetting + * @property {string} name + * @property {string} type + */ + /** * @typedef {Object} FunctionDef * @property {string} name diff --git a/src/lib/services/api-endpoints.js b/src/lib/services/api-endpoints.js index 17f39634..03a77f39 100644 --- a/src/lib/services/api-endpoints.js +++ b/src/lib/services/api-endpoints.js @@ -34,6 +34,10 @@ export const endpoints = { conversationDetailUrl: `${host}/conversation/{conversationId}`, dialogsUrl: `${host}/conversation/{conversationId}/dialogs`, + // LLM provider + llmProvidersUrl: `${host}/llm-providers`, + llmProviderModelsUrl: `${host}/llm-provider/{provider}/models`, + // logging loggingFullLogUrl: `${host}/logger/full-log`, diff --git a/src/lib/services/llm-provider-service.js b/src/lib/services/llm-provider-service.js new file mode 100644 index 00000000..a430363f --- /dev/null +++ b/src/lib/services/llm-provider-service.js @@ -0,0 +1,24 @@ +import { endpoints } from './api-endpoints.js'; +import { replaceUrl } from '$lib/helpers/http.js'; +import axios from 'axios'; + +/** + * Get provider list + * @returns {Promise} + */ +export async function getLlmProviders() { + let url = endpoints.llmProvidersUrl; + const response = await axios.get(url); + return response.data; +} + +/** + * Get provider model list + * @param {string} provider + * @returns {Promise} + */ +export async function getLlmProviderModels(provider) { + let url = replaceUrl(endpoints.llmProviderModelsUrl, {provider: provider}); + const response = await axios.get(url); + return response.data; +} \ No newline at end of file diff --git a/src/routes/page/agent/[agentId]/+page.svelte b/src/routes/page/agent/[agentId]/+page.svelte index 1c303461..75ac7215 100644 --- a/src/routes/page/agent/[agentId]/+page.svelte +++ b/src/routes/page/agent/[agentId]/+page.svelte @@ -34,14 +34,16 @@ {#if agent} - + - + - + + + {/if} diff --git a/src/routes/page/agent/[agentId]/agent-llm-config.svelte b/src/routes/page/agent/[agentId]/agent-llm-config.svelte index dcea3b32..a6303a6b 100644 --- a/src/routes/page/agent/[agentId]/agent-llm-config.svelte +++ b/src/routes/page/agent/[agentId]/agent-llm-config.svelte @@ -1,14 +1,29 @@ @@ -24,9 +39,9 @@
- handleProviderChanged(config.provider)}> {#each options as option} - + {/each}
@@ -37,7 +52,11 @@ Model
- config.is_inherit = false}/> +