Skip to content

Commit e7d9075

Browse files
author
Jicheng Lu
committed
add common cmp
1 parent b437454 commit e7d9075

File tree

7 files changed

+252
-653
lines changed

7 files changed

+252
-653
lines changed

src/routes/page/agent/[agentId]/agent-components/agent-llm-config.svelte

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
import { onMount } from 'svelte';
33
import { Card, CardBody } from '@sveltestrap/sveltestrap';
44
import { getLlmConfigs } from '$lib/services/llm-provider-service';
5+
import { LlmModelCapability } from '$lib/helpers/enums';
56
import ChatConfig from './llm-configs/chat-config.svelte';
6-
import ImageGenerationConfig from './llm-configs/image-generation-config.svelte';
7-
import ImageEditConfig from './llm-configs/image-edit-config.svelte';
8-
import AudioTranscriptionConfig from './llm-configs/audio-transcription-config.svelte';
9-
import RealtimeConfig from './llm-configs/realtime-config.svelte';
7+
import LlmBasicConfig from './llm-configs/llm-basic-config.svelte';
108
119
/** @type {import('$agentTypes').AgentModel} */
1210
export let agent;
@@ -49,7 +47,6 @@
4947
5048
async function init() {
5149
llmConfigs = await getLlmConfigs();
52-
5350
}
5451
</script>
5552
@@ -62,10 +59,38 @@
6259
6360
<div class="agent-utility-container">
6461
<ChatConfig bind:this={chatConfigCmp} {agent} {llmConfigs} {handleAgentChange} />
65-
<ImageGenerationConfig bind:this={imageGenerationConfigCmp} {agent} {llmConfigs} {handleAgentChange} />
66-
<ImageEditConfig bind:this={imageEditConfigCmp} {agent} {llmConfigs} {handleAgentChange} />
67-
<AudioTranscriptionConfig bind:this={audioTranscriptionConfigCmp} {agent} {llmConfigs} {handleAgentChange} />
68-
<RealtimeConfig bind:this={realtimeConfigCmp} {agent} {llmConfigs} {handleAgentChange} />
62+
<LlmBasicConfig
63+
title="Image Generation"
64+
bind:this={imageGenerationConfigCmp}
65+
llmConfigOptions={llmConfigs}
66+
llmConfig={agent.llm_config?.image_generation}
67+
modelCapability={LlmModelCapability.ImageGeneration}
68+
{handleAgentChange}
69+
/>
70+
<LlmBasicConfig
71+
title="Image Edit"
72+
bind:this={imageEditConfigCmp}
73+
llmConfigOptions={llmConfigs}
74+
llmConfig={agent.llm_config?.image_edit}
75+
modelCapability={LlmModelCapability.ImageEdit}
76+
{handleAgentChange}
77+
/>
78+
<LlmBasicConfig
79+
title="Audio Transcription"
80+
bind:this={audioTranscriptionConfigCmp}
81+
llmConfigOptions={llmConfigs}
82+
llmConfig={agent.llm_config?.audio_transcription}
83+
modelCapability={LlmModelCapability.AudioTranscription}
84+
{handleAgentChange}
85+
/>
86+
<LlmBasicConfig
87+
title="Realtime"
88+
bind:this={realtimeConfigCmp}
89+
llmConfigOptions={llmConfigs}
90+
llmConfig={agent.llm_config?.realtime}
91+
modelCapability={LlmModelCapability.Realtime}
92+
{handleAgentChange}
93+
/>
6994
</div>
7095
</CardBody>
7196
</Card>

src/routes/page/agent/[agentId]/agent-components/llm-configs/image-edit-config.svelte

Lines changed: 0 additions & 116 deletions
This file was deleted.

src/routes/page/agent/[agentId]/agent-components/llm-configs/image-generation-config.svelte

Lines changed: 0 additions & 116 deletions
This file was deleted.
Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
<script>
22
import { Input } from '@sveltestrap/sveltestrap';
3-
import { LlmModelCapability } from '$lib/helpers/enums';
43
5-
/** @type {import('$agentTypes').AgentModel} */
6-
export let agent;
4+
/** @type {string} */
5+
export let title;
6+
7+
/** @type {string} */
8+
export let modelType = '';
9+
10+
/** @type {string} */
11+
export let modelCapability;
12+
13+
/** @type {any} */
14+
export let llmConfig;
715
816
/** @type {import('$commonTypes').LlmConfig[]} */
9-
export let llmConfigs = [];
17+
export let llmConfigOptions = [];
1018
1119
/** @type {() => void} */
1220
export let handleAgentChange = () => {};
@@ -23,21 +31,20 @@
2331
};
2432
}
2533
26-
let config = agent.llm_config?.audio_transcription || {};
27-
2834
/** @type {import('$commonTypes').LlmConfig[]} */
29-
let innerLlmConfigs = [];
35+
let innerLlmConfigOptions = [];
3036
3137
/** @type {string[]} */
3238
let providers = [];
3339
3440
/** @type {import('$commonTypes').LlmModelSetting[]} */
3541
let models = [];
3642
43+
let config = llmConfig || {};
3744
$: {
38-
if (llmConfigs.length > 0 && innerLlmConfigs.length === 0) {
39-
innerLlmConfigs = llmConfigs;
40-
const innerProviders = innerLlmConfigs.filter(x => x.models?.some(y => y.capabilities?.includes(LlmModelCapability.AudioTranscription)));
45+
if (llmConfigOptions.length > 0 && innerLlmConfigOptions.length === 0) {
46+
innerLlmConfigOptions = llmConfigOptions;
47+
const innerProviders = innerLlmConfigOptions.filter(x => x.models?.some(y => (!!modelType && y.type === modelType) || y.capabilities?.includes(modelCapability)));
4148
providers = ['', ...innerProviders.map(x => x.provider)];
4249
if (!!config.provider) {
4350
models = getLlmModels(config.provider);
@@ -51,8 +58,8 @@
5158
5259
/** @param {string} provider */
5360
function getLlmModels(provider) {
54-
return innerLlmConfigs.find(x => x.provider === provider)?.models
55-
?.filter(x => x.capabilities?.includes(LlmModelCapability.AudioTranscription)) || [];
61+
return innerLlmConfigOptions.find(x => x.provider === provider)?.models
62+
?.filter(x => (!!modelType && x.type === modelType) || x.capabilities?.includes(modelCapability)) || [];
5663
}
5764
5865
/** @param {any} e */
@@ -81,7 +88,7 @@
8188
8289
<div class="agent-config-container">
8390
<div class="text-center">
84-
<h6 class="mt-1 mb-2">Audio Transcription</h6>
91+
<h6 class="mt-1 mb-2">{title}</h6>
8592
</div>
8693
8794
<div class="mb-3 row">

0 commit comments

Comments
 (0)