mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add no-API LLM prompt back to Google (#118082)
* Add no-API LLM prompt back * Use string join
This commit is contained in:
parent
86a24cc3b9
commit
c59d4f9bba
@ -181,8 +181,7 @@ async def google_generative_ai_config_option_schema(
|
||||
schema = {
|
||||
vol.Optional(
|
||||
CONF_PROMPT,
|
||||
description={"suggested_value": options.get(CONF_PROMPT)},
|
||||
default=DEFAULT_PROMPT,
|
||||
description={"suggested_value": options.get(CONF_PROMPT, DEFAULT_PROMPT)},
|
||||
): TemplateSelector(),
|
||||
vol.Optional(
|
||||
CONF_LLM_HASS_API,
|
||||
|
@ -205,15 +205,6 @@ class GoogleGenerativeAIConversationEntity(
|
||||
messages = [{}, {}]
|
||||
|
||||
try:
|
||||
prompt = template.Template(
|
||||
self.entry.options.get(CONF_PROMPT, DEFAULT_PROMPT), self.hass
|
||||
).async_render(
|
||||
{
|
||||
"ha_name": self.hass.config.location_name,
|
||||
},
|
||||
parse_result=False,
|
||||
)
|
||||
|
||||
if llm_api:
|
||||
empty_tool_input = llm.ToolInput(
|
||||
tool_name="",
|
||||
@ -226,9 +217,24 @@ class GoogleGenerativeAIConversationEntity(
|
||||
device_id=user_input.device_id,
|
||||
)
|
||||
|
||||
prompt = (
|
||||
await llm_api.async_get_api_prompt(empty_tool_input) + "\n" + prompt
|
||||
api_prompt = await llm_api.async_get_api_prompt(empty_tool_input)
|
||||
|
||||
else:
|
||||
api_prompt = llm.PROMPT_NO_API_CONFIGURED
|
||||
|
||||
prompt = "\n".join(
|
||||
(
|
||||
api_prompt,
|
||||
template.Template(
|
||||
self.entry.options.get(CONF_PROMPT, DEFAULT_PROMPT), self.hass
|
||||
).async_render(
|
||||
{
|
||||
"ha_name": self.hass.config.location_name,
|
||||
},
|
||||
parse_result=False,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
except TemplateError as err:
|
||||
LOGGER.error("Error rendering prompt: %s", err)
|
||||
|
@ -29,7 +29,10 @@
|
||||
dict({
|
||||
'history': list([
|
||||
dict({
|
||||
'parts': 'Answer in plain text. Keep it simple and to the point.',
|
||||
'parts': '''
|
||||
Only if the user wants to control a device, tell them to edit the AI configuration and allow access to Home Assistant.
|
||||
Answer in plain text. Keep it simple and to the point.
|
||||
''',
|
||||
'role': 'user',
|
||||
}),
|
||||
dict({
|
||||
@ -79,7 +82,10 @@
|
||||
dict({
|
||||
'history': list([
|
||||
dict({
|
||||
'parts': 'Answer in plain text. Keep it simple and to the point.',
|
||||
'parts': '''
|
||||
Only if the user wants to control a device, tell them to edit the AI configuration and allow access to Home Assistant.
|
||||
Answer in plain text. Keep it simple and to the point.
|
||||
''',
|
||||
'role': 'user',
|
||||
}),
|
||||
dict({
|
||||
|
Loading…
x
Reference in New Issue
Block a user