Class LlmClient
java.lang.Object
com.scivicslab.turingworkflow.plugins.llm.LlmClient
LLMサーバ/MCPゲートウェイへの問い合わせ を保持する素のオブジェクト。アクターとして動かすのは LlmActor の役目であり、
「アクターであること」はこのクラスの性質ではない(ActorSuffixAndOwnedActorRef_260722_oo01)。
Actor that calls an LLM service.
Two backends are supported:
- Direct REST (
submitDirect) — POSTs to/api/chat/submiton a quarkus-chat-ui instance and polls for the result. No MCP session required. - OpenAI-compatible (
callOpenAi) — Calls any vLLM / OpenAI-compatible/v1/chat/completionsendpoint via system curl.
Supported actions:
setDirectUrl— set the chat-ui base URL forsubmitDirectsubmitDirect— submit a prompt and poll for the resultsetOpenAiUrl— configure the OpenAI-compatible endpointsetSystemPrompt— set a system prompt prepended tocallOpenAirequestssetEnableThinking— enable/disable extended thinking (Qwen3 family)callOpenAi— call the OpenAI-compatible endpoint
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.scivicslab.pojoactor.action.ActionResultcallOpenAi(String args) Sends the given text to the configured OpenAI-compatible endpoint and returns the model's reply.com.scivicslab.pojoactor.action.ActionResultsetDirectUrl(String url) Sets the base URL for direct chat-ui REST API access.com.scivicslab.pojoactor.action.ActionResultsetEnableThinking(String args) Enables or disables extended thinking for Qwen3-family models (default: disabled).com.scivicslab.pojoactor.action.ActionResultsetOpenAiUrl(String args) com.scivicslab.pojoactor.action.ActionResultsetOpenAiUrl(String url, String model) Sets the endpoint and, when given, the model to ask for.voidsetOutputListener(Consumer<String> listener) Sets an output listener that will be called with status messages, LLM responses, and error notifications.com.scivicslab.pojoactor.action.ActionResultsetSystemPrompt(String args) Sets a system-level instruction prepended to everycallOpenAirequest.com.scivicslab.pojoactor.action.ActionResultsubmitDirect(String promptText) Submits a prompt directly to a chat-ui instance via its REST API.
-
Constructor Details
-
LlmClient
public LlmClient()
-
-
Method Details
-
setOutputListener
Sets an output listener that will be called with status messages, LLM responses, and error notifications.- Parameters:
listener- a consumer that receives output messages, ornullto disable
-
setDirectUrl
Sets the base URL for direct chat-ui REST API access.Expected argument: base URL string (e.g.,
"http://localhost:28006").- Parameters:
url- the chat-ui base URL- Returns:
- an
ActionResultindicating success or failure
-
setOpenAiUrl
Sets the endpoint and, when given, the model to ask for.- Parameters:
url- base URL of the OpenAI-compatible endpointmodel- model id to request, ornullto keep the current one- Returns:
- what was set
-
setOpenAiUrl
-
setSystemPrompt
Sets a system-level instruction prepended to everycallOpenAirequest. Pass an empty string to clear the system prompt.- Parameters:
args- the system prompt text- Returns:
- ActionResult indicating success
-
setEnableThinking
Enables or disables extended thinking for Qwen3-family models (default: disabled). When disabled,chat_template_kwargs: {enable_thinking: false}is added to the request.- Parameters:
args-"true"to enable,"false"(default) to disable- Returns:
- ActionResult indicating success
-
callOpenAi
Sends the given text to the configured OpenAI-compatible endpoint and returns the model's reply. Blocks until the response is complete (up to 5 minutes).Requires
setOpenAiUrl(java.lang.String, java.lang.String)to be called first.- Parameters:
args- the user prompt / content to send- Returns:
- ActionResult containing the model's reply on success
-
submitDirect
Submits a prompt directly to a chat-ui instance via its REST API. Blocks until the LLM response is complete.Expected argument: the prompt text as a plain string.
Flow: POST /api/chat/submit → poll GET /api/chat/status/{id} → GET /api/chat/result/{id}
- Parameters:
promptText- the prompt to send- Returns:
- an
ActionResultcontaining the LLM response on success
-