- Increase logo size (48x48 desktop, 56x56 mobile) for better visibility - Add logo as favicon - Add logo to mobile header - Move user menu to navigation bars (sidebar on desktop, bottom bar on mobile) - Fix desktop chat layout - container structure prevents voice controls cutoff - Fix mobile bottom bar - use icon-only ActionIcons instead of truncated text buttons - Hide Create Node/New Conversation buttons on mobile to save header space - Make fixed header and voice controls work properly with containers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
|
|
// Validate required environment variables
|
|
if (!process.env.GOOGLE_GENERATIVE_AI_API_KEY) {
|
|
throw new Error('GOOGLE_GENERATIVE_AI_API_KEY environment variable is required');
|
|
}
|
|
|
|
if (!process.env.GOOGLE_EMBEDDING_MODEL) {
|
|
throw new Error('GOOGLE_EMBEDDING_MODEL environment variable is required (e.g., gemini-embedding-001)');
|
|
}
|
|
|
|
const genAI = new GoogleGenerativeAI(process.env.GOOGLE_GENERATIVE_AI_API_KEY);
|
|
|
|
const embeddingModel = genAI.getGenerativeModel({
|
|
model: process.env.GOOGLE_EMBEDDING_MODEL,
|
|
});
|
|
|
|
/**
|
|
* Generates a vector embedding for a given text using the configured Google embedding model.
|
|
*
|
|
* @param text - The text to embed
|
|
* @returns A vector embedding (dimension depends on model)
|
|
*/
|
|
export async function generateEmbedding(text: string): Promise<number[]> {
|
|
try {
|
|
const result = await embeddingModel.embedContent(text);
|
|
return result.embedding.values;
|
|
} catch (error) {
|
|
console.error('Error generating embedding:', error);
|
|
throw new Error('Failed to generate AI embedding.');
|
|
}
|
|
}
|