Gemini-2-5-Pro-O-02main.tsx61 matches
2import { OpenAI } from "npm:openai";
34const IMAGE_COST = 400;
5const TEXT_COST = 400;
6const FILE_ANALYSIS_COST = 400;
4445const POE_MODELS = {
46imageGeneration: [
47"Flux-schnell",
48"Flux-schnell-DI",
49"ImageCreatorSD",
50"Free-GPT-Image-1"
51],
52textGeneration: [
65"Llama-3.1-8b-DI"
66],
67imageAnalysis: [
68"Qwen3-235B-A22B",
69"Gemini-1.5-Flash",
118119function selectOptimalTokens(contentLength: number, taskType: string): number {
120if (taskType === "Image Generation") return 1024;
121if (contentLength < 100) return 1024; // Short queries
122if (contentLength < 500) return 1500; // Medium queries
130taskType: string,
131timeout: number = 15000,
132isImageGeneration: boolean = false
133): Promise<string | null> {
134try {
153const content = message?.content;
154155if (isImageGeneration && message?.attachments && message.attachments.length > 0) {
156const imageAttachment = message.attachments.find(att =>
157att.content_type && att.content_type.startsWith('image/')
158);
159if (imageAttachment && imageAttachment.url) {
160return imageAttachment.url;
161}
162}
175taskType: string,
176timeout: number = 15000,
177isImageGeneration: boolean = false
178): Promise<string | null> {
179// Try first 2 models in parallel for speed
187for (const model of parallelModels) {
188promises.push(
189callSinglePoeModel(model, prompt, keyIndex, taskType, timeout, isImageGeneration)
190.then(result => ({ result, model, keyIndex }))
191);
203console.log(`Success with ${successful.value.model} (API key ${successful.value.keyIndex + 1})`);
204
205if (isImageGeneration) {
206const urlMatch = successful.value.result.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp)/i);
207if (urlMatch) {
208send("replace_response", {
209text: `π¨ **${taskType} completed**\n\n`
210});
211return urlMatch[0];
232for (const model of remainingModels) {
233for (let keyIndex = 0; keyIndex < POE_API_KEYS.length; keyIndex++) {
234const result = await callSinglePoeModel(model, prompt, keyIndex, taskType, timeout, isImageGeneration);
235if (result) {
236if (isImageGeneration) {
237const urlMatch = result.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp)/i);
238if (urlMatch) {
239send("replace_response", {
240text: `π¨ **${taskType} completed**\n\n`
241});
242return urlMatch[0];
260}
261262async function imageToBase64(imageUrl: string): Promise<{ data: string; mimeType: string }> {
263try {
264const response = await fetch(imageUrl, { timeout: 8000 });
265if (!response.ok) {
266throw new Error(`Failed to fetch image: ${response.status}`);
267}
268const arrayBuffer = await response.arrayBuffer();
269const buffer = Buffer.from(arrayBuffer);
270const mimeType = response.headers.get('content-type') || 'image/jpeg';
271return { data: buffer.toString('base64'), mimeType: mimeType };
272} catch (error) {
273console.error('Error converting image to base64:', error);
274throw error;
275}
281send: SendEventFn,
282taskType: string,
283imageUrl?: string
284): Promise<string | null> {
285try {
287
288let parts: any[] = [{ text: prompt }];
289if (imageUrl) {
290const { data: imageBase64, mimeType } = await imageToBase64(imageUrl);
291parts.push({
292inline_data: {
293mime_type: mimeType,
294data: imageBase64
295}
296});
338}
339340async function generateImage(prompt: string, send: SendEventFn): Promise<void> {
341let cleanPrompt = prompt;
342if (cleanPrompt.endsWith('--image')) {
343cleanPrompt = cleanPrompt.substring(0, cleanPrompt.length - 7).trim();
344}
345346const imagePrompt = `Detailed ${cleanPrompt}`;
347send("text", { text: `π¨ Generating image...` });
348349const result = await callPoeModelParallel(
350POE_MODELS.imageGeneration,
351imagePrompt,
352send,
353"Image Generation",
35415000,
355true
358if (!result) {
359send("error", {
360text: `β Image generation failed: All models exhausted.`,
361allow_retry: true
362});
436}
437438async function analyzeImage(imageUrl: string, userPrompt: string, send: SendEventFn): Promise<void> {
439let analysisPrompt: string;
440if (!userPrompt || userPrompt.trim().length === 0) {
441analysisPrompt = `Analyze this image in detail. Provide a comprehensive analysis including what you see, colors, objects, people, text, context, and any other relevant details.`;
442} else {
443analysisPrompt = `${userPrompt}`;
444}
445446send("text", { text: `π Analyzing image...` });
447448// Try Gemini Pro with vision first
449const geminiResult = await callGeminiApi(GEMINI_VISION_CONFIG, analysisPrompt, send, "Image Analysis", imageUrl);
450if (geminiResult) return;
451452// Fallback to Poe models with URL reference
453const fallbackPrompt = `Analyze image: ${imageUrl}\n\nUser's request: ${userPrompt || "Provide detailed analysis"}`;
454const poeResult = await callPoeModelParallel(
455POE_MODELS.imageAnalysis,
456fallbackPrompt,
457send,
458"Image Analysis",
45915000
460);
462if (!poeResult) {
463send("error", {
464text: `β Image analysis failed: All models exhausted.`,
465allow_retry: true
466});
509}
510511if (cleanContent.endsWith('--image')) {
512return { intent: 'image_generation', useClaudeModels };
513}
514518519if (hasAttachments) {
520if (lowerContent.includes('image') || lowerContent.includes('picture') ||
521lowerContent.includes('photo') || lowerContent.includes('analyze') ||
522lowerContent.includes('what') || lowerContent.includes('describe')) {
523return { intent: 'image_analysis', useClaudeModels };
524}
525return { intent: 'file_analysis', useClaudeModels };
526}
527528if (lowerContent.includes('generate image') || lowerContent.includes('create image') ||
529lowerContent.includes('draw') || lowerContent.includes('picture of') ||
530lowerContent.includes('image of')) {
531return { intent: 'image_generation', useClaudeModels };
532}
533563try {
564switch (intent) {
565case 'image_generation':
566await generateImage(userContent, send);
567break;
568590break;
591592case 'image_analysis':
593if (attachments.length > 0) {
594const imageAttachment = attachments.find(att =>
595att.content_type && att.content_type.startsWith('image/')
596);
597if (imageAttachment && imageAttachment.url) {
598await analyzeImage(imageAttachment.url, userContent, send);
599} else {
600send("error", {
605} else {
606send("error", {
607text: "Please attach an image for analysis.",
608allow_retry: false,
609});
652const rateCard = "| Task Type | Price |\n" +
653"|-----------|-------|\n" +
654`| Input (image) | ${IMAGE_COST} points/message |\n` +
655`| Input (file) | ${FILE_ANALYSIS_COST} points/message |\n` +
656`| Input (text) | ${TEXT_COST} points/message |\n` +
657`| Output (search) | ${SEARCH_COST} points/message |\n` +
658`| Output (image) | ${IMAGE_COST} points/message |\n`;
659660return {
Gemini-2-5-Pro-O-01main.tsx60 matches
2import { OpenAI } from "npm:openai";
34const IMAGE_COST = 400;
5const TEXT_COST = 400;
6const FILE_ANALYSIS_COST = 400;
4243const POE_MODELS = {
44imageGeneration: [
45"ImageCreatorSD",
46"Free-GPT-Image-1",
47"Flux-schnell-DI",
48"Flux-schnell"
64"Gemini-1.5-Flash"
65],
66imageAnalysis: [
67"Llama-3.1-8b-DI",
68"Qwen3-235B-A22B",
97taskType: string,
98timeout: number = 30000,
99isImageGeneration: boolean = false
100): Promise<string | null> {
101for (let keyIndex = 0; keyIndex < POE_API_KEYS.length; keyIndex++) {
123const content = message?.content;
124125if (isImageGeneration && message?.attachments && message.attachments.length > 0) {
126const imageAttachment = message.attachments.find(att =>
127att.content_type && att.content_type.startsWith('image/')
128);
129
130if (imageAttachment && imageAttachment.url) {
131send("replace_response", {
132text: `π¨ **${taskType} completed**\n\n`
133});
134return imageAttachment.url;
135}
136}
137138if (content && content.trim().length > 0) {
139if (isImageGeneration) {
140const urlMatch = content.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp)/i);
141if (urlMatch) {
142send("replace_response", {
143text: `π¨ **${taskType} completed**\n\n`
144});
145return urlMatch[0];
164}
165166async function imageToBase64(imageUrl: string): Promise<{ data: string; mimeType: string }> {
167try {
168const response = await fetch(imageUrl, { timeout: 10000 });
169if (!response.ok) {
170throw new Error(`Failed to fetch image: ${response.status}`);
171}
172
173const arrayBuffer = await response.arrayBuffer();
174const buffer = Buffer.from(arrayBuffer);
175const mimeType = response.headers.get('content-type') || 'image/jpeg';
176
177return {
180};
181} catch (error) {
182console.error('Error converting image to base64:', error);
183throw error;
184}
189send: SendEventFn,
190taskType: string,
191imageUrl?: string
192): Promise<string | null> {
193try {
197let parts: any[] = [{ text: prompt }];
198
199if (imageUrl) {
200const { data: imageBase64, mimeType } = await imageToBase64(imageUrl);
201parts.push({
202inline_data: {
203mime_type: mimeType,
204data: imageBase64
205}
206});
252async function callGeminiVision(
253prompt: string,
254imageUrl: string,
255send: SendEventFn,
256taskType: string
258try {
259console.log(`Trying ${taskType} with Gemini Vision`);
260send("text", { text: `π Processing image with Gemini Vision...` });
261262const { data: imageBase64, mimeType } = await imageToBase64(imageUrl);
263264const payload = {
270inline_data: {
271mime_type: mimeType,
272data: imageBase64
273}
274}
418}
419420async function generateImage(prompt: string, send: SendEventFn): Promise<void> {
421let cleanPrompt = prompt;
422if (cleanPrompt.endsWith('--image')) {
423cleanPrompt = cleanPrompt.substring(0, cleanPrompt.length - 7).trim();
424}
425426const imagePrompt = `Detailed ${cleanPrompt}`;
427send("text", { text: `π¨ Generating image...` });
428429const result = await callPoeModel(
430POE_MODELS.imageGeneration,
431imagePrompt,
432send,
433"Image Generation",
43420000,
435true
437438if (!result) {
439await fallbackToGemini(imagePrompt, send, "Image Generation");
440}
441}
508}
509510async function analyzeImage(imageUrl: string, userPrompt: string, send: SendEventFn): Promise<void> {
511let analysisPrompt: string;
512if (!userPrompt || userPrompt.trim().length === 0) {
513analysisPrompt = `Analyze this image in detail. Provide a comprehensive analysis including what you see, colors, objects, people, text, context, and any other relevant details.`;
514} else {
515analysisPrompt = `${userPrompt}`;
516}
517518const geminiProResult = await callGeminiPro(analysisPrompt, send, "Image Analysis", imageUrl);
519if (!geminiProResult) {
520const geminiResult = await callGeminiVision(analysisPrompt, imageUrl, send, "Image Analysis");
521if (!geminiResult) {
522const fallbackPrompt = `Analyze image: ${imageUrl}\n\nUser's request: ${userPrompt || "Provide detailed analysis"}\n\n`;
523const poeResult = await callPoeModel(
524POE_MODELS.imageAnalysis,
525fallbackPrompt,
526send,
527"Image Analysis",
52825000
529);
530531if (!poeResult) {
532await fallbackToGemini(fallbackPrompt, send, "Image Analysis");
533}
534}
575}
576577if (cleanContent.endsWith('--image')) {
578return { intent: 'image_generation', useClaudeModels };
579}
580584585if (hasAttachments) {
586if (lowerContent.includes('image') || lowerContent.includes('picture') ||
587lowerContent.includes('photo') || lowerContent.includes('analyze') ||
588lowerContent.includes('what') || lowerContent.includes('describe')) {
589return { intent: 'image_analysis', useClaudeModels };
590}
591return { intent: 'file_analysis', useClaudeModels };
592}
593594if (lowerContent.includes('generate image') || lowerContent.includes('create image') ||
595lowerContent.includes('draw') || lowerContent.includes('picture of') ||
596lowerContent.includes('image of')) {
597return { intent: 'image_generation', useClaudeModels };
598}
599630try {
631switch (intent) {
632case 'image_generation':
633await generateImage(userContent, send);
634break;
635660break;
661662case 'image_analysis':
663if (attachments.length > 0) {
664const imageAttachment = attachments.find(att =>
665att.content_type && att.content_type.startsWith('image/')
666);
667668if (imageAttachment && imageAttachment.url) {
669await analyzeImage(imageAttachment.url, userContent, send);
670} else {
671send("error", {
676} else {
677send("error", {
678text: "Please attach an image for analysis.",
679allow_retry: false,
680});
723const rateCard = "| Task Type | Price |\n" +
724"|-----------|-------|\n" +
725`| Input (image) | ${IMAGE_COST} points |\n` +
726`| Input (file) | ${FILE_ANALYSIS_COST} points |\n` +
727`| Input (text) | ${TEXT_COST} points |\n` +
728`| Output (search) | ${SEARCH_COST} points |\n`+
729`| Output (image) | ${IMAGE_COST} points |\n`;
730731return {
nabanhotelmain.ts1 match
11<style>body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial; }</n/style>
12<style>
13.hero-bg { background-image: linear-gradient(90deg, rgba(2,6,23,0.55), rgba(2,6,23,0.35)), url('https://images.unsplash.com/photo-1501117716987-c8e2f7a1b1a7?auto=format&fit=crop&w=1600&q=60'); background-size: cover; background-position: center; }
14.gallery-img { background-size: cover; background-position: center; }
15</style>
campanhapsdalcoframain.ts4 matches
93profissao: "Profissional de Seguros",
94localidade: "Oliveira de Frades",
95foto: "https://i.postimg.cc/L6ckF9GG/cropped-circle-image-2.png",
96},
97{
99profissao: "Programador InformΓ‘tico",
100localidade: "Agros-Alcofra",
101foto: "https://i.postimg.cc/vTVHLzP2/cropped-circle-image-1.png",
102},
103{
105profissao: "Auxiliar Educativa",
106localidade: "Ribeira-Alcofra",
107foto: "https://i.postimg.cc/NMVjHVxr/cropped-circle-image.png",
108},
109];
697<meta name="viewport" content="width=device-width, initial-scale=1.0">
698<script src="https://cdn.tailwindcss.com"></script>
699<link rel="icon" href="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Flag_of_the_Social_Democratic_Party_%28Portugal%29.svg/1200px-Flag_of_the_Social_Democratic_Party_%28Portugal%29.svg.png" type="image/png" />
700<style>
701</style>
h6-val-summary.ts3 matches
16SUM(cache_write_tokens) as total_cache_write_tokens,
17SUM(price) as total_price,
18SUM(num_images) as total_images
19FROM ${USAGE_TABLE}
20WHERE val_id = ? AND our_api_token = 1
54total_cache_write_tokens: 0,
55total_price: 0,
56total_images: 0
57};
58
85// Always include inference price for comparison
86inference_price: inferenceSummary.inference_price || 0,
87total_images: usageSummary.total_images,
88// Add flag to indicate inference data usage
89used_inference_data: !!inferenceSummary.inference_price,
h6-val-detail.ts6 matches
17price?: number;
18finish_reason?: string;
19num_images?: number;
20our_api_token: boolean;
21}
31inference_price: number;
32original_price?: number;
33total_images: number;
34used_inference_data?: boolean;
35inference_price_primary?: boolean;
66<th>Cache Write</th>
67<th>Total Price</th>
68<th>Images</th>
69</tr>
70</thead>
76<td>${formatNumber(summary.total_cache_write_tokens)}</td>
77<td class="price">${formatPrice(summary.total_price)}</td>
78<td>${formatNumber(summary.total_images)}</td>
79</tr>
80</tbody>
97<th>Price</th>
98<th>Finish</th>
99<th>Images</th>
100</tr>
101</thead>
114<td class="price">${formatPrice(row.price)}</td>
115<td>${row.finish_reason || '-'}</td>
116<td>${formatNumber(row.num_images)}</td>
117</tr>
118`).join("")}
h6-user-summary.ts2 matches
18SUM(cache_write_tokens) as total_cache_write_tokens,
19SUM(price) as total_price,
20SUM(num_images) as total_images
21FROM ${USAGE_TABLE}
22WHERE our_api_token = 1
151total_price: userData.price,
152inference_price: inferencePriceByUser.get(userId) || 0,
153total_images: 0,
154used_inference_data: true
155});
h6-user-detail.ts7 matches
13total_price: number;
14inference_price: number;
15total_images: number;
16used_inference_data?: boolean;
17}
32price?: number;
33finish_reason?: string;
34num_images?: number;
35our_api_token: boolean;
36}
48total_price: 0,
49inference_price: 0,
50total_images: 0
51};
52
77<th>Total Price</th>
78<th>Inference Price</th>
79<th>Images</th>
80</tr>
81</thead>
88<td class="price">${formatPrice(userData.total_price)} ${userData.used_inference_data ? '<span class="badge badge-info" title="Using inference data">I</span>' : ''}</td>
89<td class="price">${formatPrice(userData.inference_price || 0)}</td>
90<td>${formatNumber(userData.total_images)}</td>
91</tr>
92</tbody>
135<th>Price</th>
136<th>Finish</th>
137<th>Images</th>
138</tr>
139</thead>
152<td class="price">${formatPrice(row.price)}</td>
153<td>${row.finish_reason || '-'}</td>
154<td>${formatNumber(row.num_images)}</td>
155</tr>
156`).join("")}
h6-useChatLogic.ts4 matches
7branchId: string | undefined;
8selectedFiles: string[];
9images: (string | null)[];
10soundEnabled: boolean;
11}
20// bearerToken,
21selectedFiles,
22images,
23soundEnabled,
24}: UseChatLogicProps) {
44branchId,
45selectedFiles,
46images: images
47.filter((img): img is string => {
48const isValid = typeof img === "string" && img.startsWith("data:");
49if (!isValid && img !== null) {
50console.warn(
51"Invalid image format:",
52img?.substring(0, 50) + "..."
53);
h6-usage-detail.ts2 matches
17price?: number;
18finish_reason?: string;
19num_images?: number;
20our_api_token: boolean;
21}
126</div>
127<div class="card-item">
128<strong>Images:</strong> ${formatNumber(usage.num_images)}
129</div>
130<div class="card-item">