ai

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse interface {
	GetContent() string
	GetTokensUsed() int
	GetFinishReason() string // ADD THIS
	IsComplete() bool        // ADD THIS
}

APIResponse interface for different provider responses

type AnthropicContent

type AnthropicContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type AnthropicMessage

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

type AnthropicRequest

type AnthropicRequest struct {
	Model       string             `json:"model"`
	MaxTokens   int                `json:"max_tokens"`
	Temperature float64            `json:"temperature,omitempty"`
	Messages    []AnthropicMessage `json:"messages"`
}

Anthropic API types

type AnthropicResponse

type AnthropicResponse struct {
	Content    []AnthropicContent `json:"content"`
	Usage      AnthropicUsage     `json:"usage"`
	StopReason string             `json:"stop_reason"` // ADD THIS
}

func (*AnthropicResponse) GetContent

func (r *AnthropicResponse) GetContent() string

func (*AnthropicResponse) GetFinishReason

func (r *AnthropicResponse) GetFinishReason() string

func (*AnthropicResponse) GetTokensUsed

func (r *AnthropicResponse) GetTokensUsed() int

func (*AnthropicResponse) IsComplete

func (r *AnthropicResponse) IsComplete() bool

type AnthropicUsage

type AnthropicUsage struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles AI API requests

func New

func New(cfg *types.APIConfig) *Client

New creates a new AI client

func (*Client) BuildContinuationPrompt

func (c *Client) BuildContinuationPrompt(partialContent, originalContent string, req types.AIRequest) string

NEW: Build continuation prompt

func (*Client) LooksReasonablyComplete

func (c *Client) LooksReasonablyComplete(response, original string, language types.Language) bool

NEW: Check if response looks reasonably complete

func (*Client) MergeContinuation

func (c *Client) MergeContinuation(existing, continuation string) string

Enhanced mergeContinuation with robust overlap detection and removal

func (*Client) ProcessContent

func (c *Client) ProcessContent(req types.AIRequest, contextFiles []*types.ContextFile) (*types.AIResponse, error)

ProcessContent sends content to AI for processing

func (*Client) ValidateConfig

func (c *Client) ValidateConfig() error

ValidateConfig checks if the AI configuration is valid

type OpenAIChoice

type OpenAIChoice struct {
	Message      OpenAIMessage `json:"message"`
	FinishReason string        `json:"finish_reason"` // ADD THIS
}

type OpenAIMessage

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

type OpenAIRequest

type OpenAIRequest struct {
	Model       string          `json:"model"`
	Messages    []OpenAIMessage `json:"messages"`
	MaxTokens   int             `json:"max_tokens,omitempty"`
	Temperature float64         `json:"temperature,omitempty"`
}

OpenAI API types

type OpenAIResponse

type OpenAIResponse struct {
	Choices []OpenAIChoice `json:"choices"`
	Usage   OpenAIUsage    `json:"usage"`
}

func (*OpenAIResponse) GetContent

func (r *OpenAIResponse) GetContent() string

func (*OpenAIResponse) GetFinishReason

func (r *OpenAIResponse) GetFinishReason() string

func (*OpenAIResponse) GetTokensUsed

func (r *OpenAIResponse) GetTokensUsed() int

func (*OpenAIResponse) IsComplete

func (r *OpenAIResponse) IsComplete() bool

type OpenAIUsage

type OpenAIUsage struct {
	TotalTokens int `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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