textToGeneratemain.tsx24 matches
7function App() {
8const [prompt, setPrompt] = useState("");
9const [imageUrl, setImageUrl] = useState("");
10const [generatedText, setGeneratedText] = useState("");
11const [isLoading, setIsLoading] = useState(false);
12const [error, setError] = useState("");
13const [mode, setMode] = useState<"image" | "text">("image");
1415const generateContent = async () => {
21setIsLoading(true);
22setError("");
23setImageUrl("");
24setGeneratedText("");
253839const data = await response.json();
40mode === "image" ? setImageUrl(data.imageUrl) : setGeneratedText(data.text);
41} catch (err) {
42setError(err.message);
48return (
49<div style={styles.container}>
50<h1>{mode === "image" ? "🖼️ AI Image Generator" : "📝 AI Text Generator"}</h1>
51<div style={styles.modeToggle}>
52<button
53onClick={() => setMode("image")}
54style={{
55...styles.modeButton,
56backgroundColor: mode === "image" ? "#4CAF50" : "#f0f0f0",
57color: mode === "image" ? "white" : "black",
58}}
59>
60Image
61</button>
62<button
76value={prompt}
77onChange={(e) => setPrompt(e.target.value)}
78placeholder={mode === "image"
79? "Describe the image you want to create"
80: "Enter a prompt for text generation"}
81style={styles.input}
86style={styles.button}
87>
88{isLoading ? "Generating..." : `Generate ${mode === "image" ? "Image" : "Text"}`}
89</button>
90</div>
96)}
9798{imageUrl && mode === "image" && (
99<div style={styles.imageContainer}>
100<img
101src={imageUrl}
102alt={prompt}
103style={styles.generatedImage}
104/>
105<p style={styles.imageDescription}>{prompt}</p>
106</div>
107)}
171marginBottom: "20px",
172},
173imageContainer: {
174marginTop: "20px",
175},
176generatedImage: {
177maxWidth: "100%",
178borderRadius: "10px",
189lineHeight: "1.6",
190},
191imageDescription: {
192fontStyle: "italic",
193color: "#666",
233const openai = new OpenAI();
234235if (mode === "image") {
236const response = await openai.images.generate({
237model: "dall-e-3",
238prompt: prompt,
241});
242243const imageUrl = response.data[0].url;
244return c.json({ imageUrl });
245} else {
246const response = await openai.chat.completions.create({
characterGuessermain.tsx14 matches
9const [swipeProgress, setSwipeProgress] = useState(0);
10const [gameStarted, setGameStarted] = useState(false);
11const [imageUrl, setImageUrl] = useState("");
12const swipeRef = useRef(null);
1315const urlParams = new URLSearchParams(window.location.search);
16const initialMessage = urlParams.get("message");
17const initialImageUrl = urlParams.get("imageUrl");
18if (initialMessage) {
19setMessage(decodeURIComponent(initialMessage));
20setGameStarted(true);
21}
22if (initialImageUrl) {
23setImageUrl(decodeURIComponent(initialImageUrl));
24}
25}, []);
38const data = await response.json();
39setMessage(data.message);
40setImageUrl(data.imageUrl);
41setGameStarted(true);
4243// Update URL with new conversation state and image URL
44urlParams.set("message", encodeURIComponent(data.message));
45urlParams.set("conversation", encodeURIComponent(JSON.stringify(data.conversation)));
46urlParams.set("imageUrl", encodeURIComponent(data.imageUrl));
47window.history.replaceState({}, "", `${window.location.pathname}?${urlParams}`);
48} catch (error) {
116>
117<div className="h-[500px] bg-gray-300 flex items-center justify-center">
118{imageUrl ? <img src={imageUrl} alt="Character hint" className="w-[1000px] h-full object-cover" /> : (
119<svg
120className="w-20 h-20 text-gray-400"
166setGameStarted(false);
167setMessage("Think of a new character, then swipe right to start!");
168setImageUrl("");
169window.history.replaceState({}, "", window.location.pathname);
170}}
244role: "system",
245content:
246"You are an AI that guesses the fictional or real character that the user is thinking of. Ask yes/no questions to gather information. The user will respond with 'yes' for yes and 'no' for no. Start by introducing the game and asking the first question. After each response, also provide a brief image description (without spaces) based on the current knowledge of the character.",
247},
248{
249role: "assistant",
250content:
251"Welcome to the Character Guesser game! I'll try to guess the character you're thinking of by asking yes/no questions. Let's begin! Is your character a real person (as opposed to fictional)?\n\nImage description: mysterious_silhouette_with_question_mark",
252},
253];
266267const aiMessage = completion.choices[0].message.content.trim();
268const [message, imageDescription] = aiMessage.split("\n\nImage description: ");
269const imageUrl = `https://maxm-imggenurl.web.val.run/${imageDescription}`;
270271conversation.push({ role: "assistant", content: aiMessage });
272273return new Response(JSON.stringify({ message, imageUrl, conversation }), {
274headers: { "Content-Type": "application/json" },
275});
cerebras_codermain.tsx1 match
1185<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1186<meta property="og:type" content="website">
1187<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1188
1189
MultiImageCompressormain.tsx43 matches
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45interface CompressedImage {
6file: File;
7preview: string;
10}
1112function ImageCompressor() {
13const [images, setImages] = React.useState<CompressedImage[]>([]);
14const [totalCompressed, setTotalCompressed] = React.useState(0);
15const canvasRef = React.useRef<HTMLCanvasElement>(null);
18React.useEffect(() => {
19return () => {
20images.forEach(image => {
21if (image.preview) {
22URL.revokeObjectURL(image.preview);
23}
24});
25};
26}, [images]);
2728const generatePreview = React.useCallback((file: File): Promise<string> => {
34
35// Verify the URL is valid
36const img = new Image();
37img.onload = () => {
38resolve(objectUrl);
64}, []);
6566const compressImage = React.useCallback(async (file: File): Promise<File> => {
67return new Promise((resolve, reject) => {
68const reader = new FileReader();
69reader.onload = (event) => {
70const img = new Image();
71img.onload = () => {
72const canvas = canvasRef.current || document.createElement('canvas');
102canvas.height = height;
103104// Draw resized image
105ctx.drawImage(img, 0, 0, width, height);
106107// Compress with reducing quality
123compressRecursively(quality - 0.1);
124} else {
125reject(new Error(`Cannot compress image under 300 kB`));
126}
127}, file.type, quality);
131};
132133img.onerror = () => reject(new Error('Image load failed'));
134img.src = event.target?.result as string;
135};
144if (!files) return;
145146const newImages: CompressedImage[] = await Promise.all(
147Array.from(files)
148.filter(file => file.type.startsWith('image/'))
149.map(async (file) => {
150try {
170);
171172setImages(prev => [...prev, ...newImages]);
173174// Compress images
175newImages.forEach(async (image) => {
176try {
177const compressedFile = await compressImage(image.file);
178
179// Update total compressed count
182setTotalCompressed(currentTotal + 1);
183184setImages(prev => prev.map(img =>
185img.file === image.file
186? { ...img, compressedFile }
187: img
188));
189} catch (error) {
190setImages(prev => prev.map(img =>
191img.file === image.file
192? {
193...img,
202};
203204const handleDownload = (image: CompressedImage) => {
205if (!image.compressedFile) return;
206207const url = URL.createObjectURL(image.compressedFile);
208const link = document.createElement('a');
209link.href = url;
210link.download = `compressed_${image.file.name}`;
211document.body.appendChild(link);
212link.click();
230/>
231232<h1 style={{ color: '#4CAF50' }}>🖼️ Image Compressor</h1>
233
234<div style={{
246type="file"
247multiple
248accept="image/*"
249onChange={handleFileUpload}
250style={{
263gap: '10px'
264}}>
265{images.map((image, index) => (
266<div
267key={index}
273}}
274>
275{image.preview && (
276<img
277src={image.preview}
278alt="Original"
279onError={(e) => {
280console.error('Image load error:', {
281src: image.preview,
282error: e
283});
292)}
293294<p>Original: {image.file.name}</p>
295<p>Size: {(image.file.size / 1024).toFixed(2)} kB</p>
296297{image.compressedFile && (
298<>
299<p>Compressed: {(image.compressedFile.size / 1024).toFixed(2)} kB</p>
300<button
301onClick={() => handleDownload(image)}
302style={{
303backgroundColor: '#4CAF50',
314)}
315316{image.error && (
317<p style={{ color: '#ff6b6b' }}>{image.error}</p>
318)}
319</div>
328<html>
329<head>
330<title>Image Compressor</title>
331<meta name="viewport" content="width=device-width, initial-scale=1">
332<style>
cerebras_codermain.tsx2 matches
5import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
6import { STARTER_PROMPTS } from "https://esm.town/v/stevekrouse/cerebras_coder_prompts";
7const [uploadedImage, setUploadedImage] = useState<string | null>(null);
8const fileInputRef = React.useRef<HTMLInputElement>(null);
91187<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1188<meta property="og:type" content="website">
1189<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1190
1191
1185<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1186<meta property="og:type" content="website">
1187<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1188
1189
cerebras_codermain.tsx1 match
1111<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1112<meta property="og:type" content="website">
1113<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1114
1115
blobCommentDemomain.tsx10 matches
45// });
4647// New route to serve images from blob storage
48app.get("/image/:id.png", async (c) => {
49console.log(c.req)
50const id = c.req.param("id");
51console.log({ id })
52const imageBlob = await blob.get(id);
53const known = await blob.get("notionDeleteTest")
54console.log({ known })
55
56if (!imageBlob) {
57return c.text("Image not found", 404);
58}
5960return new Response(imageBlob.body, {
61headers: {
62"Content-Type": "image/png"
63}
64});
84return c.body(known.body, {
85headers: {
86'Content-Type': 'image/png'
87}
88})
110return c.body(known.body, {
111headers: {
112'Content-Type': 'image/png'
113}
114})
128return c.body(known.body, {
129headers: {
130'Content-Type': 'image/png'
131}
132})
newFavoriteSongBotmain.tsx13 matches
21href: track.track.href,
22url: track.track.external_urls.spotify,
23img_url: track.track.album.images[0].url,
24}));
2545});
4647// Helper function to upload an image and get a blob reference
48async function uploadImage(agent: AtpAgent, imageUrl: string) {
49try {
50// Fetch the image
51const response = await fetch(imageUrl);
52if (!response.ok) {
53console.error(`Failed to fetch image: ${imageUrl}`);
54return null;
55}
5657// Convert image to blob
58const imageBlob = await response.blob();
5960// Upload blob to Bluesky
61const uploadedBlob = await agent.uploadBlob(imageBlob, {
62encoding: response.headers.get("content-type") || "image/jpeg",
63});
6465return uploadedBlob.data.blob;
66} catch (error) {
67console.error("Error uploading image:", error);
68return null;
69}
94for (const song of newSongs) {
95try {
96// Upload image and get blob reference
97const thumbBlob = song.img_url ? await uploadImage(agent, song.img_url) : null;
9899const postText = `My new favorite song is "${song.track_name}" ${song.url}`;
seamlessAquamarineAntlionmain.tsx2 matches
152</Col>
153<Col md={6}>
154<img src="https://maxm-imggenurl.web.val.run/futuristic-gaming-setup-with-rgb-lights" alt="Setup Gaming" className="img-fluid rounded shadow gaming-image" loading="lazy" />
155</Col>
156</Row>
515}
516517.gaming-image {
518border: 2px solid #00ffff;
519box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);