95}
9697async function createApiInstance(config: Config) {
98const api = axios.create({
99baseURL: config.baseUrl,
100headers: {
106},
107});
108return api;
109}
110111async function authenticate(api: any, config: Config): Promise<void> {
112const loginResponse = await api.post("/api/login", {
113email: config.email,
114password: config.password,
119}
120121const saveAuthResponse = await api.post("/api/auth/saveAuth", {
122authorizationToken: loginResponse.data.authorizationToken,
123});
139}
140141api.defaults.headers["X-Xsrf-Token"] = xsrfToken;
142api.defaults.headers["Cookie"] = [
143`accessToken=${accessToken}`,
144`xsrfToken=${xsrfToken}`,
149}
150151async function getActiveApps(api: any) {
152const response = await api.get("/api/pages", {
153params: {
154mobileAppsOnly: false,
158const apps = response.data;
159if (!apps || !apps.pages || !apps.folders) {
160throw new Error("Invalid response format from apps API");
161}
162176}
177178async function downloadApp(api: any, app: any, zip: JSZip) {
179try {
180console.log(`Downloading app: ${app.name}`);
181if (!app.uuid) { throw new Error("App UUID is missing"); }
182183const response = await api.post(`/api/pages/uuids/${app.uuid}/export`);
184const exportData = response.data;
185201}
202203async function getWorkflows(api: any) {
204const response = await api.get("/api/workflow/");
205const workflows = response.data;
206207if (!workflows || !workflows.workflowsMetadata) {
208throw new Error("Invalid response format from workflows API");
209}
210212}
213214async function downloadWorkflow(api: any, workflow: any, zip: JSZip) {
215try {
216if (!workflow.id || !workflow.name) {
220221console.log(`Downloading workflow: ${workflow.name}`);
222const response = await api.post("/api/workflow/export", {
223workflowId: workflow.id,
224branchName: "",
329const zip = new JSZip();
330331// Create and authenticate API instance
332const api = await createApiInstance(config);
333await authenticate(api, config);
334335const [activeApps, workflows] = await Promise.all([
336getActiveApps(api),
337getWorkflows(api),
338]);
339343// Download all apps and workflows in parallel
344await Promise.all([
345...activeApps.map(app => downloadApp(api, app, zip)),
346...workflows.map(workflow => downloadWorkflow(api, workflow, zip)),
347]);
348
8
9// 3. 由於 Val Town 不支持直接訪問環境變量,
10// 我們將修改方法以要求傳遞 API 密鑰
11const args = extend({
12callbacks: options?.verbose !== false ? [] : undefined
specialBlueGophermain.tsx1 match
34const replicate = new Replicate({
5auth: Deno.env.get("REPLICATE_API_KEY"),
6});
7
sophisticatedOliveFinchREADME.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
sophisticatedOliveFinchmain.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
MILLENCHATmain.tsx12 matches
2// {
3// "name": "AI Chat Assistant",
4// "description": "A chat assistant using OpenAI's API",
5// "permissions": ["env"]
6// }
8990async function callOpenAI(userMessage: string): Promise<string> {
91const apiKey = Deno.env.get("OPENAI_API_KEY");
92
93if (!apiKey) {
94throw new Error("OpenAI API key is not configured. Please set the OPENAI_API_KEY environment variable.");
95}
9697try {
98const response = await fetch('https://api.openai.com/v1/chat/completions', {
99method: 'POST',
100headers: {
101'Authorization': `Bearer ${apiKey}`,
102'Content-Type': 'application/json'
103},
117if (!response.ok) {
118const errorBody = await response.text();
119throw new Error(`OpenAI API error: ${response.status} - ${errorBody}`);
120}
121124"I'm not sure how to respond to that.";
125} catch (error) {
126console.error("OpenAI API Call Error:", error);
127throw error;
128}
279280export default async function server(request: Request): Promise<Response> {
281// Check if OpenAI API key is configured
282const apiKey = Deno.env.get("OPENAI_API_KEY");
283
284if (!apiKey) {
285return new Response(`
286<!DOCTYPE html>
313<div class="error-container">
314<h1>🚨 Configuration Error</h1>
315<p>OpenAI API key is not configured. Please set the OPENAI_API_KEY environment variable.</p>
316<p>Contact the val owner to resolve this issue.</p>
317</div>
STARTER_PROMPTSmain.tsx1 match
12},
13{
14prompt: "weather dashboard for nyc using open-meteo API for NYC with icons",
15title: "Weather App",
16code:
intimatePinkMoleREADME.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
intimatePinkMolemain.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
luminousAquamarineChickadeeREADME.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