Skip to content

Commit a5b23e5

Browse files
committed
Adapt the admin to the rag migration
1 parent 6b8cf40 commit a5b23e5

13 files changed

Lines changed: 141 additions & 94 deletions

File tree

admin/components/ai_config/AIConfig.vue

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,56 @@
11
<template>
22
<div class="dashboard-page-title">{{ $t("aiconfiguration") }}</div>
33
<el-tabs class="main-page-tabs" v-model="itemType">
4-
<el-tab-pane :lazy="true" :label="$t('rag')" name="rag-configs">
5-
<ReadWriteView :readableName="$t('rag')" apiUrl="/back/api/language-model/rag-configs/"
4+
<el-tab-pane :lazy="true" :label="$t('llm')" name="llm-configs">
5+
<ReadWriteView :readableName="$t('llm')" apiUrl="/back/api/language-model/llm-configs/"
66
:cardProps="{
7-
'knowledge_base': $t('knowledgebase'),
8-
'llm_config': $t('llmconfig'),
9-
'prompt_config': $t('promptconfig'),
10-
'generation_config': $t('generationconfig'),
11-
'retriever_config': $t('retrieverconfig'),
7+
'llm_type': $t('llmtype'),
8+
'llm_name': $t('llmname'),
9+
'base_url': $t('baseurl'),
10+
'model_max_length': $t('modelMaxLength'),
11+
'enabled': $t('enabled'),
12+
'num_replicas': $t('numreplicas'),
1213
}"
1314
:tableProps="{
1415
'name': {'name': $t('name'), 'sortable': true},
15-
'knowledge_base': {'name': $t('knowledgebase')},
16-
'llm_config': {'name': $t('llmconfig')},
17-
'prompt_config': {'name': $t('promptconfig')},
18-
'generation_config': {'name': $t('generationconfig')},
19-
'retriever_config': {'name': $t('retrieverconfig')},
16+
'llm_type': {'name': $t('llmtype')},
17+
'llm_name': {'name': $t('llmname')},
18+
'enabled': {'name': $t('enabled')},
2019
'updated_date': {'name': $t('updateddate'), 'sortable': true},
2120
}"
2221
:defaultSort="{'prop': 'name'}">
23-
<template v-slot:extra-card-bottom="{item}">
24-
<el-button class="bottom-card-button" @click="callRagReindex(item.id, $t)"
25-
:disabled="item.index_status === 'up_to_date'">
26-
<span>{{ $t("reindex") }}</span>
27-
<el-icon>
28-
<Refresh/>
29-
</el-icon>
30-
</el-button>
31-
</template>
3222
</ReadWriteView>
3323
</el-tab-pane>
3424
<el-tab-pane :lazy="true" :label="$t('retriever')" name="retriever-configs">
3525
<ReadWriteView :readableName="$t('retriever')" apiUrl="/back/api/language-model/retriever-configs/"
3626
:cardProps="{
3727
'model_name': $t('modelname'),
28+
'retriever_type': $t('retrievertype'),
29+
'knowledge_base': $t('knowledgebase'),
30+
'batch_size': $t('batchsize'),
3831
'device': $t('device'),
32+
'enabled': $t('enabled'),
33+
'num_replicas': $t('numreplicas'),
3934
}"
4035
:tableProps="{
4136
'name': {'name': $t('name'), 'sortable': true},
4237
'model_name': {'name': $t('modelname')},
38+
'knowledge_base': {'name': $t('knowledgebase')},
39+
'retriever_type': {'name': $t('retrievertype')},
4340
'device': {'name': $t('device')},
41+
'enabled': {'name': $t('enabled')},
4442
'updated_date': {'name': $t('updateddate'), 'sortable': true},
4543
}"
4644
:defaultSort="{'prop': 'name'}">
45+
<template v-slot:extra-card-bottom="{item}">
46+
<el-button class="bottom-card-button" @click="callRetrieverReindex(item.id, $t)"
47+
:disabled="item.index_status === 'up_to_date'">
48+
<span>{{ $t("reindex") }}</span>
49+
<el-icon>
50+
<Refresh/>
51+
</el-icon>
52+
</el-button>
53+
</template>
4754
</ReadWriteView>
4855
</el-tab-pane>
4956
<el-tab-pane :lazy="true" :label="$t('prompt')" name="prompt-configs">
@@ -77,26 +84,13 @@
7784
:cardProps="{
7885
'temperature': $t('temperature'),
7986
'max_tokens': $t('maxtokens'),
87+
'seed': $t('seed'),
8088
}"
8189
:tableProps="{
8290
'name': {'name': $t('name'), 'sortable': true},
8391
'temperature': {'name': $t('temperature')},
8492
'max_tokens': {'name': $t('maxtokens')},
85-
'updated_date': {'name': $t('updateddate'), 'sortable': true},
86-
}"
87-
:defaultSort="{'prop': 'name'}">
88-
</ReadWriteView>
89-
</el-tab-pane>
90-
<el-tab-pane :lazy="true" :label="$t('llm')" name="llm-configs">
91-
<ReadWriteView :readableName="$t('llm')" apiUrl="/back/api/language-model/llm-configs/"
92-
:cardProps="{
93-
'llm_type': $t('llmtype'),
94-
'llm_name': $t('llmname'),
95-
}"
96-
:tableProps="{
97-
'name': {'name': $t('name'), 'sortable': true},
98-
'llm_type': {'name': $t('llmtype')},
99-
'llm_name': {'name': $t('llmname')},
93+
'seed': {'name': $t('seed')},
10094
'updated_date': {'name': $t('updateddate'), 'sortable': true},
10195
}"
10296
:defaultSort="{'prop': 'name'}">
@@ -109,11 +103,11 @@
109103
import ReadWriteView from "~/components/generic/ReadWriteView.vue";
110104
import {useItemsStore} from "~/store/items.js";
111105
import {useI18n} from "vue-i18n";
112-
import {callRagReindex} from "~/utils/index.js";
106+
import {callRetrieverReindex} from "~/utils/index.js";
113107
114108
const {$axios} = useNuxtApp();
115109
const itemsStore = useItemsStore()
116-
const itemType = ref("rag-configs")
110+
const itemType = ref("retriever-configs")
117111
await itemsStore.loadSchema()
118112
119113
</script>

admin/components/dashboard/Dashboard.vue

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
:cardProps="cardPropsSDK" :itemSchema="itemSchemaSDK" :apiUrl="SDKAPIUrl"
1010
:titleProps="['fsm_name']" />
1111
</div>
12-
<div class="section-title">{{ $t("rags") }}</div>
12+
<div class="section-title">{{ $t("retrievers") }}</div>
1313
<div class="cards-view">
14-
<div class="no-items" v-if="!rags || !rags.length">{{ $t('norags') }}</div>
15-
<Card v-for="rag in rags" @delete="initItems" @edit="() => goTo('ai_config')" :item="rag"
16-
:cardProps="cardPropsRAG" :itemSchema="itemSchemaRAG" :apiUrl="RAGAPIUrl">
14+
<div class="no-items" v-if="!retrievers || !retrievers.length">{{ $t('noretrievers') }}</div>
15+
<Card v-for="retriever in retrievers" @delete="initItems" @edit="() => goTo('ai_config')" :item="retriever"
16+
:cardProps="cardPropsRetriever" :itemSchema="itemSchemaRetriever" :apiUrl="RetrieverAPIUrl">
1717
<template v-slot:extra-card-bottom="{item}">
18-
<el-button class="bottom-card-button" @click="callRagReindex(item.id, $t)"
18+
<el-button class="bottom-card-button" @click="callRetrieverReindex(item.id, $t)"
1919
:disabled="item.index_status === 'up_to_date'">
2020
<span>{{ $t("reindex") }}</span>
2121
<el-icon>
@@ -27,7 +27,25 @@
2727
<span class="title">{{ name }}:</span>
2828
<el-switch
2929
v-model="item.enabled"
30-
:before-change="() => switchEnabled(item)"
30+
:before-change="() => switchEnabled(item, RetrieverAPIUrl)"
31+
@click.native.stop
32+
:loading="loading[item.id]"
33+
:active-value="true"
34+
:inactive-value="false"
35+
/>
36+
</template>
37+
</Card>
38+
</div>
39+
<div class="section-title">{{ $t("llms") }}</div>
40+
<div class="cards-view">
41+
<div class="no-items" v-if="!llms || !llms.length">{{ $t('nollms') }}</div>
42+
<Card v-for="llm in llms" @delete="initItems" @edit="() => goTo('ai_config')" :item="llm"
43+
:cardProps="cardPropsLLM" :itemSchema="itemSchemaLLM" :apiUrl="LLMAPIUrl">
44+
<template v-slot:enabled="{item, name}">
45+
<span class="title">{{ name }}:</span>
46+
<el-switch
47+
v-model="item.enabled"
48+
:before-change="() => switchEnabled(item, LLMAPIUrl)"
3149
@click.native.stop
3250
:loading="loading[item.id]"
3351
:active-value="true"
@@ -51,7 +69,7 @@ import { authHeaders, useItemsStore } from "~/store/items.js";
5169
import { useAuthStore } from "~/store/auth.js";
5270
import { useI18n } from "vue-i18n";
5371
import Card from "~/components/generic/Card.vue";
54-
import { callRagReindex, upsertItem } from "~/utils/index.js";
72+
import { callRetrieverReindex, upsertItem } from "~/utils/index.js";
5573
5674
const { t } = useI18n();
5775
const itemsStore = useItemsStore();
@@ -61,12 +79,23 @@ const router = useRouter();
6179
6280
const loading = ref({});
6381
64-
// -------- RAG --------
65-
const RAGAPIUrl = ref("/back/api/language-model/rag-configs/");
66-
const cardPropsRAG = ref({
82+
// -------- Retriever --------
83+
const RetrieverAPIUrl = ref("/back/api/language-model/retriever-configs/");
84+
const cardPropsRetriever = ref({
6785
"enabled": t("enabled"),
86+
"model_name": t("modelname"),
87+
"retriever_type": t("retrievertype"),
6888
});
69-
const itemSchemaRAG = ref({});
89+
const itemSchemaRetriever = ref({});
90+
91+
// -------- LLM --------
92+
const LLMAPIUrl = ref("/back/api/language-model/llm-configs/");
93+
const cardPropsLLM = ref({
94+
"enabled": t("enabled"),
95+
"llm_type": t("llmtype"),
96+
"llm_name": t("llmname"),
97+
});
98+
const itemSchemaLLM = ref({});
7099
71100
// -------- Widget --------
72101
const WidgetAPIUrl = ref("/back/api/widget/widgets/");
@@ -82,21 +111,26 @@ const cardPropsSDK = ref({
82111
"created_date": t("created_date"),
83112
});
84113
const itemSchemaSDK = ref({});
85-
const rags = ref([]);
114+
115+
const retrievers = ref([]);
116+
const llms = ref([]);
86117
const widgets = ref([]);
87118
const sdks = ref([]);
88119
const userName = await authStore.getUserName()
120+
89121
async function initData() {
90122
itemsStore.loading = true;
91-
itemSchemaRAG.value = await itemsStore.getSchemaDef(RAGAPIUrl.value);
123+
itemSchemaRetriever.value = await itemsStore.getSchemaDef(RetrieverAPIUrl.value);
124+
itemSchemaLLM.value = await itemsStore.getSchemaDef(LLMAPIUrl.value);
92125
itemSchemaWidget.value = await itemsStore.getSchemaDef(WidgetAPIUrl.value);
93126
itemSchemaSDK.value = await itemsStore.getSchemaDef(SDKAPIUrl.value);
94127
itemsStore.loading = false;
95128
}
96129
97130
async function initItems() {
98131
itemsStore.loading = true;
99-
rags.value = (await $axios.get(RAGAPIUrl.value + "?enabled=1", { headers: authHeaders() })).data.results;
132+
retrievers.value = (await $axios.get(RetrieverAPIUrl.value + "?enabled=1", { headers: authHeaders() })).data.results;
133+
llms.value = (await $axios.get(LLMAPIUrl.value + "?enabled=1", { headers: authHeaders() })).data.results;
100134
widgets.value = (await $axios.get(WidgetAPIUrl.value, { headers: authHeaders() })).data.results;
101135
sdks.value = (await $axios.get(SDKAPIUrl.value, { headers: authHeaders() })).data.results;
102136
itemsStore.loading = false;
@@ -109,10 +143,10 @@ function goTo(route) {
109143
router.push({ name: route });
110144
}
111145
112-
async function switchEnabled(item) {
146+
async function switchEnabled(item, apiUrl) {
113147
try {
114148
loading.value[item.id] = true;
115-
const res = await upsertItem(RAGAPIUrl.value, { id: item.id, enabled: !item.enabled }, itemsStore, false, {}, t);
149+
const res = await upsertItem(apiUrl, { id: item.id, enabled: !item.enabled }, itemsStore, false, {}, t);
116150
item.enabled = res.enabled; // Assuming the backend responds with the updated state
117151
loading.value[item.id] = false;
118152
} catch (e) {
@@ -123,7 +157,6 @@ async function switchEnabled(item) {
123157
124158
</script>
125159

126-
127160
<style lang="scss">
128161
.dashboard-wrapper {
129162
margin-left: 146px;

admin/components/labeling/Labeling.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
apiUrl="/back/api/broker/conversations/"
77
:tableProps="{
88
'name': {'name': $t('name')},
9-
'rags': {'name': $t('rags')},
9+
'fsm_defs': {'name': $t('fsms')},
1010
'created_date': {'name': $t('created_date'), 'sortable': true},
1111
'user_id': {'name': $t('userid')},
1212
'view': {'name': '', 'width': $t('view').length * 20, 'align': 'center'},
@@ -15,7 +15,7 @@
1515
:filtersSchema="[
1616
{'type': 'search', 'placeholder': $t('name'), 'field': 'search'},
1717
{'type': 'range-date', 'startPlaceholder': $t('startdate'), 'endPlaceholder': $t('enddate'), 'field': 'created_date'},
18-
{'type': 'ref', 'placeholder': $t('rag'), 'field': 'rag', 'endpoint': '/back/api/language-model/rag-configs/'},
18+
{'type': 'ref', 'placeholder': $t('fsm_def'), 'field': 'fsm_def', 'endpoint': '/back/api/fsm/definitions/'},
1919
{
2020
'type': 'enum',
2121
'placeholder': $t('reviewed'),
@@ -29,16 +29,15 @@
2929
<template v-slot:view="{row}">
3030
<div class="go-to-view" @click="goToLabelingConversation(row.id)">{{ $t("view") }}</div>
3131
</template>
32-
<template v-slot:rags="{row}">
33-
{{ row?.rags ? row.rags.join(",") : "" }}
32+
<template v-slot:fsms="{row}">
33+
{{ row?.fsms ? row.fsms.join(",") : "" }}
3434
</template>
3535
</ReadView>
3636

3737
<LabelingTool v-else :id="editing" @exit="editing = undefined"></LabelingTool>
3838
</template>
3939

4040
<script setup>
41-
import ReadWriteView from "~/components/generic/ReadWriteView.vue";
4241
import {useItemsStore} from "~/store/items.js";
4342
import ReadView from "~/components/generic/ReadView.vue";
4443

admin/components/labeling/LabelingTool.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<div class="labeling-tool-left-side">
2424
<div class="selected-conversation-info">
2525
<div>{{conversation.name}}</div>
26-
<div>{{ conversation?.rags ? conversation.rags.join(",") : "" }}</div>
26+
<div>{{ conversation?.fsms ? conversation.fsms.join(",") : "" }}</div>
2727
<div>{{formatDate(conversation.created_date)}}</div>
2828
</div>
2929
<div v-for="msgs in getQAMessageGroups(conversation.msgs_chain)"

admin/components/stats/Stats.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
</div>
2323
<div class="section-title">{{ $t("reviewsandfeedback") }}</div>
2424
<div class="group-stats">
25-
<StatCard class="stat" :title="$t('precision')" :content="stats.precision"/>
26-
<StatCard class="stat" :title="$t('recall')" :content="stats.recall"/>
27-
<StatCard class="stat" :title="$t('f1')" :content="stats.f1"/>
28-
<StatCard class="stat" :title="$t('adminquality')" :content="stats.admin_quality"/>
29-
<StatCard class="stat" :title="$t('userquality')" :content="stats.user_quality"/>
25+
<StatCard class="stat" type="percentage" :title="$t('precision')" :content="stats.precision"/>
26+
<StatCard class="stat" type="percentage" :title="$t('recall')" :content="stats.recall"/>
27+
<StatCard class="stat" type="percentage" :title="$t('f1')" :content="stats.f1"/>
28+
<StatCard class="stat" type="percentage" :title="$t('adminquality')" :content="stats.admin_quality"/>
29+
<StatCard class="stat" type="percentage" :title="$t('userquality')" :content="stats.user_quality"/>
3030
</div>
3131
</div>
3232
</div>
@@ -46,16 +46,15 @@ const stats = ref(undefined)
4646
const filtersEl = ref(undefined)
4747
const loading = ref(false)
4848
49+
// NOTE: I don't know if we want to add the fsm_def filter
4950
const filterSchema = ref(
5051
[
51-
{'type': 'ref', 'placeholder': t('rag'), 'field': 'rag', 'endpoint': '/back/api/language-model/rag-configs/'},
52+
// {'type': 'ref', 'placeholder': t('fsmdef'), 'field': 'fsm_def', 'endpoint': '/back/api/fsm/definitions/'},
5253
{'type': 'range-date', 'startPlaceholder': t('startdate'), 'endPlaceholder': t('enddate'), 'field': 'created_date'},
5354
]
5455
)
5556
5657
async function requestStats(_filters) {
57-
// if (itemsStore.filters.rag === undefined)
58-
// stats.value = undefined
5958
loading.value = true
6059
let filters = {..._filters}
6160
if (filters.created_date__gte) {
@@ -123,4 +122,4 @@ requestStats()
123122
border-left: 2px solid $chatfaq-color-primary-500;
124123
125124
}
126-
</style>
125+
</style>

0 commit comments

Comments
 (0)