51 }
52
53 const { messages, project, branchId, anthropicApiKey, selectedFiles, images } = await c.req.json();
54 console.log("Original messages:", JSON.stringify(messages, null, 2));
55 console.log("Images received:", JSON.stringify(images, null, 2));
56
57 // Check if API key is available
58 if (!anthropicApiKey) {
59 return Response.json({
60 error: "Anthropic API key is required. Please log out and add your Anthropic API key to use this app.",
61 }, { status: 400 });
62 }
63
64 let apiKey;
65 if (!anthropicApiKey) {
66 return Response.json({
67 error: "Anthropic API key is required. Please log out and add your Anthropic API key to use this app.",
68 }, { status: 400 });
69 } else if (anthropicApiKey === Deno.env.get("PASSWORD")) {
70 apiKey = Deno.env.get("PROVIDED_ANTHROPIC_API_KEY");
71 } else {
72 apiKey = anthropicApiKey;
73 }
74
75 const anthropic = createAnthropic({
76 apiKey,
77 });
78
227 ];
228
229 // Capitalize first letter
230 if (num >= 0 && num <= 10) {
231 const word = words[num];
43
44 try {
45 const response = await fetch("/api/create-branch", {
46 method: "POST",
47 headers: {
8import { ChatMessages } from "./ChatMessages.tsx";
9import { ChatInput } from "./ChatInput.tsx";
10import { ApiKeyWarning } from "./ApiKeyWarning.tsx";
11
12export function Chat({
13 project,
14 bearerToken,
15 anthropicApiKey,
16 setProject,
17}: {
18 project: any;
19 bearerToken: string;
20 anthropicApiKey: string;
21 setProject: (project: any) => void;
22}) {
54 project,
55 branchId,
56 anthropicApiKey,
57 bearerToken,
58 selectedFiles,
81
82 <div className="p-6 flex flex-col h-full w-full">
83 <ApiKeyWarning show={!anthropicApiKey} />
84
85 <ChatMessages
37 setIsLoadingBranches(true);
38 try {
39 const response = await fetch(`/api/project-branches?projectId=${projectId}`, {
40 headers: {
41 "Authorization": `Bearer ${bearerToken}`,
107 const fetchBranches = async () => {
108 try {
109 const response = await fetch(`/api/project-branches?projectId=${projectId}`, {
110 headers: {
111 "Authorization": `Bearer ${bearerToken}`,
16export function App() {
17 const [bearerToken, setBearerToken] = useLocalStorage("bearer", "");
18 const [anthropicApiKey, setAnthropicApiKey] = useLocalStorage("anthropic_api_key", "");
19 const [projectJSON, setProjectJSON] = useLocalStorage("project", "");
20 const [project, setProject_] = useState(safeParse(projectJSON));
27 function handleLogout() {
28 setBearerToken("");
29 // Keep the anthropic API key in case the user wants to reuse it
30 }
31
46 <Chat
47 bearerToken={bearerToken}
48 anthropicApiKey={anthropicApiKey}
49 project={project}
50 setProject={setProject}
3 { bearerToken, projectId, branchId }: { bearerToken: string; projectId: string; branchId?: string },
4) {
5 const url = new URL("/api/project-files", window.location.origin);
6 url.searchParams.append("projectId", projectId);
7 if (branchId) {
2import React from "https://esm.sh/react@18.2.0?dev";
3
4interface ApiKeyWarningProps {
5 show: boolean;
6}
7
8export function ApiKeyWarning({ show }: ApiKeyWarningProps) {
9 if (!show) return null;
10
11 return (
12 <div className="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 mb-4 rounded">
13 <p className="font-bold">Anthropic API Key Missing</p>
14 <p>Please log out and add your Anthropic API key to use this app.</p>
15 </div>
16 );
212 <meta name="viewport" content="width=device-width, initial-scale=1.0">
213 <title>TR-808 Style Drum Machine</title>
214 <link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">
215 <style>${css}</style>
216 </head>
1import RSS from "npm:rss";
2import * as feedbin from "./feedbinAPI";
3
4export default async function starFeed() {