Skip to content

Commit

Permalink
add insert to context to quick messages
Browse files Browse the repository at this point in the history
  • Loading branch information
juzeon committed Mar 26, 2024
1 parent af0e4cf commit 308b0cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
13 changes: 12 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type Config struct {
type Migration struct {
SydneyPreset20240304 bool `json:"sydney_preset_20240304"`
ThemeColor20240304 bool `json:"theme_color_20240304"`
Quick20240326 bool `json:"quick_20240326"`
}

func fillDefault[T comparable](pointer *T, defaultValue T) {
Expand Down Expand Up @@ -116,6 +117,15 @@ func (o *Config) DoMigration() {
}
o.Migration.ThemeColor20240304 = true
}
if !o.Migration.Quick20240326 {
_, ok := lo.Find(o.Quick, func(item string) bool {
return item == "[user](#message)"
})
if !ok {
o.Quick = append(o.Quick, "[user](#message)")
}
o.Migration.Quick20240326 = true
}
}
func (o *Config) FillDefault() {
if len(o.Presets) == 0 {
Expand All @@ -140,7 +150,8 @@ func (o *Config) FillDefault() {
"Explain the content above in a comprehensive but simple way.",
"Fix grammar errors and polish the writing of the text above.",
"Translate the text above into Chinese in a fluent way.",
"Continue the conversation in context. Assistant:"}
"Continue the conversation in context. Assistant:",
"[user](#message)"}
}
if len(o.OpenAIBackends) == 0 {
o.OpenAIBackends = []OpenAIBackend{
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/pages/IndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,18 @@ function generateTitle() {
Quick
</v-btn>
</template>
<v-list density="compact">
<v-list-item density="compact" @click="applyQuickResponse(item)" v-for="item in config.quick">{{
item
}}
<v-list density="compact" max-width="1000">
<v-list-item density="compact" v-for="item in config.quick">
<template #default>
<div @click="applyQuickResponse(item)" style="cursor: pointer">
{{ item }}
</div>
</template>
<template #append>
<v-btn density="compact" @click="appendBlockToCurrentWorkspace(item+'\n')" variant="text"
prepend-icon="mdi-delta">Context
</v-btn>
</template>
</v-list-item>
</v-list>
</v-menu>
Expand Down
2 changes: 2 additions & 0 deletions frontend/wailsjs/go/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export namespace main {
export class Migration {
sydney_preset_20240304: boolean;
theme_color_20240304: boolean;
quick_20240326: boolean;

static createFrom(source: any = {}) {
return new Migration(source);
Expand All @@ -86,6 +87,7 @@ export namespace main {
if ('string' === typeof source) source = JSON.parse(source);
this.sydney_preset_20240304 = source["sydney_preset_20240304"];
this.theme_color_20240304 = source["theme_color_20240304"];
this.quick_20240326 = source["quick_20240326"];
}
}
export class OpenAIBackend {
Expand Down

0 comments on commit 308b0cb

Please sign in to comment.