Package com.mindsdb.models
Class Mind
java.lang.Object
com.mindsdb.models.Mind
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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>
streamCompletion
(String message) Streams completion responses based on the provided message by interacting with the OpenAI client.toString()
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.
-
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 MindnewDatasources
- the new list of data sources associated with the MindnewModelName
- the new model name for the MindnewParameters
- the new parameters for the Mind as a JsonObjectnewProvider
- the new provider for the MindnewPromptTemplate
- the new prompt template for the Mind- Throws:
Exception
- if validation fails or if the update operation encounters an error
-
addDatasource
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
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
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
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
-