Anthropic

Anthropic node allows integration with Anthropic’s large language models to generate answers based on user inputs. This node is used for tasks like question answering, summarization, or text generation.

Inputs

  • Prompt – Text prompt for the model
  • Questions – This port receives natural language prompts or questions from upstream nodes. The input is passed to the selected LLM
  • Documents – Document objects for context
  • System – System instructions for the model

Outputs

  • Text – Generated text output
  • Answers – This port emits the LLM-generated responses based on the received input. These outputs can be passed to downstream nodes for further processing or storage

Configuration

Model Settings

  • Model – Anthropic model to use
    • Default – “claude-3-opus-20240229”
    • Note – Available models include claude-3-opus, claude-3-sonnet, claude-3-haiku
      • Use Claude-3-Opus for highest quality and complex reasoning tasks
      • Use Claude-3-Sonnet for a balance of quality and speed
      • Use Claude-3-Haiku for faster responses and lower cost
  • API Key – Anthropic API key
    • Note – Required for authentication
  • Temperature – Creativity/randomness level
    • Default – 0.7
    • Note – Range: 0.0-1.0
  • Max Tokens – Maximum response length
    • Default – 1024
    • Note – Limits output size

Advanced Settings

  • Top P – Nucleus sampling parameter
    • Default – 0.95
    • Note – Controls diversity
  • Top K – Top-K sampling parameter
    • Default – 40
    • Note – Limits token selection
  • System Prompt – Default system instructions
    • Note – Sets model behavior
  • Stop Sequences – Sequences to stop generation
    • Default – []
    • Note – Custom stop tokens
  • Timeout – API request timeout
    • Default – 60
    • Note – In seconds

Samples

Basic Text Generation

This example shows how to configure the Anthropic LLM for basic text generation:
{
"model": "claude-3-sonnet-20240229",
"apiKey": "your-api-key",
"temperature": 0.7,
"maxTokens": 1024,
"topP": 0.95
}

RAG Implementation

For a Retrieval-Augmented Generation (RAG) implementation with specific system instructions:
{
"model": "claude-3-opus-20240229",
"apiKey": "your-api-key",
"temperature": 0.3,
"maxTokens": 2048,
"systemPrompt":
"You are a helpful assistant that answers questions based on the provided documents. Always cite your sources and maintain a professional tone.",
"topP": 0.9,
"timeout": 120
}

Best Practices

Prompt Engineering

  • Provide clear, specific instructions in your prompts
  • Use system prompts to establish consistent behavior
  • Include relevant context for knowledge-intensive tasks
  • Structure prompts with clear sections for complex tasks

Performance Optimization

  • Adjust temperature based on task requirements (lower for factual responses, higher for creative content)
  • Set appropriate max tokens to avoid unnecessary processing
  • Use streaming for responsive user interfaces

Troubleshooting

API Problems

  • Authentication errors – Verify API key validity
  • Rate limit exceeded – Implement request throttling or upgrade API tier
  • Timeout errors – Increase timeout setting or reduce prompt/context size

Response Quality Issues

  • Irrelevant responses – Refine prompts or adjust system instructions
  • Inconsistent outputs – Lower temperature for more deterministic responses
  • Truncated responses – Increase max tokens setting
Technical Reference

For detailed technical information, refer to: