mirror of
				https://github.com/Yidadaa/ChatGPT-Next-Web.git
				synced 2025-11-04 16:57:27 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			652 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			652 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { MaskConfig, ProviderConfig } from "../store";
 | 
						|
import { shareToShareGPT } from "./common/share";
 | 
						|
import { createOpenAiClient } from "./openai";
 | 
						|
import { ChatControllerPool } from "./common/controller";
 | 
						|
 | 
						|
export const LLMClients = {
 | 
						|
  openai: createOpenAiClient,
 | 
						|
};
 | 
						|
 | 
						|
export function createLLMClient(
 | 
						|
  config: ProviderConfig,
 | 
						|
  maskConfig: MaskConfig,
 | 
						|
) {
 | 
						|
  return LLMClients[maskConfig.provider as any as keyof typeof LLMClients](
 | 
						|
    config,
 | 
						|
    maskConfig.modelConfig,
 | 
						|
  );
 | 
						|
}
 | 
						|
 | 
						|
export function createApi() {
 | 
						|
  return {
 | 
						|
    createLLMClient,
 | 
						|
    shareToShareGPT,
 | 
						|
    controllerManager: ChatControllerPool,
 | 
						|
  };
 | 
						|
}
 | 
						|
 | 
						|
export const api = createApi();
 |