1Migrated from folder: capital/capitalMultipliers
4export function App() {
5 const [projectUrl, setProjectUrl] = useState("");
6 const [apiToken, setApiToken] = useState("");
7 const [loading, setLoading] = useState(false);
8 const [message, setMessage] = useState("");
21 }
22
23 if (!apiToken.trim()) {
24 throw new Error("API Token is required");
25 }
26
28 method: "POST",
29 headers: {
30 "Authorization": `Bearer ${apiToken}`,
31 "Content-Type": "application/json",
32 },
63 value={projectUrl}
64 onChange={(e) => setProjectUrl(e.target.value)}
65 placeholder="https://api.val.town/v1/projects/..."
66 className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
67 />
69
70 <div>
71 <label htmlFor="apiToken" className="block text-sm font-medium text-gray-700 mb-1">
72 Val Town API Token (project read + write permissions)
73 </label>
74 <input
75 id="apiToken"
76 type="password"
77 value={apiToken}
78 onChange={(e) => setApiToken(e.target.value)}
79 placeholder="Enter your API token"
80 className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
81 />
3import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
4
5const SOCIAL_DATA_API_KEY = Deno.env.get("SOCIAL_DATA_API_KEY") || "";
6
7// Initialize SQLite database
135}
136
137// Core API functions
138async function searchTweets(query: string, startTime: Date): Promise<Tweet[]> {
139 try {
140 console.log(`Making request to socialdata API with query: ${query}`);
141 const url = `https://api.socialdata.tools/twitter/search?query=${encodeURIComponent(query)}&type=Latest`;
142 console.log(`URL: ${url}`);
143
144 const response = await fetch(url, {
145 headers: {
146 "Authorization": `Bearer ${SOCIAL_DATA_API_KEY}`,
147 "Accept": "application/json",
148 },
203 // For user tweets, we can use the search endpoint with from: operator
204 const query = `from:${username}`;
205 const url = `https://api.socialdata.tools/twitter/search?query=${encodeURIComponent(query)}&type=Latest`;
206 console.log(`Making request to socialdata API with query: ${query}`, url);
207
208 const response = await fetch(url, {
209 headers: {
210 "Authorization": `Bearer ${SOCIAL_DATA_API_KEY}`,
211 "Accept": "application/json",
212 },
16
17function CatVisionSimulator() {
18 const [imageUrl, setImageUrl] = useState("/api/placeholder/600/400");
19 const [catVisionEnabled, setCatVisionEnabled] = useState(false);
20 const [brightness, setBrightness] = useState(100);
121 // Reset to default image
122 const resetToDefault = () => {
123 setImageUrl("/api/placeholder/600/400");
124 setImageSource("default");
125 if (cameraActive) {
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>Casino Night in Macao</title>
8 <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Poppins:wght@500&display=swap" rel="stylesheet">
9 <style>
10 body {
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error
152 } else if (model === "gemini") {
153 const { GoogleGenerativeAI } = await import("https://esm.sh/@google/generative-ai");
154 const apiKey = Deno.env.get("GEMINI_API_KEY");
155
156 if (!apiKey) {
157 return Response.json({
158 message: "Gemini API key is not configured.",
159 }, { status: 500 });
160 }
161
162 const genAI = new GoogleGenerativeAI(apiKey);
163 const generationConfig = {
164 maxOutputTokens: 300,
177 });
178 } else if (model === "mistral") {
179 const apiKey = Deno.env.get("MISTRAL_API_KEY");
180
181 if (!apiKey) {
182 return Response.json({
183 message: "Mistral API key is not configured.",
184 }, { status: 500 });
185 }
186
187 const response = await fetch("https://api.mistral.ai/v1/chat/completions", {
188 method: "POST",
189 headers: {
190 "Content-Type": "application/json",
191 "Authorization": `Bearer ${apiKey}`,
192 },
193 body: JSON.stringify({
204 });
205 } else if (model === "ollama") {
206 // Ollama local API call for Phi4 model
207 const ollamaMessages = messages.map(msg => ({
208 role: msg.role === "system" ? "system" : msg.role,
210 }));
211
212 const response = await fetch("http://127.0.0.1:11434/api/chat", {
213 method: "POST",
214 headers: {
16 const { prompt } = await c.req.json();
17
18 const replicate = new Replicate({ auth: Deno.env.get("REPLICATE_API_TOKEN") });
19 const model = "black-forest-labs/flux-schnell";
20 const output = await replicate.run(model, {
21To run it:
22
231. Get your free Steel API key at https://app.steel.dev/settings/api-keys
242. Add it to your [Val Town Environment Variables](https://www.val.town/settings/environment-variables) as `STEEL_API_KEY`
253. Click `Fork` on this val
264. Click `Run` on this val
72
73- [Steel Documentation](https://docs.steel.dev)
74- [API Reference](https://docs.steel.dev/api-reference)
75- [Discord Community](https://discord.gg/gPpvhNvc5R)
3
4const replicate = new Replicate({
5 auth: Deno.env.get("REPLICATE_API_KEY"),
6});
7