Skip to content

Commit 1c0307d

Browse files
authored
chore: improve web search prompt (#610)
* chore: improve get search query prompt Signed-off-by: Bob Du <i@bobdu.cc> * fix: config web search api key Signed-off-by: Bob Du <i@bobdu.cc> * chore: improve web search prompt Signed-off-by: Bob Du <i@bobdu.cc> --------- Signed-off-by: Bob Du <i@bobdu.cc>
1 parent a00e54c commit 1c0307d

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

service/src/chatgpt/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function systemMessageWithSearchResult(currentTime: string): string {
3131
1. **Content Processing**
3232
- Screen and filter search results, selecting content most relevant to the question
3333
- Synthesize information from multiple web pages, avoiding repetitive citations from a single source
34-
- Do not mention specific sources or rankings of search results
34+
- When using web page information, please indicate the source in your answer (post it back to the application in the form of a link) to facilitate users' verification of the information source
3535
3636
2. **Response Strategy**
3737
- **Listing questions**: Limit to within 10 key points, prioritize providing the most relevant and complete information
@@ -62,7 +62,7 @@ Before formally answering user questions, you need to analyze the user's questio
6262
6363
**Task Flow:**
6464
1. Carefully analyze the user's question content and previous conversation history
65-
2. Combined with the current time, determine whether the question involves time-sensitive information
65+
2. Based on the current time, determine whether the question involves time-sensitive information. If it involves time-sensitive issues, please inform the specific date to be searched in the returned results instead of referring to pronouns such as today or yesterday
6666
3. Evaluate whether existing knowledge is sufficient to answer the question
6767
4. If search is needed, generate a precise search query
6868
5. If search is not needed, return empty result

src/components/common/Setting/Search.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang='ts'>
22
import { onMounted, ref } from 'vue'
33
import { NButton, NInput, NSelect, NSpin, NSwitch, useMessage } from 'naive-ui'
4-
import type { ConfigState, SearchConfig, SearchServiceProvider } from './model'
4+
import { SearchConfig } from './model'
5+
import type { ConfigState, SearchServiceProvider } from './model'
56
import { fetchChatConfig, fetchTestSearch, fetchUpdateSearch } from '@/api'
67
import { t } from '@/locales'
78
@@ -22,6 +23,10 @@ async function fetchConfig() {
2223
try {
2324
loading.value = true
2425
const { data } = await fetchChatConfig<ConfigState>()
26+
if (!data.searchConfig)
27+
data.searchConfig = new SearchConfig(false, '', { apiKey: '' })
28+
if (!data.searchConfig.options)
29+
data.searchConfig.options = { apiKey: '' }
2530
config.value = data.searchConfig
2631
}
2732
finally {
@@ -87,11 +92,9 @@ onMounted(() => {
8792
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.searchApiKey') }}</span>
8893
<div class="flex-1">
8994
<NInput
90-
:value="config && config.options && config.options.apiKey"
95+
v-model:value="config.options.apiKey"
9196
placeholder=""
92-
type="password"
9397
show-password-on="click"
94-
@input="(val) => { if (config && config.options) config.options.apiKey = val }"
9598
/>
9699
</div>
97100
</div>

src/components/common/Setting/model.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,19 @@ export interface GiftCard {
182182
redeemed: number
183183
}
184184

185-
export type SearchServiceProvider = 'tavily'
185+
export type SearchServiceProvider = 'tavily' | ''
186186

187187
export interface SearchServiceOptions {
188188
apiKey: string
189189
}
190190

191191
export class SearchConfig {
192-
enabled?: boolean
193-
provider?: SearchServiceProvider
194-
options?: SearchServiceOptions
192+
enabled: boolean
193+
provider: SearchServiceProvider
194+
options: SearchServiceOptions
195+
constructor(enabled: boolean, provider: SearchServiceProvider, options: SearchServiceOptions) {
196+
this.enabled = enabled
197+
this.provider = provider
198+
this.options = options
199+
}
195200
}

0 commit comments

Comments
 (0)