Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit66ba546

Browse files
committed
feat: add OS context to LLM chat and enhance session management logic
1 parenta591cc4 commit66ba546

File tree

45 files changed

+9706
-9897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+9706
-9897
lines changed

‎api/llm/llm.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func MakeChatCompletionRequest(c *gin.Context) {
2424
Messages []openai.ChatCompletionMessage`json:"messages"`
2525
Languagestring`json:"language,omitempty"`
2626
NginxConfigstring`json:"nginx_config,omitempty"`// Separate field for nginx configuration content
27+
OSInfostring`json:"os_info,omitempty"`// Operating system information
2728
}
2829

2930
if!cosy.BindAndValid(c,&json) {
@@ -34,6 +35,11 @@ func MakeChatCompletionRequest(c *gin.Context) {
3435
varsystemPromptstring
3536
ifjson.Type=="terminal" {
3637
systemPrompt=llm.TerminalAssistantPrompt
38+
39+
// Add OS context for terminal assistant
40+
ifjson.OSInfo!="" {
41+
systemPrompt+=fmt.Sprintf("\n\nSystem Information: %s",json.OSInfo)
42+
}
3743
}else {
3844
systemPrompt=llm.NginxConfigPrompt
3945
}

‎api/llm/session.go‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ func CreateLLMSession(c *gin.Context) {
102102
}
103103

104104
g:=query.LLMSession
105+
106+
// When creating a new active session, deactivate all other sessions with the same path
107+
ifsession.IsActive&&sessionPath!="" {
108+
_,err:=g.Where(g.Path.Eq(sessionPath)).UpdateSimple(g.IsActive.Value(false))
109+
iferr!=nil {
110+
logger.Error("Failed to deactivate other sessions:",err)
111+
// Continue anyway, this is not critical
112+
}
113+
}
114+
105115
err:=g.Create(session)
106116
iferr!=nil {
107117
logger.Error(err)
@@ -144,7 +154,20 @@ func UpdateLLMSession(c *gin.Context) {
144154
session.MessageCount=len(json.Messages)
145155
}
146156

147-
ifjson.IsActive!=nil {
157+
ifjson.IsActive!=nil&&*json.IsActive {
158+
session.IsActive=true
159+
160+
// Deactivate all other sessions with the same path
161+
_,err=g.Where(
162+
g.Path.Eq(session.Path),
163+
g.SessionID.Neq(sessionID),
164+
).UpdateSimple(g.IsActive.Value(false))
165+
166+
iferr!=nil {
167+
logger.Error("Failed to deactivate other sessions:",err)
168+
// Continue anyway, this is not critical
169+
}
170+
}elseifjson.IsActive!=nil {
148171
session.IsActive=*json.IsActive
149172
}
150173

@@ -240,6 +263,14 @@ func GetLLMSessionByPath(c *gin.Context) {
240263
IsActive:true,
241264
}
242265

266+
// Deactivate all other sessions with the same path before creating
267+
ifpath!="" {
268+
_,deactivateErr:=g.Where(g.Path.Eq(path)).UpdateSimple(g.IsActive.Value(false))
269+
ifdeactivateErr!=nil {
270+
logger.Error("Failed to deactivate other sessions:",deactivateErr)
271+
}
272+
}
273+
243274
err=g.Create(session)
244275
iferr!=nil {
245276
logger.Error(err)
@@ -294,6 +325,14 @@ func CreateOrUpdateLLMSessionByPath(c *gin.Context) {
294325
IsActive:true,
295326
}
296327

328+
// Deactivate all other sessions with the same path before creating
329+
ifjson.FileName!="" {
330+
_,deactivateErr:=g.Where(g.Path.Eq(json.FileName)).UpdateSimple(g.IsActive.Value(false))
331+
ifdeactivateErr!=nil {
332+
logger.Error("Failed to deactivate other sessions:",deactivateErr)
333+
}
334+
}
335+
297336
err=g.Create(session)
298337
iferr!=nil {
299338
logger.Error(err)

‎app/components.d.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ declare module 'vue' {
4848
AModal:typeofimport('ant-design-vue/es')['Modal']
4949
APopconfirm:typeofimport('ant-design-vue/es')['Popconfirm']
5050
APopover:typeofimport('ant-design-vue/es')['Popover']
51+
AppProvider:typeofimport('./src/components/AppProvider.vue')['default']
5152
AProgress:typeofimport('ant-design-vue/es')['Progress']
5253
AQrcode:typeofimport('ant-design-vue/es')['QRCode']
5354
ARadio:typeofimport('ant-design-vue/es')['Radio']
@@ -133,6 +134,7 @@ declare module 'vue' {
133134
SystemRestoreSystemRestoreContent:typeofimport('./src/components/SystemRestore/SystemRestoreContent.vue')['default']
134135
TabFilterTabFilter:typeofimport('./src/components/TabFilter/TabFilter.vue')['default']
135136
TerminalTerminalStatusBar:typeofimport('./src/components/Terminal/TerminalStatusBar.vue')['default']
137+
TestMessage:typeofimport('./src/components/TestMessage.vue')['default']
136138
TwoFAAuthorization:typeofimport('./src/components/TwoFA/Authorization.vue')['default']
137139
UpstreamCardsUpstreamCards:typeofimport('./src/components/UpstreamCards/UpstreamCards.vue')['default']
138140
UpstreamDetailModalUpstreamDetailModal:typeofimport('./src/components/UpstreamDetailModal/UpstreamDetailModal.vue')['default']

‎app/package.json‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"@fingerprintjs/fingerprintjs":"^4.6.2",
1919
"@formkit/auto-animate":"^0.8.4",
2020
"@simplewebauthn/browser":"^13.1.2",
21-
"@uozi-admin/curd":"^4.11.0",
21+
"@uozi-admin/curd":"^4.15.4",
2222
"@uozi-admin/request":"^2.8.4",
23-
"@vue/reactivity":"^3.5.20",
24-
"@vue/shared":"^3.5.20",
23+
"@vue/reactivity":"^3.5.21",
24+
"@vue/shared":"^3.5.21",
2525
"@vueuse/components":"^13.9.0",
2626
"@vueuse/core":"^13.9.0",
2727
"@vueuse/integrations":"^13.9.0",
@@ -51,7 +51,7 @@
5151
"unocss":"^66.5.0",
5252
"uuid":"^11.1.0",
5353
"vite-plugin-build-id":"0.5.0",
54-
"vue":"^3.5.20",
54+
"vue":"^3.5.21",
5555
"vue-dompurify-html":"^5.3.0",
5656
"vue-echarts":"^7.0.3",
5757
"vue-router":"^4.5.1",
@@ -62,7 +62,7 @@
6262
"vuedraggable":"^4.1.0"
6363
},
6464
"devDependencies": {
65-
"@antfu/eslint-config":"^5.2.1",
65+
"@antfu/eslint-config":"^5.2.2",
6666
"@iconify-json/fa":"1.2.2",
6767
"@iconify-json/tabler":"^1.2.22",
6868
"@iconify/tools":"^4.1.2",
@@ -75,11 +75,11 @@
7575
"@vitejs/plugin-legacy":"^7.2.1",
7676
"@vitejs/plugin-vue":"^6.0.1",
7777
"@vitejs/plugin-vue-jsx":"^5.1.1",
78-
"@vue/compiler-sfc":"^3.5.20",
78+
"@vue/compiler-sfc":"^3.5.21",
7979
"@vue/tsconfig":"^0.8.1",
80-
"ace-builds":"^1.43.2",
80+
"ace-builds":"^1.43.3",
8181
"autoprefixer":"^10.4.21",
82-
"eslint":"^9.34.0",
82+
"eslint":"^9.35.0",
8383
"eslint-plugin-sonarjs":"^3.0.5",
8484
"less":"^4.4.1",
8585
"postcss":"^8.5.6",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp