types

package
v0.43.5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIChatSettings

type AIChatSettings struct {
	ApiKey   *string // the API key if available
	Provider string  // the provider like "ollama" or "openai"
}

AIChatSettings stores settings for AI chats

type AIEditor

type AIEditor struct {
	App          *AppContext     // the underlying application context
	ChatEditor   *tview.TextArea // the chat editor TextArea
	ChatHistory  *tview.List     // the chat history
	CreateButton *tview.Button   // the "create" button
	FileViewer   *tview.TextView // the viewer for file content
	InfoLeft     *tview.TextView // the last info

	OnCreateClick func() error                   // the callback that is executed then "create" button is "clicked"/"pressed"
	OnResetClick  func() error                   // the callback that is executed then "reset" button is "clicked"/"pressed"
	OnSendClick   func(chatMessage string) error // the callback that is executed then "send" button is "clicked"/"pressed"
	ProjectUrl    string                         // the URL of the new project, which is also the module name
	ResetButton   *tview.Button                  // the "reset" button
	Root          tview.Primitive                // the root element in the UI
	SendButton    *tview.Button                  // the "send" button
	Tree          *tview.TreeView                // the file tree
	TreeNodes     []*AIEditorFileTreeNode        // all current file tree nodes
	UI            *tview.Application             // the UI / App
	// contains filtered or unexported fields
}

AIEditor represents an AI editor / viewer

func NewAIEditor

func NewAIEditor(app *AppContext, projectUrl string) *AIEditor

NewAIEditor creates a new instance of an `AIEditor` as reference by needing an `AppContext` and the project URL / module name

func (*AIEditor) Run

func (e *AIEditor) Run() error

e.Run() runs the underlying UI as fullscreen application

func (*AIEditor) StopWith

func (e *AIEditor) StopWith(f func() error) error

func (*AIEditor) UpdateFileTree

func (e *AIEditor) UpdateFileTree(fileItems []AIEditorFileItem) []*AIEditorFileTreeNode

type AIEditorFileItem

type AIEditorFileItem struct {
	Content []byte // the content
	Name    string // the name/relative path of the file
}

AIEditorFileItem is a simple type to update the file tree view

type AIEditorFileTreeNode

type AIEditorFileTreeNode struct {
	Content  []byte                  // content
	Children []*AIEditorFileTreeNode // the children
	Name     string                  // the name/relative path of the file
	Node     *tview.TreeNode         // the node in the view
	Parent   *AIEditorFileTreeNode   // the parent
	Type     string                  // the type: `dir`, `file` or `root`
}

AIEditorFileTreeNode is a "real" element in the file tree

type AIPrompts

type AIPrompts struct {
	Prompt       string  // the prompt
	SystemPrompt *string // the system prompt, if defined
}

AIPrompts stores prompts for AI chats

type AliasesFile

type AliasesFile struct {
	Aliases map[string][]string `yaml:"aliases"` // one or more aliases and their sources
}

AliasesFile stores information of an `aliases.yaml` file from home folder

type AppContext

type AppContext struct {
	AliasesFile      AliasesFile  // aliases.yaml file in home folder
	AliasesFilePath  string       // custom file path of the `aliases.yaml` file from CLI flags
	Clipboard        Clipboard    // clipboard
	Cwd              string       // current working directory
	EnvFiles         []string     // one or more env files
	Environment      string       // the name of the environment
	ErrorOut         io.Writer    // error output
	GpmFile          GpmFile      // the gpm.y(a)ml file
	GpmRootPath      string       // custom app root path from CLI flags
	In               *os.File     // the input stream
	IsCI             bool         // indicates if app runs in CI environment like GitHub action or GitLab runner
	L                *log.Logger  // the logger to use
	Model            string       // custom model from CLI flags
	NoPreScript      bool         // if the command supports "pre scripts" from gpm.yaml file, the flag indicates not to use it, if `true`
	NoPostScript     bool         // if the command supports "post scripts" from gpm.yaml file, the flag indicates not to use it, if `true`
	NoScript         bool         // if the command supports scripts from gpm.yaml file, the flag indicates not to use it, if `true`
	NoSystemPrompt   bool         // do not use system prompt
	Ollama           bool         // use Ollama
	Out              io.Writer    // the output stream
	ProjectsFile     ProjectsFile // projects.yaml file in home folder
	ProjectsFilePath string       // custom file path of the `projects.yaml` file from CLI flags
	Prompt           string       // custom (AI) prompt
	SettingsFile     SettingsFile // settings.yaml file
	SettingsFilePath string       // custom settings file
	SystemPrompt     string       // custom system prompt
	Temperature      float32      // temperature value for AI chats from CLI flags
	Verbose          bool         // output verbose information
}

An AppContext contains all information for running this app

func (*AppContext) ChatWithAI

func (app *AppContext) ChatWithAI(prompt string, options ...ChatWithAIOption) (string, error)

ChatWithAI() - does a simple AI chat based on the current app settings

func (*AppContext) CreateAIChat

func (app *AppContext) CreateAIChat(options ...CreateAIChatOptions) (ChatAI, error)

app.CreateAIChat() - creates a new ChatAI instance based on the current settings

func (*AppContext) Debug

func (app *AppContext) Debug(v ...any) *AppContext

app.Debug() - writes debug information with the underlying logger

func (*AppContext) EnsureBinFolder

func (app *AppContext) EnsureBinFolder() (string, error)

app.EnsureBinFolder() - ensures and returns the path of central bin folder

func (*AppContext) EnsureFolder

func (app *AppContext) EnsureFolder(dir string) (string, error)

app.EnsureFolder() - ensures and returns the path of a specific folder

func (*AppContext) EnsureRootFolder

func (app *AppContext) EnsureRootFolder() (string, error)

app.EnsureRootFolder() - ensures the root directory for this app exists, and returns its path on success

func (*AppContext) FindSourceFiles added in v0.36.0

func (app *AppContext) FindSourceFiles(patterns ...string) ([]string, error)

app.FindSourceFiles() - returns list of sources files by using regex patterns or URLs

func (*AppContext) GetAIChatSettings

func (app *AppContext) GetAIChatSettings() (AIChatSettings, error)

app.GetAIChatSettings() - returns AI chat settings based on this app

func (*AppContext) GetAIPrompt

func (app *AppContext) GetAIPrompt(defaultPrompt string) string

app.GetAIPrompt() - returns the AI prompt based on the current app settings

func (*AppContext) GetAIPromptSettings

func (app *AppContext) GetAIPromptSettings(defaultPrompt string, defaultSystemPrompt string) AIPrompts

app.GetAIPromptSettings() - returns AI prompt settings

func (*AppContext) GetAITemperature added in v0.39.0

func (app *AppContext) GetAITemperature(defaultTemperature float32) float32

app.GetAITemperature() - returns AI temperature based on current settings

func (*AppContext) GetAliasesFilePath

func (app *AppContext) GetAliasesFilePath() (string, error)

app.GetAliasesFilePath() - returns the possible path of the aliases.yaml file

func (*AppContext) GetBinFolderPath

func (app *AppContext) GetBinFolderPath() (string, error)

app.GetBinFolderPath() - returns the possible path of a central bin folder

func (*AppContext) GetChromaSettings added in v0.41.0

func (app *AppContext) GetChromaSettings() *ChromaSettings

app.GetChromaSettings() - returns settings for terminal syntax highlighter

func (*AppContext) GetCurrentCompilerVersion

func (app *AppContext) GetCurrentCompilerVersion() (*version.Version, error)

app.GetCurrentCompilerVersion() - tries to detect the current Go compiler version that should be used

func (*AppContext) GetCurrentGitBranch

func (app *AppContext) GetCurrentGitBranch() (string, error)

app.GetCurrentGitBranch() - returns the name of the current branch using git command

func (*AppContext) GetDefaultAIChatModel added in v0.41.0

func (app *AppContext) GetDefaultAIChatModel() string

app.GetDefaultAIChatModel() - returns the name of the default AI chat model

func (*AppContext) GetDefaultAIChatTemperature added in v0.41.0

func (app *AppContext) GetDefaultAIChatTemperature() float32

app.GetDefaultAIChatTemperature() - returns the value of the default AI temperature value

func (*AppContext) GetDefaultSettingsFilePath added in v0.41.0

func (app *AppContext) GetDefaultSettingsFilePath() (string, error)

app.GetDefaultSettingsFilePath() - returns the possible paths of global / default settings.yaml file

func (*AppContext) GetEnvFilePaths

func (app *AppContext) GetEnvFilePaths() ([]string, error)

app.GetEnvFilePaths() - returns possible paths of .env* files

func (*AppContext) GetEnvValue added in v0.42.0

func (app *AppContext) GetEnvValue(name string) string

app.GetEnvValue() - returns value from environment variable

func (*AppContext) GetEnvironment

func (app *AppContext) GetEnvironment() string

app.GetEnvironment() - returns the name of the environment

func (*AppContext) GetFullPathOrDefault

func (app *AppContext) GetFullPathOrDefault(p string, d string) string

app.GetFullPathOrDefault() - returns full version of a path or a default if input is empty

func (*AppContext) GetGitBranches

func (app *AppContext) GetGitBranches() ([]string, error)

app.GetGitBranches() - returns the list of branches using git command

func (*AppContext) GetGitRemotes

func (app *AppContext) GetGitRemotes() ([]string, error)

app.GetGitRemotes() - returns the list of remotes using git command

func (*AppContext) GetGitTags

func (app *AppContext) GetGitTags() ([]string, error)

app.GetGitTags() - returns the list of tags using git command

func (*AppContext) GetGoModules

func (app *AppContext) GetGoModules() ([]GoModule, error)

app.GetGoModules() - returns the list of installed Go modules of current project

func (*AppContext) GetGpmFilePath

func (app *AppContext) GetGpmFilePath() (string, error)

app.GetAliasesFilePath() - returns the possible path of the gpm.yaml file

func (*AppContext) GetGpmFilesSection

func (app *AppContext) GetGpmFilesSection() []string

app.GetGpmFilesSection() - returns `Files` section in `gpm.yaml` files based on the current environment

func (*AppContext) GetModuleUrls

func (app *AppContext) GetModuleUrls(moduleNameOrUrl string) []string

app.GetModuleUrls() - returns the list of module urls based on the information from aliases.y(a)ml file if possible

func (*AppContext) GetName

func (app *AppContext) GetName() string

app.GetName() - returns the of the current app

func (*AppContext) GetProjectsFilePath

func (app *AppContext) GetProjectsFilePath() (string, error)

app.GetProjectsFilePath() - returns the possible path of the projects.yaml file

func (*AppContext) GetRootPath

func (app *AppContext) GetRootPath() (string, error)

app.GetRootPath() - returns the root directory for this app, usually inside the user's home directory

func (*AppContext) GetSettingsFilePaths added in v0.41.0

func (app *AppContext) GetSettingsFilePaths() ([]string, bool, error)

app.GetSettingsFilePaths() - returns the possible paths of settings.yaml files

func (*AppContext) GetShell added in v0.42.0

func (app *AppContext) GetShell() string

app.GetShell()- returns the name of the current shell

func (*AppContext) GetSystemAIPrompt

func (app *AppContext) GetSystemAIPrompt(defaultPrompt string) string

app.GetSystemAIPrompt() - returns the AI system prompt based on the current app settings

func (*AppContext) IsRunningInTests added in v0.43.2

func (app *AppContext) IsRunningInTests() bool

app.IsRunningInTests() - `true` if tests are running

func (*AppContext) ListFiles

func (app *AppContext) ListFiles() ([]string, error)

app.ListFiles() - Lists all files inside the current working directory based of the patterns from "files" section of gpm.yaml file.

func (*AppContext) LoadAliasesFileIfExist

func (app *AppContext) LoadAliasesFileIfExist() bool

app.LoadAliasesFileIfExist - Loads a gpm.y(a)ml file if it exists and return `true` if file has been loaded successfully.

func (*AppContext) LoadDataFrom

func (app *AppContext) LoadDataFrom(source string) ([]byte, error)

app.LoadDataFrom() - loads binary data from a source like local file system or web URL

func (*AppContext) LoadEnvFilesIfExist

func (app *AppContext) LoadEnvFilesIfExist()

app.LoadEnvFilesIfExist() - Loads .env* files if they exist and return `true` if file has been loaded successfully.

func (*AppContext) LoadFromInputIfAvailable added in v0.37.0

func (app *AppContext) LoadFromInputIfAvailable() (*[]byte, error)

app.LoadFromInputIfAvailable() - loads data from input stream of this app if available

func (*AppContext) LoadGpmFileIfExist

func (app *AppContext) LoadGpmFileIfExist() bool

app.LoadGpmFileIfExist() - Loads a gpm.y(a)ml file if it exists and return `true` if file has been loaded successfully.

func (*AppContext) LoadProjectsFileIfExist

func (app *AppContext) LoadProjectsFileIfExist() bool

app.LoadProjectsFileIfExist() - Loads an aliases.yaml file if it exists and return `true` if file has been loaded successfully.

func (*AppContext) LoadSettingsFileIfExist added in v0.41.0

func (app *AppContext) LoadSettingsFileIfExist()

app.LoadEnvFilesIfExist() - Loads .env* files if they exist and return `true` if file has been loaded successfully.

func (*AppContext) NewVersionManager

func (app *AppContext) NewVersionManager() *ProjectVersionManager

app.NewVersionManager() - creates a new `ProjectVersionManager` instance based on this application context

func (*AppContext) Read

func (app *AppContext) Read(p []byte) (int, error)

app.Read() - implementation for an io.Reader

func (*AppContext) ReadAllInputs

func (app *AppContext) ReadAllInputs(files ...string) ([]byte, error)

app.ReadAllInputs() - reads from all inputs (STDIN and files, in that order) and returns binary data

func (*AppContext) RunCurrentProject

func (app *AppContext) RunCurrentProject(additionalArgs ...string)

app.RunCurrentProject() - runs the current go project

func (*AppContext) RunScript

func (app *AppContext) RunScript(scriptName string, additionalArgs ...string)

app.RunScript() - runs a script defined in gpm.y(a)ml file

func (*AppContext) RunShellCommand

func (app *AppContext) RunShellCommand(cmd string)

app.RunShellCommand() - runs a shell command in app's context

func (*AppContext) RunShellCommandByArgs

func (app *AppContext) RunShellCommandByArgs(c string, a ...string)

app.RunShellCommandByArgs() - runs a shell command by arguments in app's context

func (*AppContext) TidyUp

func (app *AppContext) TidyUp(options ...TidyUpOptions)

app.TidyUp() - runs 'go mod tidy' for the current project (folder)

func (*AppContext) UpdateAliasesFile

func (app *AppContext) UpdateAliasesFile() error

app.UpdateAliasesFile() - Updates the aliases.yaml file in home folder.

func (*AppContext) UpdateProjectsFile

func (app *AppContext) UpdateProjectsFile() error

app.UpdateProjectsFile() - Updates the projects.yaml file in home folder.

func (*AppContext) Write

func (app *AppContext) Write(p []byte) (int, error)

app.Write() - implementation for an io.Writer

func (*AppContext) WriteAllInputsTo

func (app *AppContext) WriteAllInputsTo(w io.Writer, files ...string) (int64, error)

app.WriteAllInputsTo() - reads from all inputs (STDIN and files, in that order) to an io.Writer

func (*AppContext) WriteError

func (app *AppContext) WriteError(p []byte) (int, error)

app.WriteError() - writes to error output

func (*AppContext) WriteErrorString added in v0.43.0

func (app *AppContext) WriteErrorString(s string) (int, error)

app.WriteErrorString() - writes to error output

func (*AppContext) WriteString added in v0.43.0

func (app *AppContext) WriteString(s string) (int, error)

app.WriteString() - implementation for an io.StringWriter

type BumpProjectVersionOptions

type BumpProjectVersionOptions struct {
	Arguments *[]string // additional arguments for git command
	Breaking  *bool     // increase major part
	Feature   *bool     // increase minor part
	Fix       *bool     // increase patch part
	Force     *bool     // force bump even if latest version is newer
	Major     *int64    // if defined, the initial value for new major part
	Message   *string   // the custom git message
	Minor     *int64    // if defined, the initial value for minor part
	Patch     *int64    // if defined, the initial value for patch part
}

BumpProjectVersionOptions stores options for `Bump()“ method of `ProjectVersionManager“ instance

type ChatAI

type ChatAI interface {
	// ChatAI.AddToHistory() - adds an entry to history
	AddToHistory(role string, content string)
	// ChatAI.ClearHistory() - clears chat history
	ClearHistory()
	// ChatAI.DescribeImage() - describes an image without adding using history
	DescribeImage(message string, dataURI string) (DescribeImageResponse, error)
	// ChatAI.GetModel() - get the name of the chat model
	GetModel() string
	// ChatAI.GetMoreInfo() - returns additional information, if available
	GetMoreInfo() string
	// ChatAI.GetPromptSuffix() - returns additional suffix for an input prompt, if available
	GetPromptSuffix() string
	// ChatAI.GetProvider() - get the name of the chat provider
	GetProvider() string
	// ChatAI.SendMessage() - sends a new message
	// to the API for the current chat conversation
	SendMessage(message string, onUpdate ChatAIMessageChunkReceiver) error
	// ChatAI.SendPrompt() - sends a single completion prompt
	SendPrompt(prompt string, onUpdate ChatAIMessageChunkReceiver) error
	// ChatAI.SendMessage() - switches the model
	UpdateModel(modelName string)
	// ChatAI.UpdateSystem() - clears chat history and sets the
	// system prompt
	UpdateSystem(systemPromt string)
	// ChatAI.UpdateSystem() - sets up new temperature value
	UpdateTemperature(newValue float32)
	// WithJsonSchema() - sends a message with a JSON schema
	WithJsonSchema(message string, schemaName string, schema map[string]interface{}, onUpdate ChatAIMessageChunkReceiver) error
}

ChatAI describes an object that provides abstract methods to interaction with a chat API

type ChatAIMessageChunkReceiver

type ChatAIMessageChunkReceiver = func(messageChunk string) error

type ChatWithAIOption

type ChatWithAIOption struct {
	Model        *string  // custom model
	SystemPrompt *string  // custom system prompt
	Temperature  *float32 // custom temperature
}

ChatWithAIOption stores settings for `ChatWithAI()` method

type ChromaSettings added in v0.41.0

type ChromaSettings struct {
	Formatter string // name of the formatter
	Style     string // name of the style
	// contains filtered or unexported fields
}

ChromaSettings stores settings for syntax highlighted console output

func (*ChromaSettings) Highlight added in v0.41.0

func (cs *ChromaSettings) Highlight(s string, language string)

app.Highlight() - tries to output a string highlighted in the defined language

func (*ChromaSettings) HighlightMarkdown added in v0.41.1

func (cs *ChromaSettings) HighlightMarkdown(s string)

app.HighlightMarkdown() - tries to output a string highlighted in Markdown

type Clipboard added in v0.43.0

type Clipboard interface {
	// ReadText() - reads text from clipboard
	ReadText() (string, error)

	// WriteText() - writes text to clipboard
	WriteText(s string) error
}

Clipboard implements a minimal clipboard

type CreateAIChatOptions

type CreateAIChatOptions struct {
	Model        *string // custom model
	SystemPrompt *string // custom system prompt
	Temperature  *int    // custom temperature
}

CreateAIChatOptions stores settings for `CreateAIChat()` method

type DescribeImageResponse

type DescribeImageResponse struct {
	Description string `json:"description" yaml:"description"` // the long description for aria-description maybe
	Label       string `json:"label" yaml:"label"`             // the label for aria-label maybe
}

DescribeImageResponse stores the data of a response from an AI image description e.g.

type GenerateProjectStepsResponse

type GenerateProjectStepsResponse struct {
	// the final summary from the AI
	FinalSummary string `json:"final_summary,omitempty"`
	// The steps
	Steps []map[string]interface{} `json:"steps,omitempty"`
}

GenerateProjectStepsResponse stores the response of a AI chat request that stores the steps to generate and setup a project

type GetSettingOptions added in v0.41.0

type GetSettingOptions struct {
	DoNotTrimEnvValues *bool // `true` if not trimming env values
}

GetSettingOptions provides additional options for app.GetSetting() method

type GoModule

type GoModule struct {
	Indirect *bool   `json:"Indirect,omitempty"` // indirect module or not
	Path     *string `json:"Path,omitempty"`     // the path
	Version  *string `json:"Version,omitempty"`  // the version
}

OsvDevResponse stores information about a successful response from osv.dev API

type GpmFile

type GpmFile struct {
	Contributors []GpmFileContributor   `yaml:"contributors,omitempty"` // list of contributors
	Description  string                 `yaml:"description,omitempty"`  // the description
	DisplayName  string                 `yaml:"display_name,omitempty"` // the display name
	Donations    map[string]string      `yaml:"donations,omitempty"`    // one or more donation links
	Environment  map[string]string      `yaml:"environment,omitempty"`  // environment variables
	Files        []string               `yaml:"files,omitempty"`        // whitelist of file patterns which are used by pack command for example
	Homepage     string                 `yaml:"homepage,omitempty"`     // the homepage
	License      string                 `yaml:"license,omitempty"`      // the license
	Name         string                 `yaml:"name,omitempty"`         // the name
	Repositories []GpmFileRepository    `yaml:"repositories,omitempty"` // source code repository information
	Scripts      map[string]string      `yaml:"scripts,omitempty"`      // one or more scripts
	Settings     map[string]interface{} `yaml:"settings,omitempty"`     // custom settings
	// contains filtered or unexported fields
}

GpmFile stores all data of a gpm.y(a)ml file.

func LoadGpmFile

func LoadGpmFile(gpmFilePath string) (GpmFile, error)

LoadGpmFile() - Loads a gpm.yaml file via a file path

func (*GpmFile) GetEnvironmentSectionByEnvSafe added in v0.42.0

func (g *GpmFile) GetEnvironmentSectionByEnvSafe(envName string) map[string]string

GetEnvironmentSectionByEnvSafe() - will return environment specific `environment` section in `gpm.yaml` file, if exists, otherwise the default one

func (*GpmFile) GetFilesSectionByEnvSafe

func (g *GpmFile) GetFilesSectionByEnvSafe(envName string) []string

GetFilesSectionByEnvSafe() - will return environment specific `files` section in `gpm.yaml` file, if exists, otherwise the default one

func (*GpmFile) GetSettingsSectionByEnvSafe added in v0.41.0

func (g *GpmFile) GetSettingsSectionByEnvSafe(envName string) map[string]interface{}

GetSettingsSectionByEnvSafe() - will return environment specific `settings` section in `gpm.yaml` file, if exists, otherwise the default one

type GpmFileContributor

type GpmFileContributor struct {
	Homepage string `yaml:"homepage,omitempty"` // the homepage url
	Name     string `yaml:"name,omitempty"`     // the full name
	Role     string `yaml:"role,omitempty"`     // the role
}

GpmFileContributor is an item inside `Contributors` of a `GpmFile` instance

type GpmFileRepository

type GpmFileRepository struct {
	Name string `yaml:"name,omitempty"` // the full name
	Type string `yaml:"type,omitempty"` // the type
	Url  string `yaml:"url,omitempty"`  // the url
}

GpmFileRepository is an item inside `Repositories` of a `GpmFile` instance

type MemoryClipboard added in v0.43.0

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

MemoryClipboard stores clipboard data in memory

func (*MemoryClipboard) ReadText added in v0.43.0

func (dc *MemoryClipboard) ReadText() (string, error)

func (*MemoryClipboard) WriteText added in v0.43.0

func (dc *MemoryClipboard) WriteText(s string) error

type OllamaAIChat

type OllamaAIChat struct {
	Conversation []OllamaAIChatMessage // the conversation
	Model        string                // the current model
	SystemPrompt string                // the current system prompt
	Temperature  float32               // the current temperature
	Verbose      bool                  // running in verbose mode or not
}

OllamaAIChat is an implementation of ChatAI interface using local Ollama REST API

func (*OllamaAIChat) AddToHistory added in v0.36.0

func (c *OllamaAIChat) AddToHistory(role string, content string)

func (*OllamaAIChat) ClearHistory

func (c *OllamaAIChat) ClearHistory()

func (*OllamaAIChat) DescribeImage

func (c *OllamaAIChat) DescribeImage(message string, dataURI string) (DescribeImageResponse, error)

func (*OllamaAIChat) GetModel

func (c *OllamaAIChat) GetModel() string

func (*OllamaAIChat) GetMoreInfo

func (c *OllamaAIChat) GetMoreInfo() string

func (*OllamaAIChat) GetPromptSuffix

func (c *OllamaAIChat) GetPromptSuffix() string

func (*OllamaAIChat) GetProvider

func (c *OllamaAIChat) GetProvider() string

func (*OllamaAIChat) SendMessage

func (c *OllamaAIChat) SendMessage(message string, onUpdate ChatAIMessageChunkReceiver) error

func (*OllamaAIChat) SendPrompt

func (c *OllamaAIChat) SendPrompt(prompt string, onUpdate ChatAIMessageChunkReceiver) error

func (*OllamaAIChat) UpdateModel

func (c *OllamaAIChat) UpdateModel(modelName string)

func (*OllamaAIChat) UpdateSystem

func (c *OllamaAIChat) UpdateSystem(systemPrompt string)

func (*OllamaAIChat) UpdateTemperature

func (c *OllamaAIChat) UpdateTemperature(newValue float32)

func (*OllamaAIChat) WithJsonSchema

func (c *OllamaAIChat) WithJsonSchema(message string, schemaName string, schema map[string]interface{}, onUpdate ChatAIMessageChunkReceiver) error

type OllamaAIChatMessage

type OllamaAIChatMessage struct {
	Content string `json:"content,omitempty"` // the message content
	Role    string `json:"role,omitempty"`    // the role like user, assistant or system
}

OllamaAIChatMessage is an item inside OllamaAIChat.Conversation array

type OllamaApiChatCompletionResponse

type OllamaApiChatCompletionResponse struct {
	Message OllamaAIChatMessage `json:"message,omitempty"` // the message
}

OllamaApiResponse is the data of a successful chat conversation response

type OllamaApiCompletionResponse

type OllamaApiCompletionResponse struct {
	Response string `json:"response,omitempty"` // the message
}

OllamaApiCompletionResponse is the data of a successful completion response

type OllamaGenerateResponse

type OllamaGenerateResponse struct {
	Model    string `json:"model"`    // used model
	Response string `json:"response"` // the response
}

OllamaGenerateResponse is the response of a successful Ollama API call

type OpenAIChat

type OpenAIChat struct {
	ApiKey       string              // the API key to use
	Conversation []OpenAIChatMessage // the conversation
	Model        string              // the current model
	SystemPrompt string              // the current system prompt
	Temperature  float32             // the current temperature
	TotalTokens  int32               // number of total used tokens in this session
	Verbose      bool                // running in verbose mode or not
}

OpenAIChat is an implementation of ChatAI interface using remote ChatGPT REST API by OpenAI

func (*OpenAIChat) AddToHistory added in v0.36.0

func (c *OpenAIChat) AddToHistory(role string, content string)

func (*OpenAIChat) ClearHistory

func (c *OpenAIChat) ClearHistory()

func (*OpenAIChat) DescribeImage

func (c *OpenAIChat) DescribeImage(message string, dataURI string) (DescribeImageResponse, error)

func (*OpenAIChat) GetModel

func (c *OpenAIChat) GetModel() string

func (*OpenAIChat) GetMoreInfo

func (c *OpenAIChat) GetMoreInfo() string

func (*OpenAIChat) GetPromptSuffix

func (c *OpenAIChat) GetPromptSuffix() string

func (*OpenAIChat) GetProvider

func (c *OpenAIChat) GetProvider() string

func (*OpenAIChat) SendMessage

func (c *OpenAIChat) SendMessage(message string, onUpdate ChatAIMessageChunkReceiver) error

func (*OpenAIChat) SendPrompt

func (c *OpenAIChat) SendPrompt(prompt string, onUpdate ChatAIMessageChunkReceiver) error

func (*OpenAIChat) UpdateModel

func (c *OpenAIChat) UpdateModel(modelName string)

func (*OpenAIChat) UpdateSystem

func (c *OpenAIChat) UpdateSystem(systemPrompt string)

func (*OpenAIChat) UpdateTemperature

func (c *OpenAIChat) UpdateTemperature(newValue float32)

func (*OpenAIChat) WithJsonSchema

func (c *OpenAIChat) WithJsonSchema(message string, schemaName string, schema map[string]interface{}, onUpdate ChatAIMessageChunkReceiver) error

type OpenAIChatCompletionResponseV1

type OpenAIChatCompletionResponseV1 struct {
	Choices []OpenAIChatCompletionResponseV1Choice `json:"choices"` // list of choices
	Model   string                                 `json:"model"`   // used model
	Usage   OpenAIChatCompletionResponseV1Usage    `json:"usage"`   // the usage
}

OpenAIChatCompletionResponseV1 stores data of a successful OpenAI chat completion response API response (version 1)

type OpenAIChatCompletionResponseV1Choice

type OpenAIChatCompletionResponseV1Choice struct {
	Index   int32                                       `json:"index"`   // the zero-based index
	Message OpenAIChatCompletionResponseV1ChoiceMessage `json:"message"` // the message information
}

OpenAIChatCompletionResponseV1Choice is an item inside `choices` property of an `OpenAIChatCompletionResponseV1` object

type OpenAIChatCompletionResponseV1ChoiceMessage

type OpenAIChatCompletionResponseV1ChoiceMessage struct {
	Content string `json:"content"` // the message context
	Role    string `json:"role"`    // the role like 'user' or 'assistant'
}

OpenAIChatCompletionResponseV1ChoiceMessage contains data for `message` property of an `OpenAIChatCompletionResponseV1ChoiceMessage` object

type OpenAIChatCompletionResponseV1Usage

type OpenAIChatCompletionResponseV1Usage struct {
	CompletionTokens int32 `json:"completion_tokens"` // number of completion tokens
	PromptTokens     int32 `json:"prompt_tokens"`     // number of prompt tokens
	TotalTokens      int32 `json:"total_tokens"`      // number of total used tokens
}

OpenAIChatCompletionResponseV1Usage contains data for `usage` property of an `OpenAIChatCompletionResponseV1` object

type OpenAIChatMessage

type OpenAIChatMessage struct {
	Content string `json:"content,omitempty"` // the message content
	Role    string `json:"role,omitempty"`    // the role like user, assistant or system
}

OpenAIChatMessage is an item inside OpenAIChat.Conversation array

type OsvDevResponse

type OsvDevResponse struct {
	Vulnerabilities *[]OsvDevResponseVulnerabilityItem `json:"vulns,omitempty"` // list of vulnerabilities
}

OsvDevResponse stores information about a successful response from osv.dev API

type OsvDevResponseVulnerabilityItem

type OsvDevResponseVulnerabilityItem struct {
	DatabaseSpecific *OsvDevResponseVulnerabilityItemDataSpecificInfo `json:"database_specific,omitempty"` // database specific information
	Details          string                                           `json:"details,omitempty"`           // details
	Id               string                                           `json:"id,omitempty"`                // ID
	ModifiedDate     string                                           `json:"modified,omitempty"`          // modification date
	PublishedDate    string                                           `json:"published,omitempty"`         // publish date
	References       *[]OsvDevResponseVulnerabilityItemReference      `json:"references,omitempty"`        // list of references
	Severity         *[]OsvDevResponseVulnerabilitySeverityItem       `json:"severity,omitempty"`          // list of severities
	Summary          string                                           `json:"summary,omitempty"`           // summary
}

OsvDevResponseVulnerabilityItem represents an item in OsvDevResponse.Vulnerabilities array

func (*OsvDevResponseVulnerabilityItem) GetSeverityDisplayValues

func (v *OsvDevResponseVulnerabilityItem) GetSeverityDisplayValues() (string, int)

v.GetSeverityDisplayValues() - gets values for display the item while the first element is the display text for the console and the second one the sort value

func (*OsvDevResponseVulnerabilityItem) IsCritical

func (v *OsvDevResponseVulnerabilityItem) IsCritical() bool

v.IsCritical() - checks if this item is critical

func (*OsvDevResponseVulnerabilityItem) IsHigh

v.IsHigh() - checks if this item is high

func (*OsvDevResponseVulnerabilityItem) IsLow

v.IsLow() - checks if this item is low

func (*OsvDevResponseVulnerabilityItem) IsModerate

func (v *OsvDevResponseVulnerabilityItem) IsModerate() bool

v.IsModerate() - checks if this item is moderate

type OsvDevResponseVulnerabilityItemDataSpecificInfo

type OsvDevResponseVulnerabilityItemDataSpecificInfo struct {
	Severity string `json:"severity,omitempty"` // the severity
}

OsvDevResponseVulnerabilityItemDataSpecificInfo represents value in OsvDevResponseVulnerabilityItem.DatabaseSpecific property

type OsvDevResponseVulnerabilityItemReference

type OsvDevResponseVulnerabilityItemReference struct {
	Type string `json:"type,omitempty"` // the type
	Url  string `json:"url,omitempty"`  // the URL
}

OsvDevResponseVulnerabilityItemReference represents an item in OsvDevResponseVulnerabilityItem.References array

type OsvDevResponseVulnerabilitySeverityItem

type OsvDevResponseVulnerabilitySeverityItem struct {
	Score string `json:"score,omitempty"` // the score
	Type  string `json:"type,omitempty"`  // the type
}

OsvDevResponseVulnerabilitySeverityItem represents an item in OsvDevResponseVulnerabilityItem.v array

type ProjectVersionManager

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

ProjectVersionManager manages versions of a project based on Git tags

func (*ProjectVersionManager) Bump

func (pvm *ProjectVersionManager) Bump(options ...BumpProjectVersionOptions) (*version.Version, error)

pvm.Bump() - bumps the version of the current project, based on the current settings by default minor version is increased

func (*ProjectVersionManager) GetLatestVersion

func (pvm *ProjectVersionManager) GetLatestVersion() (*version.Version, error)

pvm.GetLatestVersion() - Returns the latest version based on the Git tags of the current repository or nil if not found.

func (*ProjectVersionManager) GetVersions

func (pvm *ProjectVersionManager) GetVersions() ([]*version.Version, error)

pvm.GetVersions() - Returns all versions represented by Git tags inside the current working directory.

type ProjectsFile

type ProjectsFile struct {
	Projects map[string]string `yaml:"projects"` // one or more projects and their sources
}

ProjectsFile stores information of a `projects.yaml` file from home folder

type ReactRenderer

type ReactRenderer struct {
	BodyClass       string                                 // the className for the body tag
	ContentClass    string                                 // the className for the content wrapper
	ExternalModules map[string]ReactRendererExternalModule // list of external modules
	JsModules       [][]byte                               // list of contents of JavaScript modules to include
	Jsx             [][]byte                               // list of contents of JSX modules to include
	Template        string                                 // the name of the custom template inside resources to use
	Vars            map[string]interface{}                 // variables to inject into the final HTML as JavaScript variables
}

ReactRenderer helps to render HTML output with JSX and React

func (*ReactRenderer) AddExternalEsmModule

func (rr *ReactRenderer) AddExternalEsmModule(name string, url string)

AddExternalEsmModule() - adds an external ESM module

func (*ReactRenderer) AddJavascriptTemplate

func (rr *ReactRenderer) AddJavascriptTemplate(name string) error

AddJavascriptTemplate() - adds a JavaScript template by name from resources

func (*ReactRenderer) AddJsxTemplate

func (rr *ReactRenderer) AddJsxTemplate(name string) error

AddJsxTemplate() - adds a JSX template by name from resources

func (*ReactRenderer) AddVars

func (rr *ReactRenderer) AddVars(varsToAdd map[string]interface{})

AddVars() - add one or more variable for the output HTML

func (*ReactRenderer) Render

func (rr *ReactRenderer) Render(name string) ([]byte, error)

Render() - renders the final HTML using a name

type ReactRendererExternalModule

type ReactRendererExternalModule struct {
	Type string // the type, like "module"
	Url  string // the URL
}

ReactRendererExternalModule describes an external module

type SettingsFile added in v0.41.0

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

SettingsFile handles a settings.yaml file

func (*SettingsFile) GetFloat32 added in v0.41.0

func (sf *SettingsFile) GetFloat32(name string, flagValue float32, defaultValue float32, options ...GetSettingOptions) float32

sf.GetFloat32() - returns a string value from settings via dot-notation

func (*SettingsFile) GetString added in v0.41.0

func (sf *SettingsFile) GetString(name string, flagValue string, defaultValue string, options ...GetSettingOptions) string

sf.GetString() - returns a string value from settings via dot-notation

type SystemClipboard added in v0.43.0

type SystemClipboard struct {
}

DefaultClipboard implements access to system clipboard

func (*SystemClipboard) ReadText added in v0.43.0

func (dc *SystemClipboard) ReadText() (string, error)

func (*SystemClipboard) WriteText added in v0.43.0

func (dc *SystemClipboard) WriteText(s string) error

type TidyUpOptions

type TidyUpOptions struct {
	Arguments *[]string // additional command line argumuments
	NoScript  *bool     // explicit value that indicates if no `tidy` script should be run
}

TidyUpOptions - options for app.TidyUp() method

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳