ai

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message string `json:"message"`
	Type    string `json:"type"`
	Code    string `json:"code"`
}

APIError represents an API error

type Choice

type Choice struct {
	Message Message `json:"message"`
}

Choice represents a response choice

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a chat message

type ModelInfo

type ModelInfo struct {
	ID     string `json:"id"`
	Object string `json:"object"`
}

ModelInfo represents a single model in the list

type ModelListResponse

type ModelListResponse struct {
	Data []ModelInfo `json:"data"`
}

ModelListResponse represents the /v1/models endpoint response

type OllamaGenerateRequest

type OllamaGenerateRequest struct {
	Model  string `json:"model"`
	Prompt string `json:"prompt"`
	Stream bool   `json:"stream"`
}

OllamaGenerateRequest represents Ollama's /api/generate request

type OllamaGenerateResponse

type OllamaGenerateResponse struct {
	Response string `json:"response"`
	Done     bool   `json:"done"`
}

OllamaGenerateResponse represents Ollama's /api/generate response

type OllamaModel

type OllamaModel struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
}

OllamaModel represents a model in Ollama's response

type OllamaTagsResponse

type OllamaTagsResponse struct {
	Models []OllamaModel `json:"models"`
}

OllamaTagsResponse represents Ollama's /api/tags response

type OpenAIClient

type OpenAIClient struct {
	APIKey          string
	BaseURL         string
	Model           string
	HTTPClient      *http.Client
	Validated       bool
	ValidationErr   string
	ServiceName     string
	AvailableModels []string
	AutoSelectModel bool // True if no model was specified, should auto-select
}

OpenAIClient handles OpenAI API compatible requests

func NewOpenAIClient

func NewOpenAIClient(model string) *OpenAIClient

NewOpenAIClient creates a new OpenAI client with environment variable detection

func (*OpenAIClient) AnalyzeLog

func (c *OpenAIClient) AnalyzeLog(logMessage, severity, timestamp string, attributes map[string]string) (string, error)

AnalyzeLog sends a log message to the AI for analysis

func (*OpenAIClient) AnalyzeLogWithContext

func (c *OpenAIClient) AnalyzeLogWithContext(logMessage, severity, timestamp string, attributes map[string]string, previousAnalysis string, question string) (string, error)

AnalyzeLogWithContext sends a log message to the AI with chat context

func (*OpenAIClient) GetAvailableModels

func (c *OpenAIClient) GetAvailableModels() ([]string, error)

GetAvailableModels fetches the list of available models from the API

func (*OpenAIClient) GetValidationStatus

func (c *OpenAIClient) GetValidationStatus() (bool, string, string, string)

GetValidationStatus returns the validation status and any error message

func (*OpenAIClient) ValidateConfiguration

func (c *OpenAIClient) ValidateConfiguration()

ValidateConfiguration checks if the AI client is properly configured

type OpenAIRequest

type OpenAIRequest struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
}

OpenAIRequest represents the request structure

type OpenAIResponse

type OpenAIResponse struct {
	Choices []Choice `json:"choices"`
	Error   any      `json:"error,omitempty"` // Can be string or object
}

OpenAIResponse represents the API response with flexible error handling

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL