mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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 = {
|
schema = {
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
CONF_PROMPT,
|
CONF_PROMPT,
|
||||||
description={"suggested_value": options.get(CONF_PROMPT)},
|
description={"suggested_value": options.get(CONF_PROMPT, DEFAULT_PROMPT)},
|
||||||
default=DEFAULT_PROMPT,
|
|
||||||
): TemplateSelector(),
|
): TemplateSelector(),
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
CONF_LLM_HASS_API,
|
CONF_LLM_HASS_API,
|
||||||
|
@ -205,15 +205,6 @@ class GoogleGenerativeAIConversationEntity(
|
|||||||
messages = [{}, {}]
|
messages = [{}, {}]
|
||||||
|
|
||||||
try:
|
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:
|
if llm_api:
|
||||||
empty_tool_input = llm.ToolInput(
|
empty_tool_input = llm.ToolInput(
|
||||||
tool_name="",
|
tool_name="",
|
||||||
@ -226,8 +217,23 @@ class GoogleGenerativeAIConversationEntity(
|
|||||||
device_id=user_input.device_id,
|
device_id=user_input.device_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
prompt = (
|
api_prompt = await llm_api.async_get_api_prompt(empty_tool_input)
|
||||||
await llm_api.async_get_api_prompt(empty_tool_input) + "\n" + prompt
|
|
||||||
|
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:
|
except TemplateError as err:
|
||||||
|
@ -29,7 +29,10 @@
|
|||||||
dict({
|
dict({
|
||||||
'history': list([
|
'history': list([
|
||||||
dict({
|
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',
|
'role': 'user',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
@ -79,7 +82,10 @@
|
|||||||
dict({
|
dict({
|
||||||
'history': list([
|
'history': list([
|
||||||
dict({
|
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',
|
'role': 'user',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user