✨ feat(vscode): 问 AI 和重写注释各用各的 profile,设置里加重写注释默认模型
This commit is contained in:
1 parent
925f1ed39a
commit
b83c445dd0
25 files changed
+363
-111
No files matched your search
@@ -34,13 +34,18 @@ export interface ProfileSource {
|
||||
|
||||
const PROFILE_SOURCE: ProfileSource = { list: listClaudeProfiles, defaultPath: getDefaultProfilePath, directory: getProfilesDir }
|
||||
|
||||
/** 所有预览共用临时模型选择,重新创建服务或修改默认配置后恢复设置里的默认值。 */
|
||||
/**
|
||||
* 一套 profile 选择:临时切换所有预览共用、不写进设置,重新创建服务或这一套的默认配置改了以后回到设置里的默认值。
|
||||
*
|
||||
* @param purpose 这一套给什么用(「问答」「重写注释」);报错时用它说是哪一套、该改设置里的哪一项
|
||||
* @param configuredPath 读设置里这一套的默认 profile 路径
|
||||
*/
|
||||
export class AskProfiles {
|
||||
private readonly listeners = new Set<(choice: ProfileChoice) => void>()
|
||||
private temporary: string | undefined
|
||||
private defaultKey: string | undefined
|
||||
|
||||
constructor(private readonly configuredPath: () => string, private readonly source: ProfileSource = PROFILE_SOURCE) {}
|
||||
constructor(readonly purpose: string, private readonly configuredPath: () => string, private readonly source: ProfileSource = PROFILE_SOURCE) {}
|
||||
|
||||
async choice(): Promise<ProfileChoice> {
|
||||
return (await this.read()).choice
|
||||
@@ -52,7 +57,7 @@ export class AskProfiles {
|
||||
this.publish(choice)
|
||||
const profile = profiles.find(profile => profile.name === choice.selected)
|
||||
if (choice.selected && !profile)
|
||||
throw new Error(`文件问答模型不可用:${choice.selected}。请在设置中重新选择默认模型,或在输入框旁临时切换。`)
|
||||
throw new Error(`${this.purpose}模型不可用:${choice.selected}。请在设置的「${this.purpose}默认模型」里重新选择,或在输入框旁临时切换。`)
|
||||
return profile
|
||||
}
|
||||
|
||||
@@ -66,7 +71,7 @@ export class AskProfiles {
|
||||
const { profiles, choice } = await this.read()
|
||||
const profile = profiles.find(profile => profile.name === id)
|
||||
if (id ? !profile : !choice.options.some(option => option.id === ''))
|
||||
throw new Error(`文件问答模型不可用:${id}。请重新选择。`)
|
||||
throw new Error(`${this.purpose}模型不可用:${id}。请重新选择。`)
|
||||
this.temporary = profile?.path ?? ''
|
||||
await this.refresh()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user