218 setResults(null);
219 try {
220 const response = await fetch("/search", {
221 method: "POST",
222 body: JSON.stringify({ query }),
48
49 try {
50 const response = await fetch('/search', {
51 method: 'POST',
52 headers: {
17
18 try {
19 res = await fetch(url);
20 end = performance.now();
21 status = res.status;
30 } catch (e) {
31 end = performance.now();
32 reason = `couldn't fetch: ${e}`;
33 ok = false;
34 }
5 let ok = true;
6 try {
7 const res = await fetch(url);
8 if (res.status === 200) {
9 console.log(`Website up (${url})`);
5 let ok = true;
6 try {
7 const res = await fetch(url);
8 if (res.status === 200) {
9 console.log(`Website up (${url})`);
15 const start = performance.now();
16 try {
17 res = await fetch(url);
18 end = performance.now();
19 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 }
41 };
42
43 const fetchWeather = async () => {
44 if (!location) return;
45
50 try {
51 // Geocoding to get lat/lon
52 const geoResponse = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(location)}&count=1&language=en&format=json`);
53 const geoData = await geoResponse.json();
54
60
61 // Current weather and 7-day forecast
62 const weatherResponse = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m&daily=weathercode,temperature_2m_max,temperature_2m_min&timezone=auto&forecast_days=7`);
63 const weatherData = await weatherResponse.json();
64
89 const handleKeyPress = (e) => {
90 if (e.key === 'Enter') {
91 fetchWeather();
92 }
93 };
109 };
110
111 const response = await fetch('https://jsonbin.org/create', {
112 method: 'POST',
113 headers: {
156 className="location-input"
157 />
158 <button onClick={fetchWeather} className="search-button">
159 Search
160 </button>
161 </div>
162
163 {loading && <div className="loading">Fetching weather...</div>}
164
165 {error && <div className="error">{error}</div>}
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=45";
2import { type ModelCapabilities } from "./types";
3
4const url = "https://raw.githubusercontent.com/BerriAI/litellm/refs/heads/main/model_prices_and_context_window.json";
5const res: { [key: string]: ModelCapabilities } = await fetchJSON(url);
6const pricing = Object.fromEntries(
7 Object.entries(res).filter(([_, obj]) =>
1import { fetchOpenAiUsageData } from "https://esm.town/v/nbbaier/fetchOpenAiUsageData";
2import { DateTime } from "npm:luxon";
3import { TextData } from "./types";
8const month = date.setZone(timeZone).toFormat("LLLL").toLowerCase();
9
10const { data }: { data: TextData[] } = await fetchOpenAiUsageData(today);
11
12function removeNullValues<T extends Record<string, any>>(obj: T): Partial<T> {
26
27 try {
28 const response = await fetch("/chat", {
29 method: "POST",
30 headers: { "Content-Type": "application/json" },