Interface Session
- All Superinterfaces:
AutoCloseable
A session is created from Profile.chatSession(Conversation) or
Profile.chatSession(Conversation, boolean). Each session call sends
the same conversation ID to DBMS_CLOUD_AI.GENERATE so later prompts
can use prior conversation context.
Closing a session does not close the SelectAI client, the
Profile, or the underlying JDBC connection. If the session was
created with deleteOnClose=true, closing the session drops the
associated conversation.
-
Method Summary
Modifier and TypeMethodDescriptionSends the prompt as a chat-style request using the session conversation.voidclose()Closes this session.explainsql(String prompt) Generates SQL and returns a natural-language explanation using the session conversation.Generates and runs SQL, then asks the model to narrate the result using the session conversation.Generates SQL from the prompt and runs it using the session conversation.showprompt(String prompt) Returns the augmented prompt that Select AI would send to the provider using the session conversation.Generates SQL from the prompt without running it using the session conversation.
-
Method Details
-
chat
Sends the prompt as a chat-style request using the session conversation.For a complete runnable sample source, see ChatSessionProfileSample source.
- Parameters:
prompt- natural language prompt- Returns:
- chat response
- Throws:
IllegalArgumentException- whenpromptis null or blankIllegalStateException- when this Session is already closedSelectAIException- when generation fails
-
narrate
Generates and runs SQL, then asks the model to narrate the result using the session conversation.For a complete runnable sample source, see SessionNarrateSample source.
- Parameters:
prompt- natural language prompt- Returns:
- narrative response
- Throws:
IllegalArgumentException- whenpromptis null or blankIllegalStateException- when this Session is already closedSelectAIException- when generation fails
-
runsql
Generates SQL from the prompt and runs it using the session conversation.For a complete runnable sample source, see SessionRunSqlSample source.
- Parameters:
prompt- natural language prompt- Returns:
- generated SQL execution result/content
- Throws:
IllegalArgumentException- whenpromptis null or blankIllegalStateException- when this Session is already closedSelectAIException- when generation fails
-
explainsql
Generates SQL and returns a natural-language explanation using the session conversation.For a complete runnable sample source, see SessionExplainSqlSample source.
- Parameters:
prompt- natural language prompt- Returns:
- explanation of generated SQL
- Throws:
IllegalArgumentException- whenpromptis null or blankIllegalStateException- when this Session is already closedSelectAIException- when generation fails
-
showsql
Generates SQL from the prompt without running it using the session conversation.For a complete runnable sample source, see SessionShowSqlSample source.
- Parameters:
prompt- natural language prompt- Returns:
- generated SQL text
- Throws:
IllegalArgumentException- whenpromptis null or blankIllegalStateException- when this Session is already closedSelectAIException- when generation fails
-
showprompt
Returns the augmented prompt that Select AI would send to the provider using the session conversation.For a complete runnable sample source, see SessionShowPromptSample source.
- Parameters:
prompt- natural language prompt- Returns:
- rewritten/provider-facing prompt
- Throws:
IllegalArgumentException- whenpromptis null or blankIllegalStateException- when this Session is already closedSelectAIException- when generation fails
-
close
Closes this session.This does not close the SDK client or JDBC connection. When the session was created with
deleteOnClose=true, this method drops the associated conversation. Calling this method more than once has no additional effect. For a complete runnable sample source, see SessionCloseSample source.- Specified by:
closein interfaceAutoCloseable- Throws:
SelectAIException- when delete-on-close conversation cleanup fails
-