Skip to content

Commit f49155a

Browse files
authored
Merge pull request #48 from micr0-dev/feature/promptOverride
Allows for overriding the LLM prompt in the config
2 parents 8acb7be + 52a752d commit f49155a

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

example.config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ username = "your_bot_username" # Your Mastodon bot's username
1212
[llm]
1313
provider = "gemini" # or "ollama"
1414
ollama_model = "llava-phi3"
15+
prompt_override = "" # WARNING: This will override the prompt making the bot only generate alt-text in one language
1516

1617
[gemini]
1718
api_key = "your_gemini_api_key" # Replace with your Gemini API key, if you don't have one, you can get it from https://aistudio.google.com/app/apikey

locales.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type Localization struct {
1313

1414
var localizations map[string]Localization
1515

16+
var PromptOverrideState bool
17+
1618
func loadLocalizations() error {
1719
data, err := os.ReadFile("localizations.json")
1820
if err != nil {
@@ -35,6 +37,9 @@ func getLocalizedString(lang, key string, category string) string {
3537

3638
switch category {
3739
case "prompt":
40+
if PromptOverrideState {
41+
return config.LLM.PromptOverride
42+
}
3843
if value, ok := localization.Prompts[key]; ok {
3944
return value
4045
}

main.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ import (
3939
)
4040

4141
// Version of the bot
42-
43-
const Version = "1.4.3"
42+
const Version = "1.4.4"
4443

4544
// AsciiArt is the ASCII art for the bot
4645
const AsciiArt = ` _ _ _ ___ _
@@ -57,8 +56,9 @@ type Config struct {
5756
Username string `toml:"username"`
5857
} `toml:"server"`
5958
LLM struct {
60-
Provider string `toml:"provider"`
61-
OllamaModel string `toml:"ollama_model"`
59+
Provider string `toml:"provider"`
60+
OllamaModel string `toml:"ollama_model"`
61+
PromptOverride string `toml:"prompt_override"`
6262
} `toml:"llm"`
6363
Gemini struct {
6464
Model string `toml:"model"`
@@ -215,6 +215,14 @@ func main() {
215215
fmt.Printf("%s Mastodon Connection: %s\n", getStatusSymbol(true), config.Server.MastodonServer)
216216
fmt.Printf("%s Video/Audio Processing: %v\n", getStatusSymbol(videoAudioProcessingCapability), videoAudioProcessingCapability)
217217

218+
PromptOverrideState = config.LLM.PromptOverride != ""
219+
220+
if PromptOverrideState {
221+
fmt.Printf("%s Prompt Override: Set to \"%.30s...\"\n", getStatusSymbol(false), config.LLM.PromptOverride)
222+
} else {
223+
fmt.Printf("%s Default Prompts: %s\n", getStatusSymbol(true), "Loaded")
224+
}
225+
218226
// Set up Gemini AI model
219227
err = Setup(config.Gemini.APIKey)
220228
if err != nil {

0 commit comments

Comments
 (0)