feat: dev done

This commit is contained in:
butterfly
2024-04-07 11:32:57 +08:00
19 changed files with 1031 additions and 32 deletions

View File

@@ -36,6 +36,11 @@ const DEFAULT_ACCESS_STATE = {
googleApiKey: "",
googleApiVersion: "v1",
// anthropic
anthropicApiKey: "",
anthropicApiVersion: "2023-06-01",
anthropicUrl: "",
// server config
needCode: true,
hideUserApiKey: false,
@@ -67,6 +72,10 @@ export const useAccessStore = createPersistStore(
return ensure(get(), ["googleApiKey"]);
},
isValidAnthropic() {
return ensure(get(), ["anthropicApiKey"]);
},
isAuthorized() {
this.fetch();
@@ -75,6 +84,7 @@ export const useAccessStore = createPersistStore(
this.isValidOpenAI() ||
this.isValidAzure() ||
this.isValidGoogle() ||
this.isValidAnthropic() ||
!this.enabledAccessControl() ||
(this.enabledAccessControl() && ensure(get(), ["accessCode"]))
);

View File

@@ -287,7 +287,7 @@ export const useChatStore = createPersistStore(
session.lastUpdate = Date.now();
});
get().updateStat(message);
get().summarizeSession();
// get().summarizeSession();
},
async onUserInput(content: string, attachImages?: string[]) {
@@ -348,6 +348,8 @@ export const useChatStore = createPersistStore(
var api: ClientApi;
if (modelConfig.model.startsWith("gemini")) {
api = new ClientApi(ModelProvider.GeminiPro);
} else if (modelConfig.model.startsWith("claude")) {
api = new ClientApi(ModelProvider.Claude);
} else {
api = new ClientApi(ModelProvider.GPT);
}
@@ -533,6 +535,8 @@ export const useChatStore = createPersistStore(
var api: ClientApi;
if (modelConfig.model.startsWith("gemini")) {
api = new ClientApi(ModelProvider.GeminiPro);
} else if (modelConfig.model.startsWith("claude")) {
api = new ClientApi(ModelProvider.Claude);
} else {
api = new ClientApi(ModelProvider.GPT);
}