survivalRPGAdventuremain.tsx1 match
164injury_risk: state.injury_risk + 60,
165}),
166narrative: "You wade into the freezing, rapid river. The fishing is dangerous, but potentially rewarding.",
167},
168{
zanyCyanHookwormmain.tsx33 matches
1011const WikiSearch = () => {
12const [apiKey, setApiKey] = useState("");
13const [model, setModel] = useState("claude-3-opus-20240229");
14const [query, setQuery] = useState("");
3031useEffect(() => {
32const savedApiKey = localStorage.getItem("anthropic_api_key");
33const savedModel = localStorage.getItem("anthropic_model");
3435if (savedApiKey) {
36setApiKey(savedApiKey);
37setStatus({ message: "API key loaded", type: "success" });
38}
39if (savedModel) {
53};
5455const saveApiSettings = (e) => {
56e.preventDefault();
57if (apiKey.trim()) {
58localStorage.setItem("anthropic_api_key", apiKey);
59localStorage.setItem("anthropic_model", model);
60setStatus({ message: "API settings saved successfully", type: "success" });
61setIsConfigOpen(false);
62} else {
63setStatus({ message: "Please enter an API key", type: "error" });
64}
65};
6667const callAnthropicAPI = async (prompt) => {
68const response = await fetch("https://api.anthropic.com/v1/messages", {
69method: "POST",
70headers: {
71"Content-Type": "application/json",
72"x-api-key": apiKey,
73"anthropic-version": "2023-06-01",
74},
82if (!response.ok) {
83const error = await response.text();
84throw new Error(`API Error: ${error}`);
85}
869091const searchWikipedia = async (searchQuery, language = "en") => {
92const apiUrl = `https://${language}.wikipedia.org/w/api.php`;
93const params = new URLSearchParams({
94action: "query",
101});
102103const response = await fetch(`${apiUrl}?${params}`);
104const data = await response.json();
105const pages = data.query.pages;
111e.preventDefault();
112113if (!apiKey) {
114setStatus({ message: "Please configure your API key first", type: "error" });
115setIsConfigOpen(true);
116return;
124const language = detectLanguage(query);
125126const suggestion = await callAnthropicAPI(
127`Based on this question: "${query}", tell me exactly what Wikipedia article I should look up. Respond with just the article title, nothing else.`,
128);
132setResults(prev => ({ ...prev, wikiExtract }));
133134const finalAnswer = await callAnthropicAPI(
135`Question: "${query}"
136Wikipedia excerpt: "${wikiExtract}"
153{/* Header */}
154<div className="bg-gradient-to-r from-blue-600 to-blue-700 p-6 text-white">
155<h1 className="text-2xl md:text-3xl font-bold">Wikipedia Search with Anthropic API</h1>
156<div className="mt-2 flex items-center gap-2 text-sm text-blue-100">
157<span className="text-base">{Icons.Settings}</span>
158<span>Using: {modelNames[model]}</span>
159{!apiKey && (
160<span className="bg-red-500/20 text-white px-2 py-0.5 rounded-full text-xs">(API key required)</span>
161)}
162</div>
165{/* Main content */}
166<div className="p-6 space-y-6">
167{/* API Configuration */}
168<div className="space-y-2">
169<button
174<span className="font-medium flex items-center gap-2">
175<span className="text-blue-600">{Icons.Settings}</span>
176API Configuration
177</span>
178<span className="text-gray-500">{isConfigOpen ? Icons.ChevronUp : Icons.ChevronDown}</span>
181{isConfigOpen && (
182<div className="p-4 bg-gray-50 rounded-lg border border-gray-200">
183<form onSubmit={saveApiSettings} className="space-y-4">
184<div>
185<label htmlFor="apiKey" className="block text-sm font-medium text-gray-700 mb-1">
186Anthropic API Key:
187</label>
188<input
189type="password"
190id="apiKey"
191value={apiKey}
192onChange={(e) => setApiKey(e.target.value)}
193className="w-full p-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
194placeholder="Enter your Anthropic API key"
195/>
196</div>
218className="w-full bg-blue-600 text-white px-4 py-2.5 rounded-lg hover:bg-blue-700 transition-colors"
219>
220Save API Settings
221</button>
222</form>
unassumingAzureLungfishREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
1011# Todos
unassumingAzureLungfishmain.tsx5 matches
212} catch (error) {
213Toastify({
214text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215position: "center",
216duration: 3000,
1024};
1025} else {
1026const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027const completion = await client.chat.completions.create({
1028messages: [
1149<meta name="viewport" content="width=device-width, initial-scale=1.0">
1150<title>CerebrasCoder</title>
1151<link rel="preconnect" href="https://fonts.googleapis.com" />
1152<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153<link
1154href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155rel="stylesheet"
1156/>
1165<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."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
12},
13{
14prompt: "weather dashboard for nyc using open-meteo API for NYC with icons",
15title: "Weather App",
16code:
fascinatingBrownKrillREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
1011# Todos
fascinatingBrownKrillmain.tsx5 matches
212} catch (error) {
213Toastify({
214text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215position: "center",
216duration: 3000,
1024};
1025} else {
1026const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027const completion = await client.chat.completions.create({
1028messages: [
1149<meta name="viewport" content="width=device-width, initial-scale=1.0">
1150<title>CerebrasCoder</title>
1151<link rel="preconnect" href="https://fonts.googleapis.com" />
1152<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153<link
1154href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155rel="stylesheet"
1156/>
1165<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."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
blob_adminmain.tsx25 matches
73const menuRef = useRef(null);
74const isPublic = blob.key.startsWith("__public/");
75const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
7677useEffect(() => {
237setLoading(true);
238try {
239const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240const data = await response.json();
241setBlobs(data);
264setBlobContentLoading(true);
265try {
266const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267const content = await response.text();
268setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
278const handleSave = async () => {
279try {
280await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281method: "PUT",
282body: editContent,
290const handleDelete = async (key) => {
291try {
292await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293setBlobs(blobs.filter(b => b.key !== key));
294if (selectedBlob && selectedBlob.key === key) {
307const key = `${searchPrefix}${file.name}`;
308formData.append("key", encodeKey(key));
309await fetch("/api/blob", { method: "POST", body: formData });
310const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311setBlobs([newBlob, ...blobs]);
329try {
330const fullKey = `${searchPrefix}${key}`;
331await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332method: "PUT",
333body: "",
344const handleDownload = async (key) => {
345try {
346const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347const blob = await response.blob();
348const url = window.URL.createObjectURL(blob);
363if (newKey && newKey !== oldKey) {
364try {
365const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366const content = await response.blob();
367await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368method: "PUT",
369body: content,
370});
371await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373if (selectedBlob && selectedBlob.key === oldKey) {
383const newKey = `__public/${key}`;
384try {
385const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386const content = await response.blob();
387await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388method: "PUT",
389body: content,
390});
391await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393if (selectedBlob && selectedBlob.key === key) {
402const newKey = key.slice(9); // Remove "__public/" prefix
403try {
404const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405const content = await response.blob();
406await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407method: "PUT",
408body: content,
409});
410await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412if (selectedBlob && selectedBlob.key === key) {
557onClick={() =>
558copyToClipboard(
559`${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
560)}
561className="text-blue-400 hover:text-blue-300 text-sm"
580>
581<img
582src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
583alt="Blob content"
584className="max-w-full h-auto"
660661// Public route without authentication
662app.get("/api/public/:id", async (c) => {
663const key = `__public/${c.req.param("id")}`;
664const { blob } = await import("https://esm.town/v/std/blob");
766};
767768app.get("/api/blobs", checkAuth, async (c) => {
769const prefix = c.req.query("prefix") || "";
770const limit = parseInt(c.req.query("limit") || "20", 10);
775});
776777app.get("/api/blob", checkAuth, async (c) => {
778const key = c.req.query("key");
779if (!key) return c.text("Missing key parameter", 400);
783});
784785app.put("/api/blob", checkAuth, async (c) => {
786const key = c.req.query("key");
787if (!key) return c.text("Missing key parameter", 400);
792});
793794app.delete("/api/blob", checkAuth, async (c) => {
795const key = c.req.query("key");
796if (!key) return c.text("Missing key parameter", 400);
800});
801802app.post("/api/blob", checkAuth, async (c) => {
803const { file, key } = await c.req.parseBody();
804if (!file || !key) return c.text("Missing file or key", 400);
compassionateBlackCatfishmain.tsx14 matches
23export default async function(req: Request): Promise<Response> {
4const LEPTON_API_TOKEN = Deno.env.get('LEPTON_API_TOKEN') || '';
56return new Response(
33<div id="connection-status" class="absolute top-0 left-0 right-0 text-center z-50 hidden">
34<div class="bg-red-900 text-red-300 p-2 text-sm">
35⚠️ NETWORK DISRUPTION: API CONNECTION LOST
36</div>
37</div>
75<script>
76(()=>{
77const API_URL = "/api/chat";
78const messages = [];
79const messagesContainer = document.querySelector(".messages");
164165try {
166const response = await fetch(API_URL, {
167method: "POST",
168headers: {
229
230try {
231const response = await fetch(API_URL, {
232method: "POST",
233headers: {
301}
302303// Add a separate API route handler for chat
304export async function handler(req: Request) {
305if (req.method !== 'POST') {
308309try {
310const LEPTON_API_TOKEN = Deno.env.get('LEPTON_API_TOKEN') || '';
311const openai = new OpenAI({
312apiKey: LEPTON_API_TOKEN,
313baseURL: 'https://llama3-3-70b.lepton.run/api/v1/',
314dangerouslyAllowBrowser: true
315});
317const { messages, config = {} } = await req.json();
318319// Robust API configuration with sensible defaults
320const apiConfig = {
321model: "llama3.3-70b",
322messages: messages,
329};
330331const response = await openai.chat.completions.create(apiConfig);
332333return new Response(JSON.stringify(response), {
334headers: {
335'Content-Type': 'application/json',
336'X-AI-Model': apiConfig.model,
337'X-Token-Usage': 'proxied'
338}
339});
340} catch (error) {
341console.error('API Error:', error);
342
343// Detailed error response for debugging
stellarCrimsonPandaREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
1011# Todos