Skip to content

Instantly share code, notes, and snippets.

@sebdelsol
Created May 7, 2025 15:13
Show Gist options
  • Save sebdelsol/84a787fec4f00feb421fdf4c823cc664 to your computer and use it in GitHub Desktop.
Save sebdelsol/84a787fec4f00feb421fdf4c823cc664 to your computer and use it in GitHub Desktop.
[assistant.koplugin] configuration.lua for gemini
local GEMINI_API_KEY = "here is my key"
local MY_LANGUAGE = "English"
local CONFIGURATION = {
-- Choose your preferred AI provider: "anthropic", "openai", "gemini", "openrouter", "deepseek" or "ollama"
provider = "gemini",
-- Provider-specific settings
provider_settings = {
anthropic = {
model = "claude-3-5-haiku-latest", -- model list: https://docs.anthropic.com/en/docs/about-claude/models
base_url = "https://api.anthropic.com/v1/messages",
api_key = "your-anthropic-api-key",
additional_parameters = {
anthropic_version = "2023-06-01", -- api version list: https://docs.anthropic.com/en/api/versioning
max_tokens = 4096
}
},
openai = {
model = "gpt-4o-mini", -- model list: https://platform.openai.com/docs/models
base_url = "https://api.openai.com/v1/chat/completions",
api_key = "your-openai-api-key",
additional_parameters = {
temperature = 0.7,
max_tokens = 4096
}
},
gemini = {
model = "gemini-2.0-flash-001", -- model list: https://ai.google.dev/gemini-api/docs/models/gemini , ex: gemini-1.5-pro-latest , gemini-2.0-flash-001
base_url = "https://generativelanguage.googleapis.com/v1beta/models/",
api_key = GEMINI_API_KEY,
additional_parameters = {
temperature = 0.7,
max_tokens = 4096
}
},
openrouter = {
model = "google/gemini-2.0-flash-001", -- model list: https://openrouter.ai/models?order=top-weekly
base_url = "https://openrouter.ai/api/v1/chat/completions",
api_key = "your-openrouter-api-key",
additional_parameters = {
temperature = 0.7,
max_tokens = 4096
}
},
deepseek = {
model = "deepseek-chat",
base_url = "https://api.deepseek.com/v1/chat/completions",
api_key = "your-deepseek-api-key",
additional_parameters = {
temperature = 0.7,
max_tokens = 4096
}
},
ollama = {
model = "your-preferred-model", -- model list: https://ollama.com/library
base_url = "your-ollama-api-endpoint", -- ex: "https://ollama.example.com/api/chat"
api_key = "ollama",
additional_parameters = { }
},
},
-- Optional features, replace each "Turkish" with your desired language
features = {
hide_highlighted_text = false, -- Set to true to hide the highlighted text at the top
hide_long_highlights = true, -- Hide highlighted text if longer than threshold
long_highlight_threshold = 500, -- Number of characters considered "long"
max_display_user_prompt_length = 100, -- Maximum number of characters of user_prompt to show in result window (0 or nil for no limit)
system_prompt = "You are a helpful assistant that provides clear explanations.", -- Custom system prompt for the AI ("Ask" button) to override the default, to disable set to nil
refresh_screen_after_displaying_results = true, -- Set to true to refresh the screen after displaying the results
show_dictionary_button_in_main_popup = true, -- Set to true to show the dictionary button in the main popup
dictionary_translate_to = "tr-TR", -- Set to the desired language code for the dictionary, nil to hide it
show_dictionary_button_in_dictionary_popup = true, -- Set to true to show the Dictionary (AI) button in the dictionary popup
-- Custom prompts for the AI (text = button text in the UI). system-prompt defaults to "You are a helpful assistant." if not set.
--You can use {author} and {title} variables in the user_prompt,
--and {highlight} variable for the highlighted text otherwise its appended to the user_prompt automatically.
prompts = {
translate = {
text = "Translate",
order = 1,
system_prompt = "You are a helpful translation assistant. Provide direct translations without additional commentary.",
user_prompt = "Please translate the following text to " .. MY_LANGUAGE .. ": {highlight}",
show_on_main_popup = true -- Show the button in main popup
},
simplify = {
text = "Simplify",
order = 2,
system_prompt = "You are a helpful assistant that provides clear explanations.",
user_prompt = "Please simplify the following text in its own language: {highlight}",
show_on_main_popup = false -- Show the button in main popup
},
explain = {
text = "Explain",
order = 3,
system_prompt = "You are a helpful assistant that explains complex topics clearly and concisely. Break down concepts into simple terms.",
user_prompt = "Please explain the following text. Answer in " .. MY_LANGUAGE ..": {highlight}",
show_on_main_popup = false -- Show the button in main popup
},
summarize = {
text = "Summarize",
order = 4,
system_prompt = "You are a summarization expert. Provide clear, concise summaries that capture the main points.",
user_prompt = "Please provide a concise summary of the following text in its own language: {highlight}",
show_on_main_popup = false -- Show the button in main popup
},
historical_context = {
text = "Historical Context",
order = 5,
system_prompt = "You are a historical context expert. Provide relevant historical background and connections.",
user_prompt = "Explain the historical context of this text. Answer in " .. MY_LANGUAGE .. ": {highlight}",
show_on_main_popup = false -- Show the button in main popup
},
key_points = {
text = "Key Points",
order = 6,
system_prompt = "You are a key points expert. Provide a concise list of key points from the text.",
user_prompt = "Please provide a concise list of key points from the following text. Answer in " .. MY_LANGUAGE .. ": {highlight}",
show_on_main_popup = false -- Show the button in main popup
},
ELI5 = {
text = "ELI5",
order = 7,
system_prompt = "You are an ELI5 expert. Provide simple, concise explanations for complex terms.",
user_prompt = "Please provide an ELI5 explanation. Answer in " .. MY_LANGUAGE .. ": {highlight}",
show_on_main_popup = false -- Show the button in main popup
},
grammar = {
text = "Grammar",
order = 8,
system_prompt = "You are a grammar expert.",
user_prompt = "Explain the grammar of the following text. Answer in " .. MY_LANGUAGE .. ": {highlight}",
show_on_main_popup = true -- Show the button in main popup
}
}
}
}
return CONFIGURATION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment