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

Client for communicating with local Ollama LLM server. More...

#include <OllamaClient.hpp>

Inheritance diagram for ai::OllamaClient:
Inheritance graph
Collaboration diagram for ai::OllamaClient:
Collaboration graph

Public Member Functions

 OllamaClient (const std::string &model="llama3.2", const std::string &baseUrl="http://localhost:11434")
 
 ~OllamaClient () 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
 
void SetBaseUrl (const std::string &url)
 
std::vector< ModelInfo > GetInstalledModels () const
 Get list of installed models from Ollama.
 
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 SendHttpGet (const std::string &endpoint) const
 

Private Attributes

std::string m_model
 
std::string m_baseUrl
 

Detailed Description

Client for communicating with local Ollama LLM server.

Ollama runs locally and provides OpenAI-compatible API. Default endpoint: http://localhost:11434

Constructor & Destructor Documentation

◆ OllamaClient()

ai::OllamaClient::OllamaClient ( const std::string &  model = "llama3.2",
const std::string &  baseUrl = "http://localhost:11434" 
)
explicit

◆ ~OllamaClient()

ai::OllamaClient::~OllamaClient ( )
overridedefault

Member Function Documentation

◆ GetInstalledModels()

std::vector< ModelInfo > OllamaClient::GetInstalledModels ( ) const

Get list of installed models from Ollama.

Returns
Vector of model information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetModelName()

std::string OllamaClient::GetModelName ( ) const
overridevirtual

Get the name of the model being used.

Implements ai::IAIService.

◆ GetProviderName()

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

Get the name of the AI provider.

Implements ai::IAIService.

◆ GetServiceId()

std::string OllamaClient::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 OllamaClient::IsAvailable ( ) const
overridevirtual

Check if the AI service is available.

Returns
true if service can be reached

Implements ai::IAIService.

◆ SendHttpGet()

std::string OllamaClient::SendHttpGet ( const std::string &  endpoint) const
private
Here is the caller graph for this function:

◆ SendHttpPost()

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

◆ SendPrompt()

std::string ai::OllamaClient::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:

◆ SetBaseUrl()

void OllamaClient::SetBaseUrl ( const std::string &  url)

◆ SetModelName()

void OllamaClient::SetModelName ( const std::string &  model)
overridevirtual

Implements ai::IAIService.

Member Data Documentation

◆ m_baseUrl

std::string ai::OllamaClient::m_baseUrl
private

◆ m_model

std::string ai::OllamaClient::m_model
private

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