allow services for anonymous users & gpt4 fix

This commit is contained in:
Cogent Apps
2023-04-29 18:29:48 +00:00
parent 5bcd75f120
commit 8f9ec46f9e
8 changed files with 33 additions and 11 deletions

View File

@@ -24,6 +24,7 @@ export interface User {
export class Backend extends EventEmitter {
public user: User | null = null;
public services: string[] = [];
private checkedSession = false;
private sessionInterval = new AsyncLoop(() => this.getSession(), 1000 * 30);
@@ -70,8 +71,10 @@ export class Backend extends EventEmitter {
avatar: session.picture,
services: session.services,
};
this.services = session.services || [];
} else {
this.user = null;
this.services = session?.services || [];
}
this.checkedSession = true;

View File

@@ -7,7 +7,7 @@ import { backend } from "../backend";
export const defaultModel = 'gpt-3.5-turbo';
export function isProxySupported() {
return !!backend.current?.user?.services?.includes('openai');
return !!backend.current?.services?.includes('openai');
}
function shouldUseProxy(apiKey: string | undefined | null) {
@@ -141,5 +141,5 @@ export async function createStreamingChatCompletion(messages: OpenAIMessage[], p
export const maxTokensByModel = {
"chatgpt-3.5-turbo": 2048,
"gpt-4": 8096,
"gpt-4": 8192,
}

View File

@@ -6,7 +6,7 @@ import { defaultElevenLabsVoiceID, defaultVoiceList } from "./elevenlabs-default
import { backend } from "../core/backend";
function isProxySupported() {
return !!backend.current?.user?.services?.includes('elevenlabs');
return !!backend.current?.services?.includes('elevenlabs');
}
function shouldUseProxy(apiKey: string | undefined | null) {