Package io.github.jbastgen.stemma.app.ai
Class AiService
java.lang.Object
io.github.jbastgen.stemma.app.ai.AiService
The one door to AI services. Every AI feature of Stemma asks here; this class enforces the settings (switched off,
local only), cleans and cuts the prompt (
PromptGuard), picks the provider, repeats a failed try, and runs the
request on a virtual thread so the user interface never waits.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceWhere the API key of an account comes from (the credential store). -
Constructor Summary
ConstructorsConstructorDescriptionAiService(Supplier<AiConfig> config, AiService.ApiKeys keys, PromptTemplates templates) -
Method Summary
Modifier and TypeMethodDescriptionSendsprompt(cleaned and cut as configured) and returns at once; the answer comes with the call.Likeask(String)for a request about the repository inrepository: a tool on this computer runs in that folder unless the settings name another working folder.config()The settings in effect now.booleanenabled()Whether AI is switched on.The prompt templates.test()A short request that shows whether the connection works.withConfig(Supplier<AiConfig> other) The same connection with other settings, for trying out settings that are not saved yet.
-
Constructor Details
-
AiService
- Parameters:
config- the current AI settings; asked for every request, so changes apply at oncekeys- where the API key of the configured account comes fromtemplates- the prompt templates
-
-
Method Details
-
withConfig
The same connection with other settings, for trying out settings that are not saved yet. -
config
The settings in effect now. -
enabled
public boolean enabled()Whether AI is switched on. -
templates
The prompt templates. -
test
A short request that shows whether the connection works. It sends no repository data. -
ask
Sendsprompt(cleaned and cut as configured) and returns at once; the answer comes with the call. -
ask
Likeask(String)for a request about the repository inrepository: a tool on this computer runs in that folder unless the settings name another working folder.
-