Search

3,155 results found for anthropic (6540ms)

Code
3,144

} from "https://esm.town/v/geoffreylitt/getWeather";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
import Anthropic from "npm:@anthropic-ai/sdk@0.24.3";
const TABLE_NAME = `memories`;
try {
// Get API key from environment
const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
if (!apiKey) {
console.error("Anthropic API key is not configured.");
return null;
}
// Initialize Anthropic client
const anthropic = new Anthropic({ apiKey });
const response = await anthropic.messages.create({
model: "claude-3-5-sonnet-latest",
max_tokens: 150,
</div>
<div>
<label htmlFor="anthropic-api-key" className="label">Anthropic API Key</label>
<input
type="password"
id="anthropic-api-key"
name="anthropic-key"
value={apiKey}
onChange={e => {
import { readFile } from "https://esm.town/v/std/utils@71-main/index.ts";
import { createAnthropic } from "npm:@ai-sdk/anthropic";
import { convertToCoreMessages, type CoreUserMessage, streamText } from "npm:ai";
import { Hono } from "npm:hono";
app.post("/", async (c) => {
let { messages, project, branchId, anthropicApiKey, selectedFiles, images, threadId } = await
console.log("Original messages:", JSON.stringify(messages, null, 2));
console.log("Images received:", JSON.stringify(images, null, 2));
throw new Error("Thread ID is required");
}
if (!anthropicApiKey) {
return Response.json({
error: "Anthropic API key is required. Please log out and add your Anthropic API key to us
}, { status: 400 });
}
let apiKey;
if (!anthropicApiKey) {
return Response.json({
error: "Anthropic API key is required. Please log out and add your Anthropic API key to us
}, { status: 400 });
} else if (anthropicApiKey === Deno.env.get("PASSWORD")) {
apiKey = Deno.env.get("PROVIDED_ANTHROPIC_API_KEY");
} else {
apiKey = anthropicApiKey;
}
const anthropic = createAnthropic({
apiKey,
});
// @ts-ignore
lastMessage.content.at(-1).providerOptions = {
anthropic: { cacheControl: { type: "ephemeral" } },
};
}
const result = await streamText({
model: anthropic(model),
messages: coreMessages,
system: system + "\n\n" + open_townie_prompt_additions,
input_tokens: result.usage.promptTokens,
completed_tokens: result.usage.completionTokens,
cacheReadTokens: result.providerMetadata.anthropic.cacheReadInputTokens,
cacheWriteTokens: result.providerMetadata.anthropic.cacheCreationInputTokens,
};
saveMessage({
import { Hono } from "npm:hono";
import { createAnthropic } from "npm:@ai-sdk/anthropic";
import { updateThreadName } from "../database/queries.ts";
export async function generateThreadName(apiKey, firstMessage, anthropicApiKey) {
const anthropic = createAnthropic({
apiKey,
});
try {
const response = await anthropic.messages.create({
model: "claude-3-haiku-20240307",
max_tokens: 50,
import Anthropic from '@anthropic-ai/sdk';
import 'dotenv/config';
// Initialize Anthropic client
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
/**
* Process a message with Anthropic Claude
* @param {string} prompt - The prompt to send to Claude
* @param {Object} options - Additional options
export async function processWithClaude(prompt, options = {}) {
try {
const message = await anthropic.messages.create({
model: options.model || 'claude-3-haiku-20240307',
max_tokens: options.maxTokens || 1000,
import { getMessages, getLinks } from './database.js';
ion, categorizeContent, summarizeConversation } from './anthropic-service.js';
import 'dotenv/config';
try {
// Use Anthropic to analyze the conversation
const result = await analyzeConversation(messages.slice(0, 50), query);
const messages = getMessages(filters);
// Use Anthropic to generate a summary
try {
const summaryResult = await summarizeConversation(messages.slice(0, 100), query);
});
// Use Anthropic to analyze furniture-related content
try {
// Create prompt for furniture analysis
const messages = getMessages(filters);
// Use Anthropic to analyze messages
try {
// Direct analysis of messages with Claude
"discord-interactions": "^3.4.0",
"better-sqlite3": "^9.2.2",
"@anthropic-ai/sdk": "^0.16.1",
"express": "^4.18.2",
"linkify-it": "^4.0.1",
import linkify from 'linkify-it';
import { getMessages, updateLinkCategory } from './database.js';
import { categorizeContent } from './anthropic-service.js';
import 'dotenv/config';
if (isFurnitureRelated) {
// Use Anthropic to determine specific furniture category
const validCategories = [
'sofa', 'chair', 'table', 'bed', 'dresser', 'desk',
- **Database Layer**: Uses Val.town's built-in SQLite database
- **AI Integration**: Leverages Anthropic's Claude API for analysis
- **Discord Integration**:
- Bot token for fetching messages
- `DISCORD_USER_ID`: Your Discord user ID
- `SPOUSE_USER_ID`: Your partner's Discord user ID
- `ANTHROPIC_API_KEY`: Your Anthropic API key
### Discord Bot Setup
// Link analyzer for Val.town
import { getMessages, updateLinkCategory } from "./database.ts";
import { categorizeContent } from "./anthropic-service.ts";
import { extractUrls, log } from "../shared/utils.ts";
import type { MessageRecord, LinkRecord } from "../shared/types.ts";
if (isFurnitureRelated) {
// Use Anthropic to determine specific furniture category
const validCategories = [
'sofa', 'chair', 'table', 'bed', 'dresser', 'desk',

Vals

10
View more
diegoivo
anthropicWorkflow
 
Public
diegoivo
sdkAnthropic
 
Public
maddy
anthropicProxy
 
Public
stevekrouse
anthropicStreamDemo
 
Public
toowired
anthropicCaching
 
Public

Users

No users found
No docs found