Skip to content

Commit 02874f8

Browse files
authored
Merge pull request #99 from iceljc/features/refine-chat-window
Features/refine chat window
2 parents 54d971c + f78224f commit 02874f8

File tree

5 files changed

+68
-21
lines changed

5 files changed

+68
-21
lines changed

src/lib/helpers/types.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@
8282
/**
8383
* @typedef {Object} AgentLlmConfig
8484
* @property {boolean} is_inherit - Inherited from default Agent settings
85-
* @property {string} provider
86-
* @property {string} model
85+
* @property {string?} provider
86+
* @property {string?} model
87+
* @property {number} max_recursion_depth
8788
*/
8889

8990
/**

src/lib/scss/custom/pages/_chat.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
flex: 1 1 fit-content;
201201
border-radius: 10px;
202202
border-width: 2px;
203-
max-width: 100%;
203+
max-width: 45%;
204204
margin-bottom: 0px;
205205

206206
.card-element-title {

src/routes/page/agent/[agentId]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<AgentOverview agent={agent} />
7777
<AgentLlmConfig agent={agent} />
7878
{#if agent.routing_rules?.length > 0}
79-
<AgentRouting agent={agent} />
79+
<AgentRouting agent={agent} />
8080
{/if}
8181
</Col>
8282
<Col style="flex: 40%;">
Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,64 @@
11
<script>
2-
import { Button, Card, CardBody, CardHeader, Col } from '@sveltestrap/sveltestrap';
2+
import { Button, Card, CardBody, CardHeader, Col, Input } from '@sveltestrap/sveltestrap';
33
import { getLlmProviders, getLlmProviderModels } from '$lib/services/llm-provider-service';
44
import { onMount } from 'svelte';
55
66
/** @type {string[]} */
7-
let options = [];
7+
let providers = [];
88
99
/** @type {import('$types').AgentModel} */
1010
export let agent;
1111
1212
/** @type {import('$types').LlmModelSetting[]} */
13-
let models = []
13+
let models = [];
14+
15+
const lowerLimit = 1;
16+
const upperLimit = 10;
1417
1518
let config = agent.llm_config;
1619
1720
onMount(async () =>{
18-
options = await getLlmProviders();
19-
models = await getLlmProviderModels(config.provider);
21+
providers = await getLlmProviders();
22+
providers = ['', ...providers]
23+
if (!!config.provider) {
24+
models = await getLlmProviderModels(config.provider);
25+
}
2026
});
2127
22-
/** @param {string} provider */
23-
async function handleProviderChanged(provider) {
28+
/** @param {any} e */
29+
async function changeProvider(e) {
30+
const provider = e.target.value;
31+
config.provider = provider || null;
32+
33+
if (!!!provider) {
34+
models = [];
35+
config.model = null;
36+
return;
37+
}
38+
2439
config.is_inherit = false;
2540
models = await getLlmProviderModels(provider);
2641
config.model = models[0]?.name;
2742
}
43+
44+
/** @param {any} e */
45+
function changeModel(e) {
46+
config.is_inherit = false;
47+
config.model = e.target.value || null;
48+
}
49+
50+
/** @param {any} e */
51+
function changeMaxRecursiveDepth(e) {
52+
let value = Number(e.target.value) || 0;
53+
54+
if (value < lowerLimit) {
55+
value = lowerLimit;
56+
} else if (value > upperLimit) {
57+
value = upperLimit;
58+
}
59+
60+
config.max_recursion_depth = value;
61+
}
2862
</script>
2963
3064
<Card>
@@ -38,13 +72,15 @@
3872
</div>
3973
4074
<div class="mb-3 row">
41-
<label class="col-md-3 col-form-label" for="example-large">Provider</label>
42-
<div class="col-md-9">
43-
<select class="form-select" bind:value={config.provider} on:change={() => handleProviderChanged(config.provider)}>
44-
{#each options as option}
45-
<option value={option}>{option}</option>
46-
{/each}
47-
</select>
75+
<label for="example-large" class="col-md-3 col-form-label">
76+
Provider
77+
</label>
78+
<div class="col-md-9 config-item-container">
79+
<Input type="select" value={config.provider} on:change={e => changeProvider(e)}>
80+
{#each providers as option}
81+
<option value={option}>{option}</option>
82+
{/each}
83+
</Input>
4884
</div>
4985
</div>
5086
@@ -53,12 +89,21 @@
5389
Model
5490
</label>
5591
<div class="col-md-9">
56-
<select class="form-select" bind:value={config.model} on:change={() => config.is_inherit = false}>
92+
<Input type="select" value={config.model} disabled={models.length === 0} on:change={e => changeModel(e)}>
5793
{#each models as option}
5894
<option value={option.name}>{option.name}</option>
5995
{/each}
60-
</select>
96+
</Input>
97+
</div>
98+
</div>
99+
100+
<div class="mb-3 row">
101+
<label for="example-text-input" class="col-md-3 col-form-label">
102+
Maximum recursive depth
103+
</label>
104+
<div class="col-md-9">
105+
<Input type="number" min={lowerLimit} max={upperLimit} style="text-align: center;" value={config.max_recursion_depth} on:change={e => changeMaxRecursiveDepth(e)} />
61106
</div>
62107
</div>
63108
</CardBody>
64-
</Card>
109+
</Card>

src/routes/page/agent/[agentId]/agent-prompt.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
type="textarea"
3333
id="formmessage"
3434
class="form-control"
35+
style="scrollbar-width: thin;"
3536
rows="20"
3637
bind:value={agent.instruction}
3738
placeholder="Enter your Message"

0 commit comments

Comments
 (0)