Class Mind

java.lang.Object
com.mindsdb.models.Mind

public class Mind extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDatasource(String newDatasourceName)
    Adds a new data source to the Mind by sending a POST request to the server.
    completion(String message)
    Generates a completion response based on the provided message by interacting with the OpenAI client.
    void
    Configures the OpenAI client with the appropriate API key and base URL.
    void
    dropDatasource(String datasourceName)
    Removes a data source from the Mind by sending a DELETE request to the server.
    Stream<io.github.stefanbratanov.jvm.openai.ChatCompletionChunk>
    Streams completion responses based on the provided message by interacting with the OpenAI client.
     
    void
    update(String newName, List<String> newDatasources, String newModelName, com.google.gson.JsonObject newParameters, String newProvider, String newPromptTemplate)
    Updates the Mind with new parameters by creating a Mind object from the provided parameters and then calling the update method.

    Methods inherited from class java.lang.Object

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

    • Mind

      public Mind()
  • Method Details

    • update

      public void update(String newName, List<String> newDatasources, String newModelName, com.google.gson.JsonObject newParameters, String newProvider, String newPromptTemplate) throws Exception
      Updates the Mind with new parameters by creating a Mind object from the provided parameters and then calling the update method.
      Parameters:
      newName - the new name for the Mind
      newDatasources - the new list of data sources associated with the Mind
      newModelName - the new model name for the Mind
      newParameters - the new parameters for the Mind as a JsonObject
      newProvider - the new provider for the Mind
      newPromptTemplate - the new prompt template for the Mind
      Throws:
      Exception - if validation fails or if the update operation encounters an error
    • addDatasource

      public void addDatasource(String newDatasourceName) throws Exception
      Adds a new data source to the Mind by sending a POST request to the server. Validates the Mind's name before adding the new data source.
      Parameters:
      newDatasourceName - the name of the new data source to be added
      Throws:
      Exception - if the Mind's name is invalid or if the HTTP request encounters an error
    • dropDatasource

      public void dropDatasource(String datasourceName) throws Exception
      Removes a data source from the Mind by sending a DELETE request to the server. Validates the data source's name before performing the deletion.
      Parameters:
      datasourceName - the name of the data source to be removed
      Throws:
      Exception - if the data source name is invalid or if the HTTP request encounters an error
    • completion

      public String completion(String message) throws URISyntaxException
      Generates a completion response based on the provided message by interacting with the OpenAI client.
      Parameters:
      message - the input message for which a completion is requested
      Returns:
      the content of the completion response
      Throws:
      URISyntaxException - if the base URL for OpenAI is invalid
    • streamCompletion

      public Stream<io.github.stefanbratanov.jvm.openai.ChatCompletionChunk> streamCompletion(String message) throws URISyntaxException
      Streams completion responses based on the provided message by interacting with the OpenAI client.
      Parameters:
      message - the input message for which a completion is requested
      Returns:
      a stream of ChatCompletionChunk objects representing the streamed responses
      Throws:
      URISyntaxException - if the base URL for OpenAI is invalid
    • configureOpenAIClient

      public void configureOpenAIClient() throws URISyntaxException
      Configures the OpenAI client with the appropriate API key and base URL. This method initializes the OpenAI client only if it has not been configured yet.
      Throws:
      URISyntaxException - if the base URL for OpenAI is invalid
    • toString

      public String toString()
      Overrides:
      toString in class Object