4646 CONF_NUM_CTX ,
4747 CONF_PROMPT ,
4848 CONF_THINK ,
49+ DEFAULT_AI_TASK_NAME ,
50+ DEFAULT_CONVERSATION_NAME ,
4951 DEFAULT_KEEP_ALIVE ,
5052 DEFAULT_MAX_HISTORY ,
5153 DEFAULT_MODEL ,
@@ -74,7 +76,7 @@ class OllamaConfigFlow(ConfigFlow, domain=DOMAIN):
7476 """Handle a config flow for Ollama."""
7577
7678 VERSION = 3
77- MINOR_VERSION = 1
79+ MINOR_VERSION = 2
7880
7981 def __init__ (self ) -> None :
8082 """Initialize config flow."""
@@ -136,11 +138,14 @@ def async_get_supported_subentry_types(
136138 cls , config_entry : ConfigEntry
137139 ) -> dict [str , type [ConfigSubentryFlow ]]:
138140 """Return subentries supported by this integration."""
139- return {"conversation" : ConversationSubentryFlowHandler }
141+ return {
142+ "conversation" : OllamaSubentryFlowHandler ,
143+ "ai_task_data" : OllamaSubentryFlowHandler ,
144+ }
140145
141146
142- class ConversationSubentryFlowHandler (ConfigSubentryFlow ):
143- """Flow for managing conversation subentries."""
147+ class OllamaSubentryFlowHandler (ConfigSubentryFlow ):
148+ """Flow for managing Ollama subentries."""
144149
145150 def __init__ (self ) -> None :
146151 """Initialize the subentry flow."""
@@ -201,7 +206,11 @@ async def async_step_set_options(
201206 step_id = "set_options" ,
202207 data_schema = vol .Schema (
203208 ollama_config_option_schema (
204- self .hass , self ._is_new , options , models_to_list
209+ self .hass ,
210+ self ._is_new ,
211+ self ._subentry_type ,
212+ options ,
213+ models_to_list ,
205214 )
206215 ),
207216 )
@@ -300,13 +309,19 @@ async def async_step_finish(
300309def ollama_config_option_schema (
301310 hass : HomeAssistant ,
302311 is_new : bool ,
312+ subentry_type : str ,
303313 options : Mapping [str , Any ],
304314 models_to_list : list [SelectOptionDict ],
305315) -> dict :
306316 """Ollama options schema."""
307317 if is_new :
318+ if subentry_type == "ai_task_data" :
319+ default_name = DEFAULT_AI_TASK_NAME
320+ else :
321+ default_name = DEFAULT_CONVERSATION_NAME
322+
308323 schema : dict = {
309- vol .Required (CONF_NAME , default = "Ollama Conversation" ): str ,
324+ vol .Required (CONF_NAME , default = default_name ): str ,
310325 }
311326 else :
312327 schema = {}
@@ -319,29 +334,38 @@ def ollama_config_option_schema(
319334 ): SelectSelector (
320335 SelectSelectorConfig (options = models_to_list , custom_value = True )
321336 ),
322- vol .Optional (
323- CONF_PROMPT ,
324- description = {
325- "suggested_value" : options .get (
326- CONF_PROMPT , llm .DEFAULT_INSTRUCTIONS_PROMPT
327- )
328- },
329- ): TemplateSelector (),
330- vol .Optional (
331- CONF_LLM_HASS_API ,
332- description = {"suggested_value" : options .get (CONF_LLM_HASS_API )},
333- ): SelectSelector (
334- SelectSelectorConfig (
335- options = [
336- SelectOptionDict (
337- label = api .name ,
338- value = api .id ,
337+ }
338+ )
339+ if subentry_type == "conversation" :
340+ schema .update (
341+ {
342+ vol .Optional (
343+ CONF_PROMPT ,
344+ description = {
345+ "suggested_value" : options .get (
346+ CONF_PROMPT , llm .DEFAULT_INSTRUCTIONS_PROMPT
339347 )
340- for api in llm .async_get_apis (hass )
341- ],
342- multiple = True ,
343- )
344- ),
348+ },
349+ ): TemplateSelector (),
350+ vol .Optional (
351+ CONF_LLM_HASS_API ,
352+ description = {"suggested_value" : options .get (CONF_LLM_HASS_API )},
353+ ): SelectSelector (
354+ SelectSelectorConfig (
355+ options = [
356+ SelectOptionDict (
357+ label = api .name ,
358+ value = api .id ,
359+ )
360+ for api in llm .async_get_apis (hass )
361+ ],
362+ multiple = True ,
363+ )
364+ ),
365+ }
366+ )
367+ schema .update (
368+ {
345369 vol .Optional (
346370 CONF_NUM_CTX ,
347371 description = {
0 commit comments