java.lang.Object
com.scivicslab.turingworkflow.plugins.llm.LlmClient

public class LlmClient extends Object
LLMサーバ/MCPゲートウェイへの問い合わせ を保持する素のオブジェクト。アクターとして動かすのは LlmActor の役目であり、 「アクターであること」はこのクラスの性質ではない(ActorSuffixAndOwnedActorRef_260722_oo01)。 Actor that calls an LLM service.

Two backends are supported:

  • Direct REST (submitDirect) — POSTs to /api/chat/submit on a quarkus-chat-ui instance and polls for the result. No MCP session required.
  • OpenAI-compatible (callOpenAi) — Calls any vLLM / OpenAI-compatible /v1/chat/completions endpoint via system curl.

Supported actions:

  • setDirectUrl — set the chat-ui base URL for submitDirect
  • submitDirect — submit a prompt and poll for the result
  • setOpenAiUrl — configure the OpenAI-compatible endpoint
  • setSystemPrompt — set a system prompt prepended to callOpenAi requests
  • setEnableThinking — enable/disable extended thinking (Qwen3 family)
  • callOpenAi — call the OpenAI-compatible endpoint
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.scivicslab.pojoactor.action.ActionResult
    Sends the given text to the configured OpenAI-compatible endpoint and returns the model's reply.
    com.scivicslab.pojoactor.action.ActionResult
    Sets the base URL for direct chat-ui REST API access.
    com.scivicslab.pojoactor.action.ActionResult
    Enables or disables extended thinking for Qwen3-family models (default: disabled).
    com.scivicslab.pojoactor.action.ActionResult
     
    com.scivicslab.pojoactor.action.ActionResult
    setOpenAiUrl(String url, String model)
    Sets the endpoint and, when given, the model to ask for.
    void
    Sets an output listener that will be called with status messages, LLM responses, and error notifications.
    com.scivicslab.pojoactor.action.ActionResult
    Sets a system-level instruction prepended to every callOpenAi request.
    com.scivicslab.pojoactor.action.ActionResult
    submitDirect(String promptText)
    Submits a prompt directly to a chat-ui instance via its REST API.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LlmClient

      public LlmClient()
  • Method Details

    • setOutputListener

      public void setOutputListener(Consumer<String> listener)
      Sets an output listener that will be called with status messages, LLM responses, and error notifications.
      Parameters:
      listener - a consumer that receives output messages, or null to disable
    • setDirectUrl

      public com.scivicslab.pojoactor.action.ActionResult setDirectUrl(String url)
      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 ActionResult indicating success or failure
    • setOpenAiUrl

      public com.scivicslab.pojoactor.action.ActionResult setOpenAiUrl(String url, String model)
      Sets the endpoint and, when given, the model to ask for.
      Parameters:
      url - base URL of the OpenAI-compatible endpoint
      model - model id to request, or null to keep the current one
      Returns:
      what was set
    • setOpenAiUrl

      public com.scivicslab.pojoactor.action.ActionResult setOpenAiUrl(String args)
    • setSystemPrompt

      public com.scivicslab.pojoactor.action.ActionResult setSystemPrompt(String args)
      Sets a system-level instruction prepended to every callOpenAi request. Pass an empty string to clear the system prompt.
      Parameters:
      args - the system prompt text
      Returns:
      ActionResult indicating success
    • setEnableThinking

      public com.scivicslab.pojoactor.action.ActionResult setEnableThinking(String args)
      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

      public com.scivicslab.pojoactor.action.ActionResult callOpenAi(String args)
      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

      public com.scivicslab.pojoactor.action.ActionResult submitDirect(String promptText)
      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 ActionResult containing the LLM response on success