Skip to content

Commit

Permalink
Fixed error in admin, config & chat page (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyx2000 authored Apr 23, 2024
1 parent 8903a24 commit 0fb02da
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions api/chat_session_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (s *ChatSessionService) GetSimpleChatSessionsByUserID(ctx context.Context,
MaxTokens: session.MaxTokens,
Debug: session.Debug,
Model: session.Model,
SummarizeMode: session.SummarizeMode,
}
})
return simple_sessions, nil
Expand Down
1 change: 1 addition & 0 deletions api/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type SimpleChatSession struct {
MaxTokens int32 `json:"maxTokens"`
Debug bool `json:"debug"`
Model string `json:"model"`
SummarizeMode bool `json:"summarizeMode"`
}

type ChatMessageResponse struct {
Expand Down
19 changes: 11 additions & 8 deletions web/src/views/admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { computed, h, reactive, ref } from 'vue'
import { NIcon, NLayout, NLayoutSider, NMenu } from 'naive-ui'
import type { MenuOption } from 'naive-ui'
import { PulseOutline, ShieldCheckmarkOutline } from '@vicons/ionicons5'
import { RouterLink } from 'vue-router'
import { RouterLink, useRoute } from 'vue-router'
import Permission from '@/views/components/Permission.vue'
import { t } from '@/locales'
import { useBasicLayout } from '@/hooks/useBasicLayout'
Expand All @@ -15,11 +15,14 @@ const { isMobile } = useBasicLayout()
// login modal will appear when there is no token
const authStore = useAuthStore()
const currentRoute = useRoute()
const USER_ROUTE = 'AdminUser'
const MODEL_ROUTE = 'AdminModel'
const needPermission = computed(() => !authStore.token) // || (!!authStore.token && authStore.expiresIn < Date.now() / 1000))
const collapsed: Ref<boolean> = ref(true)
const activeKey: Ref<string> = ref('rateLimit')
const activeKey = ref(currentRoute.name?.toString())
const getMobileClass = computed<CSSProperties>(() => {
if (isMobile.value) {
Expand All @@ -43,25 +46,25 @@ const menuOptions: MenuOption[] = reactive([
RouterLink,
{
to: {
name: 'AdminUser',
name: USER_ROUTE,
},
},
{ default: () => t('admin.rateLimit') },
),
key: 'rateLimit',
key: USER_ROUTE,
icon: renderIcon(PulseOutline),
},
{
label: () => h(
RouterLink,
{
to: {
name: 'AdminModel',
name: MODEL_ROUTE,
},
},
{ default: () => t('admin.model') },
),
key: 'model',
key: MODEL_ROUTE,
icon: renderIcon(ShieldCheckmarkOutline),
},
])
Expand All @@ -88,7 +91,7 @@ function handleUpdateCollapsed() {
<SvgIcon v-else class="text-2xl" icon="ri:align-right" />
</button>
</div>
<h1 v-if="!isMobile" class="flex-1 px-4 pr-6 overflow-hidden cursor-pointer select-none text-ellipsis whitespace-nowrap">
<h1 v-if="!isMobile" class="flex-1 px-4 pr-6 overflow-hidden cursor-pointer select-none text-ellipsis whitespace-nowrap">
Admin
</h1>
<!-- <div class="flex items-center space-x-2">
Expand All @@ -112,7 +115,7 @@ function handleUpdateCollapsed() {
:style="getMobileClass" @collapse="collapsed = true" @expand="collapsed = false"
>
<NMenu
v-model:value="activeKey" :collapsed="collapsed" :collapsed-width="64" :collapsed-icon-size="22"
v-model:value="activeKey" :collapsed="collapsed" :collapsed-width="64" :collapsed-icon-size="22" @update:value="handleUpdateCollapsed"
:options="menuOptions"
/>
</NLayoutSider>
Expand Down
1 change: 1 addition & 0 deletions web/src/views/admin/model/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NTabPane, NTabs } from 'naive-ui'
import { ref } from 'vue'
import PerModelRatelimit from './per_mode_ratelimit/index.vue'
import SystemModel from './system_model/index.vue'
import { SvgIcon } from '@/components/common'
const active = ref('System')
</script>

Expand Down
2 changes: 1 addition & 1 deletion web/src/views/admin/model/per_mode_ratelimit/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function createColumns(): DataTableColumns<RowData> {
width: 250,
render(row: RowData, index: number) {
return h(NInput, {
value: row.rateLimit,
value: row.rateLimit.toString(),
onUpdateValue(v: string) {
// assuming that `data` is an array of FormData objects
data.value[index].rateLimit = v
Expand Down
6 changes: 3 additions & 3 deletions web/src/views/admin/model/system_model/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function createColumns(): DataTableColumns<Chat.ChatModel> {
width: 100,
render(row: Chat.ChatModel, index: number) {
return h(NInput, {
value: row.orderNumber,
value: row.orderNumber?.toString(),
width: 5,
onUpdateValue(v: string) {
// Assuming `data` is an array of FormData objects
Expand All @@ -136,7 +136,7 @@ function createColumns(): DataTableColumns<Chat.ChatModel> {
width: 100,
render(row: Chat.ChatModel, index: number) {
return h(NInput, {
value: row.defaultToken,
value: row.defaultToken?.toString(),
width: 5,
onUpdateValue(v: string) {
// Assuming `data` is an array of FormData objects
Expand All @@ -153,7 +153,7 @@ function createColumns(): DataTableColumns<Chat.ChatModel> {
width: 100,
render(row: Chat.ChatModel, index: number) {
return h(NInput, {
value: row.maxToken,
value: row.maxToken?.toString(),
width: 5,
onUpdateValue(v: string) {
// Assuming `data` is an array of FormData objects
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/admin/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const columns = [
width: 100,
render: (row: any, index: number) => {
return h(NInput, {
value: row.rateLimit,
value: row.rateLimit.toString(),
width: 50,
async onUpdateValue(v: string) {
try {
Expand Down
1 change: 1 addition & 0 deletions web/src/views/chat/components/Session/SessionConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const debouneUpdate = debounce(async (model: ModelType) => {
n: model.n,
debug: model.debug,
model: model.chatModel,
summarizeMode: model.summarizeMode,
})
}, 200)
Expand Down
3 changes: 2 additions & 1 deletion web/src/views/chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ async function onConversationStream() {
loading: false,
},
)
scrollToBottom()
}
catch (error) {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -537,7 +538,7 @@ function getDataFromResponseText(responseText: string): string {
</template>
<template v-else>
<div>
<Message v-for="(item, index) of dataSources" :key="index" :date-time="item.dateTime"
<Message v-for="(item, index) of dataSources" :key="index" :date-time="item.dateTime"
:model="chatSession?.model" :text="item.text" :inversion="item.inversion" :error="item.error"
:is-prompt="item.isPrompt" :is-pin="item.isPin" :loading="item.loading" :pining="pining" :index="index"
@regenerate="onRegenerate(index)" @delete="handleDelete(index)" @toggle-pin="handleTogglePin(index)"
Expand Down

0 comments on commit 0fb02da

Please sign in to comment.