2 const url = new URL(req.url);
3
4 // Proxy endpoint to handle API requests
5 if (url.pathname === "/api/proxy") {
6 try {
7 const body = await req.json();
8 const apiResponse = await fetch("http://57.132.138.13:1865/message", {
9 method: "POST",
10 headers: {
14 });
15
16 if (!apiResponse.ok) {
17 throw new Error(`API responded with status: ${apiResponse.status}`);
18 }
19
20 const data = await apiResponse.json();
21 return new Response(JSON.stringify(data), {
22 headers: {
35
36 // Health check proxy endpoint
37 if (url.pathname === "/api/health") {
38 try {
39 const apiResponse = await fetch("http://57.132.138.13:1865/");
40 return new Response(null, {
41 status: apiResponse.ok ? 200 : 500
42 });
43 } catch (error) {
108 <div id="connection-status" class="text-center p-2 mb-4 hidden">
109 <span class="bg-yellow-100 bg-opacity-90 text-yellow-800 px-4 py-2 rounded-full text-sm shadow-lg">
110 ⚠️ Cannot connect to Cheshire Cat API. Please try again later.
111 </span>
112 </div>
246 }
247
248 // Test API connection through proxy
249 fetch("/api/health")
250 .then(response => {
251 if (!response.ok) throw new Error();
290
291 try {
292 const response = await fetch("/api/proxy", {
293 method: "POST",
294 headers: {
16 <meta name="viewport" content="width=device-width, initial-scale=1.0">
17 <title>${blogTitle}</title>
18 <link rel="preconnect" href="https://fonts.googleapis.com">
19 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
20 <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
21 <style>
22 @view-transition { navigation: auto; }
1/* Open in Val Town: https://www.val.town/v/cephalization/PhoenixProxy */
2const PHOENIX_API_KEY_NAME = "authorization";
3const HOSTED_PHOENIX_BASE_URL = "https://llamatrace.com";
4// const HOSTED_PHOENIX_BASE_URL = "https://app.phoenix.arize.com";
20 // });
21 // }
22 // Check that your valtown API key is sent in the 'x-authorization' header
23 // Delete this line if you don't mind other parties hitting this endpoint
24 // if (req.headers.get("x-authorization") !== Deno.env.get("valtown")) {
32 headers.set("Host", Url.hostname);
33 headers.set("Origin", Url.origin);
34 headers.set(PHOENIX_API_KEY_NAME, req.headers.get(PHOENIX_API_KEY_NAME) ?? "");
35 const init: RequestInit = {
36 method: req.method,
3THIS IS NO LONGER NECESSARY
4
5This Val will proxy anthropic HTTP requests from some frontend client, like langchain, so that you can utilize anthropic apis from the browser.
6
7Convert it to an HTTP val in order to use it (you may want to setup an ENV var / header to protect the endpoint with a secret key)
43 <script src="https://cdn.tailwindcss.com" > </script>
44 <script src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.6.0/processing.min.js"></script>
45 <link rel="preconnect" href="https://fonts.googleapis.com">
46 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
47 <link href="https://fonts.googleapis.com/css2?family=Azeret+Mono:ital,wght@0,100..900;1,100..900&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap" rel="stylesheet">
48 <style type="text/tailwindcss">
49 @tailwind base;
17 },
18 {
19 personality1: "a venture capitalist",
20 personality2: "an architect",
21 topic:
14
15 // Fetch search results
16 const search = await fetch("https://api.anicrush.to/shared/v2/movie/list?keyword=One Piece&limit=10&page=1", {
17 headers,
18 });
22
23 // Fetch server data
24 const serverData = await fetch(`https://api.anicrush.to/shared/v2/episode/servers?_movieId=${id}&ep=1`, {
25 headers,
26 });
30 // Fetch server link
31 const serverLink = await fetch(
32 `https://api.anicrush.to/shared/v2/episode/sources?_movieId=${id}&ep=1&sv=${serverId}&sc=sub`,
33 { headers },
34 );
20
21 try {
22 // First API call - Get search results
23 const searchResult = await fetch("/api/search", {
24 method: "POST",
25 headers: { "Content-Type": "application/json" },
30 setSources(searchData.sources);
31
32 // Second API call - Get summary
33 setSummaryLoading(true);
34 const summaryResult = await fetch("/api/summarize", {
35 method: "POST",
36 headers: { "Content-Type": "application/json" },
121 const url = new URL(req.url);
122
123 if (url.pathname === "/api/search") {
124 const { query } = await req.json();
125
126 // Search using SerpApi
127 const searchResponse = await fetch(
128 `https://serpapi.com/search.json?q=${encodeURIComponent(query)}&api_key=${Deno.env.get("SERP_API_KEY")}`,
129 );
130
144 }
145
146 if (url.pathname === "/api/summarize") {
147 const { query, searchData } = await req.json();
148 const sources = searchData.sources;
6
71. 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`
10
11Migrated from folder: Archive/cerebras_debater
7// ============================================================================
8
9// Demo mode - set to true to show mock data instead of making API requests
10const DEMO_MODE = true;
11
119 useEffect(() => {
120 Promise.all([
121 fetch("/api/prs").then(async (res) => {
122 if (!res.ok) {
123 const error = await res.json();
126 return res.json();
127 }),
128 fetch("/api/issues").then(async (res) => {
129 if (!res.ok) {
130 const error = await res.json();
138 })
139 .catch((err) => {
140 setErrors({ api: err.message });
141 })
142 .finally(() => {
146
147 if (loading) return <div>Loading...</div>;
148 if (errors.api) return <ErrorMessage message={errors.api} />;
149
150 return (
183 // Return mock data in demo mode
184 if (DEMO_MODE) {
185 if (url.pathname === "/api/prs") {
186 return new Response(JSON.stringify(MOCK_DATA.prs), { headers: JSON_HEADERS });
187 }
188 if (url.pathname === "/api/issues") {
189 return new Response(JSON.stringify(MOCK_DATA.issues), { headers: JSON_HEADERS });
190 }
191 }
192
193 if (url.pathname === "/api/prs") {
194 const githubToken = Deno.env.get(GITHUB.TOKEN_ENV_VAR);
195 if (!githubToken) {
200
201 const response = await fetch(
202 `https://api.github.com/search/issues?q=repo:${GITHUB.REPOSITORY}+author:${GITHUB.USERNAME}+created:>${timeAgo}+type:pr`,
203 {
204 headers: {
225 }
226
227 if (url.pathname === "/api/issues") {
228 const linearToken = Deno.env.get(LINEAR.TOKEN_ENV_VAR);
229 if (!linearToken) {
252 `;
253
254 const response = await fetch("https://api.linear.app/graphql", {
255 method: "POST",
256 headers: {