Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,20 @@ use Utopia\Agents\Adapters\Anthropic;

$anthropic = new Anthropic(
apiKey: 'your-api-key',
model: Anthropic::MODEL_CLAUDE_3_SONNET,
model: Anthropic::MODEL_CLAUDE_3_HAIKU,
maxTokens: 2048,
temperature: 0.7
);
```

Available Anthropic Models:
- `MODEL_CLAUDE_3_OPUS`: Most powerful model
- `MODEL_CLAUDE_3_SONNET`: Balanced performance
- `MODEL_CLAUDE_3_HAIKU`: Fast and efficient
- `MODEL_CLAUDE_2_1`: Previous generation
- `MODEL_CLAUDE_4_OPUS`: Flagship model with exceptional reasoning for the most demanding tasks
- `MODEL_CLAUDE_3_OPUS`: Premium model with superior performance on complex analysis and creative work
- `MODEL_CLAUDE_4_SONNET`: Intelligent and responsive model optimized for productivity workflows
- `MODEL_CLAUDE_3_7_SONNET`: Enhanced model with improved reasoning and coding capabilities
- `MODEL_CLAUDE_3_5_SONNET`: Versatile model balancing capability and speed for general use
- `MODEL_CLAUDE_3_5_HAIKU`: Ultra-fast model for quick responses and lightweight processing
- `MODEL_CLAUDE_3_HAIKU`: Rapid model designed for speed and efficiency on straightforward tasks

#### Deepseek

Expand Down
2 changes: 0 additions & 2 deletions src/Agents/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ abstract public function getModel(): string;
*
* @param string $model
* @return self
*
* @throws \Exception if model is not supported
*/
abstract public function setModel(string $model): self;

Expand Down
46 changes: 29 additions & 17 deletions src/Agents/Adapters/Anthropic.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,39 @@
class Anthropic extends Adapter
{
/**
* Claude 3 Opus - Most powerful model for highly complex tasks
* Claude 4 Opus - Flagship model with exceptional reasoning for the most demanding tasks
*/
public const MODEL_CLAUDE_3_OPUS = 'claude-3-opus-20240229';
public const MODEL_CLAUDE_4_OPUS = 'claude-opus-4-0';

/**
* Claude 3 Sonnet - Ideal balance of intelligence and speed
* Claude 3 Opus - Premium model with superior performance on complex analysis and creative work
*/
public const MODEL_CLAUDE_3_SONNET = 'claude-3-7-sonnet-20250219';
public const MODEL_CLAUDE_3_OPUS = 'claude-3-opus-latest';

/**
* Claude 3 Haiku - Fastest and most compact model
* Claude 4 Sonnet - Intelligent and responsive model optimized for productivity workflows
*/
public const MODEL_CLAUDE_3_HAIKU = 'claude-3-haiku-20240229';
public const MODEL_CLAUDE_4_SONNET = 'claude-sonnet-4-0';

/**
* Claude 2.1 - Previous generation model
* Claude 3.7 Sonnet - Enhanced model with improved reasoning and coding capabilities
*/
public const MODEL_CLAUDE_2_1 = 'claude-2.1';
public const MODEL_CLAUDE_3_7_SONNET = 'claude-3-7-sonnet-latest';

/**
* Claude 3.5 Sonnet - Versatile model balancing capability and speed for general use
*/
public const MODEL_CLAUDE_3_5_SONNET = 'claude-3-5-sonnet-latest';

/**
* Claude 3.5 Haiku - Ultra-fast model for quick responses and lightweight processing
*/
public const MODEL_CLAUDE_3_5_HAIKU = 'claude-3-5-haiku-latest';

/**
* Claude 3 Haiku - Rapid model designed for speed and efficiency on straightforward tasks
*/
public const MODEL_CLAUDE_3_HAIKU = 'claude-3-haiku-20240307';

/**
* Cache TTL for 3600 seconds
Expand Down Expand Up @@ -74,7 +89,7 @@ class Anthropic extends Adapter
*/
public function __construct(
string $apiKey,
string $model = self::MODEL_CLAUDE_3_SONNET,
string $model = self::MODEL_CLAUDE_3_HAIKU,
int $maxTokens = 1024,
float $temperature = 1.0,
int $timeout = 90
Expand Down Expand Up @@ -356,10 +371,13 @@ protected function process(Chunk $chunk, ?callable $listener): string
public function getModels(): array
{
return [
self::MODEL_CLAUDE_4_OPUS,
self::MODEL_CLAUDE_3_OPUS,
self::MODEL_CLAUDE_3_SONNET,
self::MODEL_CLAUDE_4_SONNET,
self::MODEL_CLAUDE_3_7_SONNET,
self::MODEL_CLAUDE_3_5_SONNET,
self::MODEL_CLAUDE_3_5_HAIKU,
self::MODEL_CLAUDE_3_HAIKU,
self::MODEL_CLAUDE_2_1,
];
}

Expand All @@ -378,15 +396,9 @@ public function getModel(): string
*
* @param string $model
* @return self
*
* @throws \Exception
*/
public function setModel(string $model): self
{
if (! in_array($model, $this->getModels())) {
throw new \Exception('Unsupported model: '.$model);
}

$this->model = $model;

return $this;
Expand Down
6 changes: 0 additions & 6 deletions src/Agents/Adapters/Deepseek.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,9 @@ public function getModel(): string
*
* @param string $model
* @return self
*
* @throws \Exception
*/
public function setModel(string $model): self
{
if (! in_array($model, $this->getModels())) {
throw new \Exception('Unsupported model: '.$model);
}

$this->model = $model;

return $this;
Expand Down
6 changes: 0 additions & 6 deletions src/Agents/Adapters/Gemini.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,9 @@ public function getModel(): string
*
* @param string $model
* @return self
*
* @throws \Exception
*/
public function setModel(string $model): self
{
if (! in_array($model, $this->getModels())) {
throw new \Exception('Unsupported model: '.$model);
}

$this->model = $model;

return $this;
Expand Down
6 changes: 0 additions & 6 deletions src/Agents/Adapters/OpenAI.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,9 @@ public function getModel(): string
*
* @param string $model
* @return self
*
* @throws \Exception
*/
public function setModel(string $model): self
{
if (! in_array($model, $this->getModels())) {
throw new \Exception('Unsupported model: '.$model);
}

$this->model = $model;

return $this;
Expand Down
2 changes: 1 addition & 1 deletion tests/Agents/Conversation/ConversationAnthropicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function createAdapter(): Adapter

return new Anthropic(
$apiKey,
Anthropic::MODEL_CLAUDE_3_SONNET,
Anthropic::MODEL_CLAUDE_3_HAIKU,
1024,
1.0
);
Expand Down