Search

3,155 results found for anthropic (3736ms)

Code
3,144

tnm/aws/main.ts
1 matches
message: "Analyze this AWS email and let me know if we need to do anything: " + emailBody,
},
model_provider: "anthropic",
model: "claude-sonnet-4-0",
};
import { WebClient } from "npm:@slack/web-api";
import Anthropic from "npm:@anthropic-ai/sdk";
import type { AppMentionEvent, GenericMessageEvent } from "npm:@slack/web-api";
export const slack = new WebClient(Deno.env.get("SLACK_BOT_TOKEN"));
export async function getSlackHistory(
event: AppMentionEvent | GenericMessageEvent,
): Promise<Anthropic.MessageParam[]> {
const { messages } = await slack.conversations.replies({
channel: event.channel,
import { SYSTEM_PROMPT } from "../prompts/index.ts";
import Anthropic from "npm:@anthropic-ai/sdk";
import { z } from "npm:zod@3.23.8";
});
const anthropic = new Anthropic({ apiKey: Deno.env.get("CLAUDE_API_KEY") });
export async function shouldReply(
threadHistory: Anthropic.MessageParam[],
): Promise<boolean> {
const response = await anthropic.messages.create({
model: "claude-sonnet-4-20250514",
max_tokens: 200,
}
// Claude provider (Anthropic)
const claudeKey = Deno.env.get('ANTHROPIC_API_KEY');
if (claudeKey) {
this.providers.set('claude', {
model: 'claude-3-haiku-20240307',
apiKey: claudeKey,
baseUrl: 'https://api.anthropic.com/v1',
maxTokens: 150,
temperature: 0.8
'Authorization': `Bearer ${provider.apiKey}`,
'Content-Type': 'application/json',
'anthropic-version': '2023-06-01'
},
body: JSON.stringify({
import { SYSTEM_PROMPT } from "../prompts/index.ts";
import Anthropic from "npm:@anthropic-ai/sdk";
import { z } from "npm:zod@3.23.8";
});
const anthropic = new Anthropic({ apiKey: Deno.env.get("CLAUDE_API_KEY") });
export async function shouldReply(
threadHistory: Anthropic.MessageParam[],
): Promise<boolean> {
const response = await anthropic.messages.create({
model: "claude-sonnet-4-20250514",
max_tokens: 200,
T1["Query Mongo"]
T2["CSV Export"]
T3["Anthropic Web Search"]
T4["E2B Matplotlib Visualization"]
end
# 📚 Guia Completo de Exemplos - Anthropic Agent API
Este guia contém exemplos práticos de como usar os bodies das requests para cada endpoint da API
# Anthropic Agent API with MCPs
Uma API completa para gerenciar agentes Anthropic com suporte a MCPs (Model Context Protocols) e
## 🚀 Status da API
## Funcionalidades
- 🤖 **Agentes Anthropic**: Integração com Claude Sonnet 4 usando thinking mode
- 🔗 **MCPs Integrados**: Firecrawl, Serper.dev e Semrush
- 🔄 **Workflows**: Criação de pipelines onde o output de um agente é input do próximo
```bash
ANTHROPIC_API_KEY=your_anthropic_api_key_here
FIRECRAWL_API_KEY=your_firecrawl_api_key_here
SERPER_API_KEY=your_serper_api_key_here
| Serviço | URL | Descrição |
|---------|-----|-----------|
| **Anthropic** | https://console.anthropic.com/ | Claude API para agentes inteligentes |
| **Firecrawl** | https://firecrawl.dev/ | Web scraping e extração de conteúdo |
| **Serper.dev** | https://serper.dev/ | Google Search API |
│ │ └── swagger.ts # Documentação Swagger
│ ├── services/
│ │ ├── anthropic.ts # Integração com Anthropic
│ │ ├── mcps.ts # Gerenciamento de MCPs
│ │ └── workflow.ts # Engine de workflows
import type { Agent } from "../../shared/types.ts";
export interface AnthropicMessage {
role: 'user' | 'assistant';
content: string;
}
export interface AnthropicResponse {
id: string;
type: string;
}
export class AnthropicService {
private apiKey: string;
private baseUrl = 'https://api.anthropic.com/v1';
constructor() {
this.apiKey = Deno.env.get('ANTHROPIC_API_KEY') || '';
if (!this.apiKey) {
throw new Error('ANTHROPIC_API_KEY environment variable is required');
}
}
async executeAgent(
agent: Agent,
messages: AnthropicMessage[],
tools?: any[]
): Promise<AnthropicResponse> {
const headers = {
'Content-Type': 'application/json',
'x-api-key': this.apiKey,
'anthropic-version': '2023-06-01',
'anthropic-beta': 'computer-use-2024-10-22'
};
if (!response.ok) {
const errorData = await response.json();
throw new Error(`Anthropic API error: ${errorData.error?.message || response.statusText}
}
return await response.json();
} catch (error) {
console.error('Error calling Anthropic API:', error);
throw error;
}
async streamAgent(
agent: Agent,
messages: AnthropicMessage[],
tools?: any[],
onChunk?: (chunk: any) => void
): Promise<AnthropicResponse> {
const headers = {
'Content-Type': 'application/json',
'x-api-key': this.apiKey,
'anthropic-version': '2023-06-01',
'anthropic-beta': 'computer-use-2024-10-22'
};
if (!response.ok) {
const errorData = await response.json();
throw new Error(`Anthropic API error: ${errorData.error?.message || response.statusText}
}
}
return fullResponse as AnthropicResponse;
} catch (error) {
console.error('Error streaming from Anthropic API:', error);
throw error;
}
}
formatMessagesForAnthropic(input: any): AnthropicMessage[] {
const messages: AnthropicMessage[] = [];
// Se o input for uma string simples
}
extractOutputFromResponse(response: AnthropicResponse): any {
try {
const content = response.content[0]?.text || '';
import { generateId } from "../database/migrations.ts";
import * as db from "../database/queries.ts";
import { AnthropicService } from "./anthropic.ts";
import { MCPService } from "./mcps.ts";
export class WorkflowService {
private anthropicService: AnthropicService;
private mcpService: MCPService;
constructor() {
this.anthropicService = new AnthropicService();
this.mcpService = new MCPService();
}
try {
// Preparar mensagens para Anthropic
const messages = this.anthropicService.formatMessagesForAnthropic(input);
// Preparar tools baseadas nos MCPs do agente
const tools = this.mcpService.generateToolsForAgent(agent.mcps);
// Executar com Anthropic
const response = await this.anthropicService.executeAgent(agent, messages, tools);
// Processar tool calls se houver
// Extrair output
const output = this.anthropicService.extractOutputFromResponse(finalResponse);
const tokensUsed = finalResponse.usage.input_tokens + finalResponse.usage.output_tokens;
// Fazer nova chamada com os resultados das tools
return await this.anthropicService.executeAgent(agent, updatedMessages);
}

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