45
46async function getGithubReleases(repo: string): Promise<GithubRelease[]> {
47 const response = await fetch(`https://api.github.com/repos/${repo}/releases`);
48 if (!response.ok) {
49 throw new Error(`Failed to fetch releases from ${repo}`);
1// This implementation uses SQLite to store blob data instead of the Val Town API.
2// It creates a 'blobs' table to store key-value pairs, where the key is the blob key
3// and the value is the blob data stored as TEXT. This approach allows for persistence
13 }
14
15 // Check that your valtown API key is sent in the 'x-authorization' header
16 // Delete this line if you don't mind other parties hitting this endpoint
17 if (req.headers.get("x-authorization") !== Deno.env.get("valtown")) {
24 try {
25 const body = await req.json();
26 const apiKey = req.headers.get("x-api-key");
27
28 if (!body) {
30 }
31
32 if (!apiKey) {
33 throw new Error("No API key provided");
34 }
35
36 const anthropic = new Anthropic({ apiKey });
37
38 if (body?.stream) {
57 }
58 } catch (e) {
59 if (e instanceof Anthropic.APIError) {
60 return Response.json(e.error, { status: e.status });
61 }
96 const data = await response;
97 const update = await fetch(
98 `https://discord.com/api/v10/webhooks/${body.application_id}/${body.token}/messages/@original`,
99 {
100 method: "PATCH",
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)
13Change the `query` variable for what you want to get notified for.
14
15You can use [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to customize your query, for some collection of keywords, filtering out others, and much more!
16
17## 3. Notification
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === undefined) {
6 const { OpenAI } = await import("https://esm.town/v/std/openai");
7 return new OpenAI();
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === undefined) {
6 const { OpenAI } = await import("https://esm.town/v/std/openai");
7 return new OpenAI();
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === @std/openai) {
6 const { OpenAI } = await import("https://esm.town/v/std/openai");
7 return new OpenAI();
3Speech-to-text and chapter summaries powered by [Substrate](https://substrate.run)
4
5🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
6
7Migrated from folder: Archive/subaudio