[Feature Request]: Hop GUI API for plugins to ask the default AI provider
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- java
- Ambito
- ai, backend-api-design
Direzione di ricerca
Start with the existing HopGui.openAiAdvisorSession route in hop-ui and the extension-point lookup it uses, then read HopAiConfigSingleton, AiProviderLoader and AiChatFactory in hop-tech-ai. The work spans hop-ui (HopAi, AiPrompt, AiAnswer), hop-core (IHopAiService) and hop-tech-ai (HopAiServiceImpl, HopGuiAiServiceLookup); first settle the lookup contract and how isAvailable stays cheap. Done when a plugin can call HopAi.askAsync against the default provider with masking and full-XML rules enforced, and Hop Web's UI-thread callback path is checked.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What would you like to happen?
Why
A plugin that wants to ask the configured AI provider a simple question has to use too much Java reflection.
This came up while prototyping a button in the Git commit perspective that generates the commit message from the changes. The feature only concerns the Git plugin, but hop-tech-ai is optional and has its own class loader, so the Git plugin cannot compile against it. To send one prompt, it has to find the AI plugin in the registry, get its class loader, and call these by name:
HopAiLegacyConfigMigrator.migrateHopAiConfigSingleton.getConfig, thenisAiEnabled,getDefaultProviderNameandisAllowSendFullXmlAiTextUtil.redactSecretsAiProviderLoader.loadAiChatFactory.generate
This has several drawbacks:
- A rename in
hop-tech-aionly fails at runtime. - Each plugin has to apply the AI privacy rules itself (enabled switch, secret masking, "Allow sending full XML"), and can forget one.
- Each plugin repeats the same work: thread context class loader, background thread, return to the UI thread, clean-up of the answer.
Proposal
A small API in Hop GUI to know whether AI can be used and to ask it something, with no reflection in the calling plugin.
if (HopAi.isAvailable(hopGui)) {
AiPrompt prompt =
AiPrompt.builder()
.system(SYSTEM_PROMPT)
.data("changed_files", files) // secrets masked, block tags neutralized
.data("diff", textDiff, 60_000) // with a maximum size
.hopXml("pipeline_diff", xmlDiff, summary) // summary when full XML is not allowed
.build();
HopAi.askAsync(
hopGui,
prompt,
answer -> wMessage.setText(answer.text()), // called on the UI thread
error -> showStatus(error.getMessage()));
}
hop-ui: the entry point for plugins
public final class HopAi {
/** True when the AI plugin is installed and enabled, with a valid default provider. */
public static boolean isAvailable(HopGui hopGui);
/** Call outside the UI thread. */
public static AiAnswer ask(HopGui hopGui, AiPrompt prompt) throws HopException;
/** Runs in the background, and calls back on the UI thread. */
public static void askAsync(
HopGui hopGui,
AiPrompt prompt,
Consumer<AiAnswer> onAnswer,
Consumer<HopException> onError);
}
hop-core: the contract, without any model library type
public interface IHopAiService {
boolean isAvailable(IHopMetadataProvider metadata);
AiAnswer ask(AiPrompt prompt, IVariables variables, IHopMetadataProvider metadata)
throws HopException;
}
public record AiAnswer(
String text, Integer inputTokens, Integer outputTokens, long durationMs) {}
AiPrompt is a plain builder: system, data, hopXml, and the optional provider(name) and jsonOnly().
hop-tech-ai: the implementation
HopAiServiceImpl reads the configuration, loads the provider, applies the privacy rules and calls the model. HopAi gets it through a new extension point, HopGuiAiServiceLookup, the same way HopGui.openAiAdvisorSession reaches the plugin today. After that lookup, calls are normal Java calls, checked at compile time.
Behavior
isAvailablereturns false without the AI plugin. It makes no network call and stays cheap, so a plugin can call it when it refreshes its toolbar. Availability can change during a session (option, default provider, project).askthrows aHopExceptionwith a message for the user when AI cannot be used, for example if the provider was removed in the meantime.- The privacy rules are in the implementation, so a plugin cannot bypass them:
datais always masked, andhopXmlonly sends its content with "Allow sending full XML". - Model reasoning (
<think>) and a surrounding code block are removed from the answer. - The default AI provider is used unless
provider(name)is set.
Out of scope for a first version
- Streaming and conversation history.
- Cancellation:
AiChatFactorycannot interrupt a request today. LanguageModelChatAiProviderSupport, which merges a provider configuration and does not ask the model anything.
To check
Hop Web: calling back on the UI thread from a background thread may need RAP server push.
Issue Priority
Priority: 3
Issue Component
Component: AI
- Lingua principale
- Java
- Stelle
- 1.6k
- Fork
- 499
- Merge medio
- 1g 5h
- PR unite (30g)
- 316
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/hop
-
Beam P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
awaiting triage Hop Gui P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
apache/hop#9325 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
awaiting triage Documentation P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
awaiting triage Documentation P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
awaiting triage Documentation P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
CI: LFC/ANTLR caches still use the old lfc/ paths, so the ANTLR jar is downloaded on every runForse già presa @NicoBiernat l’ha presa oggi. Apertabug CI
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
lf-lang/reactor-uc#443 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
Card-Forge/forge#13128 ·
I maintainer di solito rispondono entro 1 giorno
-
client documentation
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
ClickHouse/clickhouse-java#3469 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno