Class ClaudeProvider

java.lang.Object
org.machanism.machai.ai.provider.claude.ClaudeProvider
All Implemented Interfaces:
Genai

public class ClaudeProvider extends Object implements Genai
Anthropic-backed implementation of MachAI's Genai abstraction.

This provider adapts the Anthropic Java SDK to MachAI's provider interface.

Since:
0.0.11
Author:
Viktor Tovstyi
  • Constructor Details

    • ClaudeProvider

      public ClaudeProvider()
  • Method Details

    • init

      public void init(Configurator config)
      Description copied from interface: Genai
      Initializes the provider with application configuration.
      Specified by:
      init in interface Genai
      Parameters:
      config - configuration source
    • prompt

      public void prompt(String text)
      Description copied from interface: Genai
      Adds a user prompt to the current session.
      Specified by:
      prompt in interface Genai
      Parameters:
      text - the prompt text
    • perform

      public String perform()
      Description copied from interface: Genai
      Executes the provider to produce a response based on the accumulated prompts and state.
      Specified by:
      perform in interface Genai
      Returns:
      the provider response
    • clear

      public void clear()
      Description copied from interface: Genai
      Clears any stored files and session/provider state.
      Specified by:
      clear in interface Genai
    • addTool

      public void addTool(String name, String description, ToolFunction function, String... paramsDesc)
      Description copied from interface: Genai
      Registers a custom tool function that the provider may invoke at runtime.

      The expected argument structure passed to function is provider-specific.

      Specified by:
      addTool in interface Genai
      Parameters:
      name - tool name (unique per provider instance)
      description - human-readable description of the tool
      function - function implementation; receives an argument array and returns a result
      paramsDesc - parameter descriptors (format is provider-specific)
    • instructions

      public void instructions(String instructions)
      Description copied from interface: Genai
      Sets system/session instructions for the current conversation.
      Specified by:
      instructions in interface Genai
      Parameters:
      instructions - instruction text
    • promptBundle

      public void promptBundle(ResourceBundle promptBundle)
    • inputsLog

      public void inputsLog(File inputsLog)
      Description copied from interface: Genai
      Enables logging of provider inputs to the given directory.
      Specified by:
      inputsLog in interface Genai
      Parameters:
      inputsLog - directory used for writing log files
    • setWorkingDir

      public void setWorkingDir(File workingDir)
      Description copied from interface: Genai
      Configures the working directory used for file and tool operations.
      Specified by:
      setWorkingDir in interface Genai
      Parameters:
      workingDir - the working directory
    • usage

      public Usage usage()
      Description copied from interface: Genai
      Returns token usage metrics for the most recent Genai.perform() invocation.
      Specified by:
      usage in interface Genai
      Returns:
      usage metrics; implementations may return zero values if not supported
    • embedding

      public List<Double> embedding(String text, long dimensions)
      Description copied from interface: Genai
      Computes an embedding vector for the provided text.
      Specified by:
      embedding in interface Genai
      Parameters:
      text - the input text
      dimensions - desired embedding dimensionality (provider-specific)
      Returns:
      the embedding vector