LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
ai::AnthropicClient Class Reference

Client for Anthropic API (Claude) More...

#include <AnthropicClient.hpp>

Inheritance diagram for ai::AnthropicClient:
Inheritance graph
Collaboration diagram for ai::AnthropicClient:
Collaboration graph

Public Member Functions

 AnthropicClient (const std::string &apiKey, const std::string &model="claude-3-sonnet-20240229", const std::string &baseUrl="https://api.anthropic.com/v1")
 
 ~AnthropicClient () override=default
 
std::string SendPrompt (const std::string &prompt, std::function< void(const std::string &)> callback=nullptr) override
 Send a prompt to the AI and get a response.
 
bool IsAvailable () const override
 Check if the AI service is available.
 
std::string GetModelName () const override
 Get the name of the model being used.
 
void SetModelName (const std::string &model) override
 
virtual std::string GetProviderName () const override
 Get the name of the AI provider.
 
std::string GetServiceId () const override
 Unique identifier for this service instance.
 
std::string GetServiceType () const override
 Type of service ("ai", "analyzer", "exporter", etc.)
 

Private Member Functions

std::string SendHttpPost (const std::string &endpoint, const std::string &jsonBody, const std::string &apiKeyHeader) const
 

Private Attributes

std::string m_apiKey
 
std::string m_model
 
std::string m_baseUrl
 

Detailed Description

Client for Anthropic API (Claude)

Supports: claude-3-opus, claude-3-sonnet, claude-3-haiku API: https://api.anthropic.com/v1 Authentication: x-api-key header

Constructor & Destructor Documentation

◆ AnthropicClient()

ai::AnthropicClient::AnthropicClient ( const std::string &  apiKey,
const std::string &  model = "claude-3-sonnet-20240229",
const std::string &  baseUrl = "https://api.anthropic.com/v1" 
)
explicit

◆ ~AnthropicClient()

ai::AnthropicClient::~AnthropicClient ( )
overridedefault

Member Function Documentation

◆ GetModelName()

std::string ai::AnthropicClient::GetModelName ( ) const
inlineoverridevirtual

Get the name of the model being used.

Implements ai::IAIService.

◆ GetProviderName()

virtual std::string ai::AnthropicClient::GetProviderName ( ) const
inlineoverridevirtual

Get the name of the AI provider.

Implements ai::IAIService.

◆ GetServiceId()

std::string ai::AnthropicClient::GetServiceId ( ) const
overridevirtual

Unique identifier for this service instance.

Implements services::IService.

◆ GetServiceType()

std::string ai::IAIService::GetServiceType ( ) const
inlineoverridevirtualinherited

Type of service ("ai", "analyzer", "exporter", etc.)

Implements services::IService.

◆ IsAvailable()

bool ai::AnthropicClient::IsAvailable ( ) const
overridevirtual

Check if the AI service is available.

Returns
true if service can be reached

Implements ai::IAIService.

◆ SendHttpPost()

std::string ai::AnthropicClient::SendHttpPost ( const std::string &  endpoint,
const std::string &  jsonBody,
const std::string &  apiKeyHeader 
) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendPrompt()

std::string ai::AnthropicClient::SendPrompt ( const std::string &  prompt,
std::function< void(const std::string &)>  callback = nullptr 
)
overridevirtual

Send a prompt to the AI and get a response.

Parameters
promptThe text prompt to send
callbackFunction called with response chunks as they arrive
Returns
Complete response text

Implements ai::IAIService.

Here is the call graph for this function:

◆ SetModelName()

void ai::AnthropicClient::SetModelName ( const std::string &  model)
overridevirtual

Implements ai::IAIService.

Member Data Documentation

◆ m_apiKey

std::string ai::AnthropicClient::m_apiKey
private

◆ m_baseUrl

std::string ai::AnthropicClient::m_baseUrl
private

◆ m_model

std::string ai::AnthropicClient::m_model
private

The documentation for this class was generated from the following files: