Documentation
¶
Index ¶
- Constants
- type Hallucination
- type Hallucinator
- func (h *Hallucinator) AppendHallucination(ctx context.Context, hallucination Hallucination)
- func (h *Hallucinator) CleanHallucinations(ctx context.Context)
- func (h *Hallucinator) DecreaseHallucinationRequestCount(ctx context.Context, id int)
- func (h *Hallucinator) GenerateHallucination(ctx context.Context) (Hallucination, error)
- func (h *Hallucinator) GetHallucinationCount(ctx context.Context) int
- func (h *Hallucinator) PopHallucination(ctx context.Context) string
- func (h *Hallucinator) PopRandomHallucination(ctx context.Context) string
- func (h *Hallucinator) Start(ctx context.Context) error
- type OllamaMessage
- type OllamaResponse
Constants ¶
const ( BackToStartString = "Back to start." ContinueString = "Continue reading..." Dream404String = "Error 404: Article not found." DreamString = "We are sorry, but the requested article could be not found!" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hallucination ¶
Hallucination is a hallucination generated by the Hallucinator.
type Hallucinator ¶
type Hallucinator struct {
Interval time.Duration
HTTPClient httpClient
Logger *slog.Logger
// contains filtered or unexported fields
}
Hallucinator is the structure for the Hallucinator.
func NewHallucinator ¶
func NewHallucinator(ctx context.Context, logger *slog.Logger, interval time.Duration, hallucinationCacheSize int, hallucinatorPromptWordCount int, hallucinationRequestCount int, hallucinationMinimalLength int, hallucinationWordCount int, hallucinationLinkPercentage int, hallucinatorLinkMaxSubdirectories int, hallucinatorLinkHasVariablesProbability float64, hallucinatorLinkMaxVariables int, hallucinatorURL url.URL, ollamaAddress string, ollamaModel string, ollamaRequestTimeOut time.Duration, aiTemperature float64, aiSeed int, statistics *statistics.Statistics, ) *Hallucinator
NewHallucinator creates a new Hallucinator instance.
func (*Hallucinator) AppendHallucination ¶ added in v0.3.2
func (h *Hallucinator) AppendHallucination(ctx context.Context, hallucination Hallucination)
AppendHallucination appends a hallucination to the list of hallucinations.
func (*Hallucinator) CleanHallucinations ¶ added in v0.3.2
func (h *Hallucinator) CleanHallucinations(ctx context.Context)
CleanHallucinations cleans the list of hallucinations and removes hallucinations with requestCount 0.
func (*Hallucinator) DecreaseHallucinationRequestCount ¶
func (h *Hallucinator) DecreaseHallucinationRequestCount(ctx context.Context, id int)
DecreaseHallucinationRequestCount decreases the request count of a hallucination by 1.
func (*Hallucinator) GenerateHallucination ¶ added in v0.3.2
func (h *Hallucinator) GenerateHallucination(ctx context.Context) (Hallucination, error)
GenerateHallucination generates a hallucination from the Ollama API.
func (*Hallucinator) GetHallucinationCount ¶
func (h *Hallucinator) GetHallucinationCount(ctx context.Context) int
GetHallucinationCount returns the current hallucination count.
func (*Hallucinator) PopHallucination ¶
func (h *Hallucinator) PopHallucination(ctx context.Context) string
PopHallucination withdraws the first hallucination from the list of hallucinations.
func (*Hallucinator) PopRandomHallucination ¶
func (h *Hallucinator) PopRandomHallucination(ctx context.Context) string
PopRandomHallucination withdraws a random hallucination from the list of hallucinations.
type OllamaMessage ¶
OllamaMessage is the message structure for the Ollama API.
type OllamaResponse ¶
type OllamaResponse struct {
Model string `json:"model"`
CreatedAt string `json:"created_at"` //nolint: tagliatelle
Message OllamaMessage `json:"message"`
Done bool `json:"done"`
DoneReason string `json:"done_reason"` //nolint: tagliatelle
TotalDuration int `json:"total_duration"` //nolint: tagliatelle
LoadDuration int `json:"load_duration"` //nolint: tagliatelle
PromptEvalCount int `json:"prompt_eval_count"` //nolint: tagliatelle
EvalCount int `json:"eval_count"` //nolint: tagliatelle
EvalDuration int `json:"eval_duration"` //nolint: tagliatelle
}
OllamaResponse is the response structure for the Ollama API.