Search
Code3,144
</ul> <p> The application proxies requests to the Anthropic API and Val Town API, allowing Claude to view and edit your project files directly. </p> }, body: JSON.stringify({ model: "anthropic/claude-3.5-sonnet", messages: [ {import { Hono } from "https://esm.sh/hono@3.11.7";import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";import { Anthropic } from "https://esm.sh/@anthropic-ai/sdk@0.24.3";const app = new Hono();async function analyzeInfluencer(data: OctolensPayload['data']) { const anthropicApiKey = Deno.env.get('ANTHROPIC_API_KEY'); if (!anthropicApiKey) return { isInfluencer: false, analysis: 'No API key' }; const anthropic = new Anthropic({ apiKey: anthropicApiKey }); const prompt = `Research this person and determine if they're a tech mini-influencer (1K-100K followers, active in tech/startup space):}`; const message = await anthropic.messages.create({ model: "claude-3-5-sonnet-20241022", max_tokens: 500,**Environment Variables:**- `SLACK_WEBHOOK_URL` - Slack webhook- `ANTHROPIC_API_KEY` - Claude API key**Octolens:** }, body: JSON.stringify({ model: "anthropic/claude-3.5-sonnet", // 您可以選擇偏好的模型 messages: [{ role: "user", content: prompt }], }),import { createAnthropic } from "npm:@ai-sdk/anthropic@1.2.12";const anthropic = createAnthropic({ apiKey: "hi" });console.log(anthropic.tools.computer_20241022.toString()); project, branchId, // anthropicApiKey, // bearerToken, selectedFiles,- [x] Add a "view source" / "send me a PR" link- [x] Show the HTTP preview in second column if there is one (and let the user pick which one to preview in the iframe)- [x] Figure out a convention to teach in the anthropic prompt mod where the LLM always checks the readme for the scope (if not provided) and keeps it up to take with every change- [x] Ability to create new projects from the interface- [x] Figure out why OpenTownie can't create HTTP vals. Maybe give it a seperate tool for it?- [x] Start a timer for messages- [x] Add more indicators that it's "still working"- [x] Require users supply their own Anthropic token?- [x] Add cost indications on messages- [x] Add a bell noise when the message is done to let us knowimport { readFile } from "https://esm.town/v/std/utils/index.ts";import { createAnthropic } from "npm:@ai-sdk/anthropic@1.2.12";import { convertToCoreMessages, } = await c.req.json(); const apiKey = Deno.env.get("ANTHROPIC_API_KEY"); if (await hasInsufficientCredits({ bearerToken })) { }); const anthropic = createAnthropic({ apiKey }); let tracedModel = anthropic(model); if (Deno.env.get("POSTHOG_PROJECT_API_KEY")) { const traceId = `townie_${rowid}_${Date.now()}`; // Wrap the Anthropic model with PostHog tracing tracedModel = withTracing(anthropic(model), phClient, { posthogDistinctId: user.id, posthogTraceId: traceId, // @ts-ignore lastMessage.content.at(-1).providerOptions = { anthropic: { cacheControl: { type: "ephemeral" } }, }; } output_tokens: result.usage.completionTokens, cache_read_tokens: result.providerMetadata.anthropic.cacheReadInputTokens, cache_write_tokens: result.providerMetadata.anthropic.cacheCreationInputTokens, }); output_tokens: result.usage.completionTokens, cache_read_tokens: result.providerMetadata.anthropic.cacheReadInputTokens, cache_write_tokens: result.providerMetadata.anthropic.cacheCreationInputTokens, }); },Townie is fully open-source and itself runs on Val Town. Pull requests welcome!To get Townie running in your Val Town account, click the **Remix** button and then add your ANTHROPIC_API_KEY. You can leave all the other environment variables blank.Authentication in Townie is handled via Val Town Oauth. However, we have not yet opened up our OAuth to anyone else, which currently makes it very awkward to use your own Townie. Here is a temporary workaround: