val-town-http-mcp-servervalley.txt2 matches
169170- **Redirects:** Use `return new Response(null, { status: 302, headers: { Location: "/place/to/redirect" }})` instead of `Response.redirect` which is broken
171- **Images:** Avoid external images or base64 images. Use emojis, unicode symbols, or icon fonts/libraries instead
172- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
173- **Storage:** DO NOT use the Deno KV module for storage
174- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
33// These are critical requirements for Val Town
34* Response.redirect is broken. Use return new Response(null, { status: 302, headers: { Location: "/place/to/redirect" }})
35* Avoid external images or base64 images when possible
36* For AI-generated images, use: https://maxm-imggenurl.web.val.run/[description]
37* DO NOT use Deno KV module, alert(), prompt(), or confirm() methods
38* For weather data, use open-meteo (no API key required)
val-town-http-mcp-servertownie.txt2 matches
18* Response.redirect is broken. Use `return new Response(null, { status: 302, headers: { Location: "/place/to/redirect" }})`
1920* Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's not practical for the user's request (e.g. if they ask for a particular animated gif).
2122* If you want an AI generated image, use https://maxm-imggenurl.web.val.run/the-description-of-your-image to dynamically generate one.
2324* DO NOT use the Deno KV module for storage.
124description: z.string().max(64).optional()
125.describe("Description for the project (optional, max 64 characters)"),
126imageUrl: z.string().optional().describe("URL to an image for the project (optional)"),
127},
128async ({name, privacy, description, imageUrl}: {
129name: string
130privacy: "public" | "unlisted" | "private"
131description?: string
132imageUrl?: string
133}) => {
134try {
159privacy,
160...(description ? {description} : {}),
161...(imageUrl ? {imageUrl} : {}),
162}
163
101## Val Town Platform Specifics
102- **Redirects:** Use `return new Response(null, { status: 302, headers: { Location: "/place/to/redirect" }})` instead of `Response.redirect` which is broken
103- **Images:** Avoid external images or base64 images. Use emojis, unicode symbols, or icon fonts/libraries instead
104- For AI-generated images, use: `https://maxm-imggenurl.web.val.run/the-description-of-your-image`
105- **Storage:** DO NOT use the Deno KV module for storage
106- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
Gemini-Nano-Banana-03main.tsx41 matches
1/* Generate beautifull, high quality images: https://poe.com/Gemini-Nano-Banana */
23import process from "node:process";
4import { OpenAI } from "npm:openai";
5const IMAGE_COST = 500;
67interface ModelConfig {
12}
1314const IMAGE_MODEL: ModelConfig = {
15provider: "google",
16model: "gemini-2.5-flash-image-preview",
17endpoint:
18"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent",
19headers: {
20"Content-Type": "application/json",
35}
3637function extractImageUrl(content: string): string | null {
38// Extract URLs from POE response
39const urlMatch = content.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp)/i);
40if (urlMatch) return urlMatch[0];
41
42// Extract markdown image format
43const mdMatch = content.match(/!\[.*?\]\((https?:\/\/[^\)]+)\)/);
44if (mdMatch) return mdMatch[1];
49}
5051async function generateImageWithPoe(
52prompt: string,
53send: SendEventFn
60
61try {
62console.log(`Attempting Poe image generation with API key ${keyNumber}`);
63
64const poeClient = createPoeClient(apiKey);
65const imagePrompt = `Generate high-quality image: ${prompt}`;
66
67const chat = await poeClient.chat.completions.create({
68model: "FLUX-schnell-DI",
69messages: [{ role: "user", content: imagePrompt }],
70max_tokens: 1024,
71temperature: 0.8,
75
76if (content) {
77const imageUrl = extractImageUrl(content);
78
79if (imageUrl) {
80send("text", {
81text: `๐จ **Image Generated Successfully!**\n\n*`
82});
83return;
84} else {
85// If no URL found, send the content as-is (might contain image data or instructions)
86send("text", {
87text: `๐จ **Image Generated!**\n\n${content}`
88});
89return;
106console.error("All API keys failed:", lastError);
107send("error", {
108text: `Image generation failed: All Poe API keys exhausted. Last error: ${lastError?.message || 'Unknown error'}. Please try a different prompt.`,
109allow_retry: true
110});
125},
126body: JSON.stringify({
127model: "google/gemini-2.5-flash-image-preview",
128messages: [
129{
144
145if (content) {
146const imageUrl = extractImageUrl(content);
147
148if (imageUrl) {
149send("text", {
150text: `๐จ **Image Generated Successfully!**\n\n`
151});
152} else {
153send("text", {
154text: `๐จ **Image Generated!**\n\n${content}`
155});
156}
165}
166167async function generateImage(
168prompt: string,
169send: SendEventFn
181
182// Try Gemini
183const imagePrompt = `Detailed image: ${prompt}.`;
184
185const payload = {
186contents: [{
187role: "user",
188parts: [{ text: imagePrompt }]
189}],
190generationConfig: {
195};
196197const url = `${IMAGE_MODEL.endpoint}?key=${process.env.GEMINI_API_KEY}`;
198
199const response = await fetch(url, {
200method: "POST",
201headers: IMAGE_MODEL.headers,
202body: JSON.stringify(payload),
203});
204205if (!response.ok) {
206console.warn("Gemini image generation failed");
207await generateImageWithPoe(prompt, send);
208return;
209}
213
214if (generatedContent) {
215const imageUrl = extractImageUrl(generatedContent);
216
217if (imageUrl) {
218send("text", {
219text: `๐จ **Image Generated Successfully!**\n\n\n\n*Generated using Gemini-2.5-Flash-Image-Preview*`
220});
221} else {
222send("text", {
223text: `๐จ **Image Generated!**\n\n${generatedContent}\n\n*Generated using Gemini-2.5-Flash-Image-Preview*`
224});
225}
226} else {
227console.warn("No content from Gemini");
228await generateImageWithPoe(prompt, send);
229}
230
231} catch (error) {
232console.error("Primary image generation error:", error);
233console.warn("Attempting Poe fallback");
234await generateImageWithPoe(prompt, send);
235}
236}
267const lastUserMessage = messages.filter((m) => m.role === "user").pop();
268if (!lastUserMessage) {
269await generateImage("Welcome! I'm an image generation bot. Here's a beautiful sunset landscape to start.", send);
270send("done", {});
271return;
276if (!userContent || userContent.trim().length === 0) {
277send("error", {
278text: "Please provide a description for the image you'd like me to generate.",
279allow_retry: false,
280});
283}
284285await generateImage(userContent, send);
286send("done", {});
287}
289async function getBotSettings(): Promise<BotSettings> {
290const rateCard = "| Type | Price |\n" + "|------|------|\n" +
291`| Image Generation | ${IMAGE_COST} points |\n`;
292const costLabel = `${IMAGE_COST} points`;
293294return {
573<meta charset="UTF-8">
574<meta name="viewport" content="width=device-width, initial-scale=1.0">
575<link rel="icon" type="image/png" href="https://labspace.ai/ls2-circle.png" />
576<title>Zoom RTMS App</title>
577<meta property="og:title" content="Zoom RTMS App" />
578<meta property="og:description" content="Real-time transcript analysis and OAuth integration for Zoom meetings" />
579<meta property="og:image" content="https://yawnxyz-og.web.val.run/img?link=https://yawnxyz-zoom-rtms.web.val.run&title=Zoom+RTMS+Test&subtitle=Test+app+for+Zoom+OAuth+integration" />
580<meta property="og:url" content="https://yawnxyz-zoom-rtms.web.val.run/" />
581<meta property="og:type" content="website" />
582<meta name="twitter:card" content="summary_large_image" />
583<meta name="twitter:title" content="Zoom RTMS App" />
584<meta name="twitter:description" content="Real-time transcript analysis and OAuth integration for Zoom meetings" />
585<meta name="twitter:image" content="https://yawnxyz-og.web.val.run/img?link=https://yawnxyz-zoom-rtms.web.val.run&title=Zoom+RTMS+Test&subtitle=Test+app+for+Zoom+OAuth+integration" />
586<script src="https://cdn.tailwindcss.com"></script>
587<script>
Gemini-Nano-Banana-01main.tsx41 matches
1/* Generate beautifull, high quality images: https://poe.com/Gemini-Nano-Banana */
23import process from "node:process";
4import { OpenAI } from "npm:openai";
5const IMAGE_COST = 500;
67interface ModelConfig {
12}
1314const IMAGE_MODEL: ModelConfig = {
15provider: "google",
16model: "gemini-2.5-flash-image-preview",
17endpoint:
18"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent",
19headers: {
20"Content-Type": "application/json",
35}
3637function extractImageUrl(content: string): string | null {
38// Extract URLs from POE response
39const urlMatch = content.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp)/i);
40if (urlMatch) return urlMatch[0];
41
42// Extract markdown image format
43const mdMatch = content.match(/!\[.*?\]\((https?:\/\/[^\)]+)\)/);
44if (mdMatch) return mdMatch[1];
49}
5051async function generateImageWithPoe(
52prompt: string,
53send: SendEventFn
60
61try {
62console.log(`Attempting Poe image generation with API key ${keyNumber}`);
63
64const poeClient = createPoeClient(apiKey);
65const imagePrompt = `Generate high-quality image: ${prompt}`;
66
67const chat = await poeClient.chat.completions.create({
68model: "FLUX-schnell-DI",
69messages: [{ role: "user", content: imagePrompt }],
70max_tokens: 1024,
71temperature: 0.8,
75
76if (content) {
77const imageUrl = extractImageUrl(content);
78
79if (imageUrl) {
80send("text", {
81text: `๐จ **Image Generated Successfully!**\n\n*`
82});
83return;
84} else {
85// If no URL found, send the content as-is (might contain image data or instructions)
86send("text", {
87text: `๐จ **Image Generated!**\n\n${content}`
88});
89return;
106console.error("All API keys failed:", lastError);
107send("error", {
108text: `Image generation failed: All POE API keys exhausted. Last error: ${lastError?.message || 'Unknown error'}. Please try a different prompt.`,
109allow_retry: true
110});
125},
126body: JSON.stringify({
127model: "google/gemini-2.5-flash-image-preview",
128messages: [
129{
144
145if (content) {
146const imageUrl = extractImageUrl(content);
147
148if (imageUrl) {
149send("text", {
150text: `๐จ **Image Generated Successfully!**\n\n\n\n*Generated using Flux 1.1 Pro via OpenRouter*`
151});
152} else {
153send("text", {
154text: `๐จ **Image Generated!**\n\n${content}\n\n*Generated using Flux 1.1 Pro via OpenRouter*`
155});
156}
165}
166167async function generateImage(
168prompt: string,
169send: SendEventFn
181
182// Try Gemini
183const imagePrompt = `Detailed image: ${prompt}.`;
184
185const payload = {
186contents: [{
187role: "user",
188parts: [{ text: imagePrompt }]
189}],
190generationConfig: {
195};
196197const url = `${IMAGE_MODEL.endpoint}?key=${process.env.GEMINI_API_KEY}`;
198
199const response = await fetch(url, {
200method: "POST",
201headers: IMAGE_MODEL.headers,
202body: JSON.stringify(payload),
203});
204205if (!response.ok) {
206console.warn("Gemini image generation failed");
207await generateImageWithPoe(prompt, send);
208return;
209}
213
214if (generatedContent) {
215const imageUrl = extractImageUrl(generatedContent);
216
217if (imageUrl) {
218send("text", {
219text: `๐จ **Image Generated Successfully!**\n\n\n\n*Generated using Gemini-2.5-Flash-Image-Preview*`
220});
221} else {
222send("text", {
223text: `๐จ **Image Generated!**\n\n${generatedContent}\n\n*Generated using Gemini-2.5-Flash-Image-Preview*`
224});
225}
226} else {
227console.warn("No content from Gemini");
228await generateImageWithPoe(prompt, send);
229}
230
231} catch (error) {
232console.error("Primary image generation error:", error);
233console.warn("Attempting Poe fallback");
234await generateImageWithPoe(prompt, send);
235}
236}
267const lastUserMessage = messages.filter((m) => m.role === "user").pop();
268if (!lastUserMessage) {
269await generateImage("Welcome! I'm an image generation bot. Here's a beautiful sunset landscape to start.", send);
270send("done", {});
271return;
276if (!userContent || userContent.trim().length === 0) {
277send("error", {
278text: "Please provide a description for the image you'd like me to generate.",
279allow_retry: false,
280});
283}
284285await generateImage(userContent, send);
286send("done", {});
287}
289async function getBotSettings(): Promise<BotSettings> {
290const rateCard = "| Type | Price |\n" + "|------|------|\n" +
291`| Image Generation | ${IMAGE_COST} points |\n`;
292const costLabel = `${IMAGE_COST} points`;
293294return {
14rel="icon"
15href="https://glitch.com/edit/favicon-app.ico"
16type="image/x-icon"
17> -->
18<!-- import the webpage's stylesheet -->
Gemini-2-5-Pro-O-01main.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} by Gemini-2.5-Pro-Omni 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} by Gemini-2.5-Pro-Omni 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 {