| | |
| | import { |
| | AuthType, |
| | createContentGeneratorConfig, |
| | createContentGenerator, |
| | } from '@google/gemini-cli-core/dist/src/core/contentGenerator.js'; |
| |
|
| | |
| | |
| | |
| | let modelName: string; |
| | const generatorPromise = (async () => { |
| | |
| | const cfg = await createContentGeneratorConfig( |
| | undefined, |
| | AuthType.USE_GEMINI |
| | ); |
| | modelName = cfg.model; |
| | return await createContentGenerator(cfg); |
| | })(); |
| |
|
| | |
| | |
| | |
| | type GenConfig = Record<string, unknown>; |
| |
|
| | export async function sendChat({ |
| | contents, |
| | generationConfig = {}, |
| | }: { |
| | contents: any[]; |
| | generationConfig?: GenConfig; |
| | tools?: unknown; // accepted but ignored for now |
| | }) { |
| | const generator: any = await generatorPromise; |
| | return await generator.generateContent({ |
| | model: modelName, |
| | contents, |
| | config: generationConfig, |
| | }); |
| | } |
| |
|
| | export async function* sendChatStream({ |
| | contents, |
| | generationConfig = {}, |
| | }: { |
| | contents: any[]; |
| | generationConfig?: GenConfig; |
| | tools?: unknown; |
| | }) { |
| | const generator: any = await generatorPromise; |
| | const stream = await generator.generateContentStream({ |
| | model: modelName, |
| | contents, |
| | config: generationConfig, |
| | }); |
| | for await (const chunk of stream) yield chunk; |
| | } |
| |
|
| | |
| | |
| | |
| | export function listModels() { |
| | return [{ id: modelName }]; |
| | } |
| |
|
| | export async function embed(_input: unknown) { |
| | throw new Error('Embeddings endpoint not implemented yet.'); |
| | } |
| |
|