Search

Results include substring matches and semantically similar vals. Learn more
mmrech avatar
anthropicProxy
@mmrech
This Val will proxy anthropic HTTP requests from some frontend client, like langchain, so that you can utilize anthropic apis from the browser. Convert 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)
Script
This Val will proxy anthropic HTTP requests from some frontend client, like langchain, so that you can utilize anthropic apis
Convert 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
import Anthropic from "npm:@anthropic-ai/sdk@0.24.3";
export default async function(req: Request): Promise<Response> {
throw new Error("No API key provided");
const anthropic = new Anthropic({ apiKey });
if (body?.stream) {
const textEncoder = new TextEncoder();
anthropic.messages.stream(body).on("text", (data) => {
writer.write(textEncoder.encode(data));
} else {
const response = await anthropic.messages.create(body);
return Response.json(response);
} catch (e) {
if (e instanceof Anthropic.APIError) {
return Response.json(e.error, { status: e.status });
stevekrouse avatar
anthropicCaching
@stevekrouse
* This val creates an interactive webpage that demonstrates the functionality of the Anthropic API. * It uses a React frontend with an input for the API key and buttons to trigger different operations. * The Anthropic API key is stored in the frontend state and sent with each API request.
HTTP (deprecated)
* This val creates an interactive webpage that demonstrates the functionality of the Anthropic API.
* The Anthropic API key is stored in the frontend state and sent with each API request.
alert("Please enter your Anthropic API key first.");
<h1>Anthropic Caching JS Demo</h1>
<a href="https://github.com/anthropics/anthropic-cookbook/blob/7786b9f39db8ba65202792f564c59697a5222531/misc/prompt_c
</a>. Enter in your Anthropic API key (which is not saved) and click the buttons to see the results.
placeholder="Enter Anthropic API Key"
<title>Anthropic Caching JS Demo</title>
const { default: anthropic } = await import("npm:@anthropic-ai/sdk@0.26.1");
const client = new anthropic.Anthropic({ apiKey });
cephalization avatar
anthropicProxy
@cephalization
https://simonwillison.net/2024/Aug/23/anthropic-dangerous-direct-browser-access/ THIS IS NO LONGER NECESSARY This Val will proxy anthropic HTTP requests from some frontend client, like langchain, so that you can utilize anthropic apis from the browser. Convert 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)
Script
https://simonwillison.net/2024/Aug/23/anthropic-dangerous-direct-browser-access/
THIS IS NO LONGER NECESSARY
This Val will proxy anthropic HTTP requests from some frontend client, like langchain, so that you can utilize anthropic apis
Convert 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
import Anthropic from "npm:@anthropic-ai/sdk@0.24.3";
export default async function(req: Request): Promise<Response> {
throw new Error("No API key provided");
const anthropic = new Anthropic({ apiKey });
if (body?.stream) {
const textEncoder = new TextEncoder();
anthropic.messages.stream(body).on("text", (data) => {
writer.write(textEncoder.encode(data));
} else {
const response = await anthropic.messages.create(body);
return Response.json(response);
} catch (e) {
if (e instanceof Anthropic.APIError) {
return Response.json(e.error, { status: e.status });
stevekrouse avatar
anthropicStreamDemo
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP (deprecated)
import Anthropic from "npm:@anthropic-ai/sdk@0.22.0";
export default async (req: Request) => {
const anthropic = new Anthropic();
let { readable, writable } = new TransformStream();
const textEncoder = new TextEncoder();
anthropic.messages.stream({
model: "claude-3-haiku-20240307",
jsomers avatar
watchAnthropicCircuitsBlog
@jsomers
An interactive, runnable TypeScript val by jsomers
Cron
export const watchWebsite = async () => {
const url = "https://transformer-circuits.pub";
const newHtml = await fetch(url).then(r => r.text());
const key = "watch:" + url;
let oldHtml = "";
try {
oldHtml = await blob.get(key).then(r => r.text());
} catch (error) {
console.log("error");
await blob.set(key, newHtml);
yawnxyz avatar
claude
@yawnxyz
// Define a mapping for model shortcuts
Script
import Anthropic from "npm:@anthropic-ai/sdk";
const anthropic = new Anthropic({
// apiKey: 'my_api_key', // defaults to process.env["ANTHROPIC_API_KEY"]
// Define a mapping for model shortcuts
messages.push({ role: "user", content: text });
let res = await anthropic.messages.create({
model: modelId,
yawnxyz avatar
ai
@yawnxyz
An http and class wrapper for Vercel's AI SDK Usage: Groq: https://yawnxyz-ai.web.val.run/generate?prompt="tell me a beer joke"&provider=groq&model=llama3-8b-8192 Perplexity: https://yawnxyz-ai.web.val.run/generate?prompt="what's the latest phage directory capsid & tail article about?"&provider=perplexity Mistral: https://yawnxyz-ai.web.val.run/generate?prompt="tell me a joke?"&provider=mistral&model="mistral-small-latest" async function calculateEmbeddings(text) { const url = `https://yawnxyz-ai.web.val.run/generate?embed=true&value=${encodeURIComponent(text)}`; try { const response = await fetch(url); const data = await response.json(); return data; } catch (error) { console.error('Error calculating embeddings:', error); return null; } }
HTTP (deprecated)
import { createAnthropic } from "npm:@ai-sdk/anthropic@0.0.48";
const anthropic = createAnthropic({
// apiKey = Deno.env.get("ANTHROPIC_API_KEY");
apiKey: Deno.env.get("ANTHROPIC_API_KEY_COVERSHEET")
case 'anthropic':
result = await this.generateAnthropicResponse({ model, prompt, maxTokens, temperature, streaming, schema, system, mes
async generateAnthropicResponse({ model, prompt, maxTokens, temperature, streaming, schema, system, messages, tools, ...add
model: anthropic(modelId),
model: anthropic(modelId),
model: anthropic(modelId),
janpaul123 avatar
VALLE
@janpaul123
VALL-E LLM code generation for vals! Make apps with a frontend, backend, and database. It's a bit of work to get this running, but it's worth it. Fork this val to your own profile. Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in tempValsParentFolderId . If you want to use OpenAI models you need to set the OPENAI_API_KEY env var . If you want to use Anthropic models you need to set the ANTHROPIC_API_KEY env var . Create a Val Town API token , open the browser preview of this val, and use the API token as the password to log in.
HTTP (deprecated)
* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-v
* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environ
* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API tok
kora avatar
sonnet
@kora
Anthropic Claude Claude 3.5 Sonnet
Script
# Anthropic Claude
Claude 3.5 Sonnet
import Anthropic from "npm:@anthropic-ai/sdk";
const anthropic = new Anthropic();
const msg = await anthropic.messages.create({
model: "claude-3-5-sonnet-20240620",
janpaul123 avatar
VALLErun
@janpaul123
The actual code for VALL-E: https://www.val.town/v/janpaul123/VALLE
HTTP (deprecated)
import { sleep } from "https://esm.town/v/stevekrouse/sleep?v=1";
import { anthropic } from "npm:@ai-sdk/anthropic";
import { openai } from "npm:@ai-sdk/openai";
} else {
vercelModel = anthropic(model);
// Anthropic doesn't support system messages not at the very start.
const systemRole = model.includes("gpt") ? "system" : "user";
maxTokens: 8192,
headers: { "anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15" },
let messages = [
stevekrouse avatar
honEmeraldSnail
@stevekrouse
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
if (request.method === "POST" && new URL(request.url).pathname === "/api/chat") {
const { Anthropic } = await import("https://esm.sh/@anthropic-ai/sdk@0.17.1");
const { messages } = await request.json();
Do not escape newline characters.`
const anthropic = new Anthropic();
try {
const response = await anthropic.messages.create({
system: messages.length === 1 ? SYSTEM_NEW : SYSTEM_DIFF,
yawnxyz avatar
nighthawks
@yawnxyz
This is nighthawks an experimental NPC character generator that remembers details about conversations. Import this into other workflows for now; a UI is coming soon!
Script
// model: 'mixtral-8x7b-32768',
// model: 'llama3-8b-8192',
// provider: 'anthropic',
// model: 'claude-3-haiku-20240307',
system: [
provider: 'groq',
model: 'mixtral-8x7b-32768',
// provider: 'anthropic',
// model: 'claude-3-opus-20240229',
// model: 'claude-3-sonnet-20240229',
taowen avatar
npmExample
@taowen
An interactive, runnable TypeScript val by taowen
Script
export let npmExample = (async () => {
const { HUMAN_PROMPT, AI_PROMPT, Client } = await import(
"npm:@anthropic-ai/sdk"
); // The Lodash library exported as ES modules.
const client = new Client(
trantion avatar
largeAmaranthCat
@trantion
VALL-E LLM code generation for vals! Make apps with a frontend, backend, and database. It's a bit of work to get this running, but it's worth it. Fork this val to your own profile. Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in tempValsParentFolderId . If you want to use OpenAI models you need to set the OPENAI_API_KEY env var . If you want to use Anthropic models you need to set the ANTHROPIC_API_KEY env var . Create a Val Town API token , open the browser preview of this val, and use the API token as the password to log in.
HTTP (deprecated)
* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-v
* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environ
* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API tok
stevekrouse avatar
firmIvorySawfish
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import Anthropic from "npm:@anthropic-ai/sdk@0.22.0";
import ValTown from "npm:@valtown/sdk";
return content;
const anthropic = new Anthropic();
async function summarizeVal(valData) {
const anthropicResponse = await anthropic.messages.create({
model: "claude-3-sonnet-20240229",
text: JSON.stringify(valData),
return anthropicResponse.content[0].type === "text"
? anthropicResponse.content[0].text
: null;