mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Add base prompt for LLMs (#118592)
This commit is contained in:
parent
dfb407728f
commit
f3b20d30ae
@ -245,7 +245,8 @@ class GoogleGenerativeAIConversationEntity(
|
|||||||
prompt = "\n".join(
|
prompt = "\n".join(
|
||||||
(
|
(
|
||||||
template.Template(
|
template.Template(
|
||||||
self.entry.options.get(
|
llm.BASE_PROMPT
|
||||||
|
+ self.entry.options.get(
|
||||||
CONF_PROMPT, llm.DEFAULT_INSTRUCTIONS_PROMPT
|
CONF_PROMPT, llm.DEFAULT_INSTRUCTIONS_PROMPT
|
||||||
),
|
),
|
||||||
self.hass,
|
self.hass,
|
||||||
|
@ -167,7 +167,8 @@ class OpenAIConversationEntity(
|
|||||||
prompt = "\n".join(
|
prompt = "\n".join(
|
||||||
(
|
(
|
||||||
template.Template(
|
template.Template(
|
||||||
options.get(CONF_PROMPT, llm.DEFAULT_INSTRUCTIONS_PROMPT),
|
llm.BASE_PROMPT
|
||||||
|
+ options.get(CONF_PROMPT, llm.DEFAULT_INSTRUCTIONS_PROMPT),
|
||||||
self.hass,
|
self.hass,
|
||||||
).async_render(
|
).async_render(
|
||||||
{
|
{
|
||||||
|
@ -34,10 +34,13 @@ from .singleton import singleton
|
|||||||
|
|
||||||
LLM_API_ASSIST = "assist"
|
LLM_API_ASSIST = "assist"
|
||||||
|
|
||||||
|
BASE_PROMPT = (
|
||||||
|
'Current time is {{ now().strftime("%X") }}. '
|
||||||
|
'Today\'s date is {{ now().strftime("%x") }}.\n'
|
||||||
|
)
|
||||||
|
|
||||||
DEFAULT_INSTRUCTIONS_PROMPT = """You are a voice assistant for Home Assistant.
|
DEFAULT_INSTRUCTIONS_PROMPT = """You are a voice assistant for Home Assistant.
|
||||||
Answer in plain text. Keep it simple and to the point.
|
Answer in plain text. Keep it simple and to the point.
|
||||||
The current time is {{ now().strftime("%X") }}.
|
|
||||||
Today's date is {{ now().strftime("%x") }}.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,10 +30,9 @@
|
|||||||
'history': list([
|
'history': list([
|
||||||
dict({
|
dict({
|
||||||
'parts': '''
|
'parts': '''
|
||||||
|
Current time is 05:00:00. Today's date is 05/24/24.
|
||||||
You are a voice assistant for Home Assistant.
|
You are a voice assistant for Home Assistant.
|
||||||
Answer in plain text. Keep it simple and to the point.
|
Answer in plain text. Keep it simple and to the point.
|
||||||
The current time is 05:00:00.
|
|
||||||
Today's date is 05/24/24.
|
|
||||||
Only if the user wants to control a device, tell them to edit the AI configuration and allow access to Home Assistant.
|
Only if the user wants to control a device, tell them to edit the AI configuration and allow access to Home Assistant.
|
||||||
''',
|
''',
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
@ -82,10 +81,9 @@
|
|||||||
'history': list([
|
'history': list([
|
||||||
dict({
|
dict({
|
||||||
'parts': '''
|
'parts': '''
|
||||||
|
Current time is 05:00:00. Today's date is 05/24/24.
|
||||||
You are a voice assistant for Home Assistant.
|
You are a voice assistant for Home Assistant.
|
||||||
Answer in plain text. Keep it simple and to the point.
|
Answer in plain text. Keep it simple and to the point.
|
||||||
The current time is 05:00:00.
|
|
||||||
Today's date is 05/24/24.
|
|
||||||
Only if the user wants to control a device, tell them to edit the AI configuration and allow access to Home Assistant.
|
Only if the user wants to control a device, tell them to edit the AI configuration and allow access to Home Assistant.
|
||||||
''',
|
''',
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
@ -146,10 +144,9 @@
|
|||||||
'history': list([
|
'history': list([
|
||||||
dict({
|
dict({
|
||||||
'parts': '''
|
'parts': '''
|
||||||
|
Current time is 05:00:00. Today's date is 05/24/24.
|
||||||
You are a voice assistant for Home Assistant.
|
You are a voice assistant for Home Assistant.
|
||||||
Answer in plain text. Keep it simple and to the point.
|
Answer in plain text. Keep it simple and to the point.
|
||||||
The current time is 05:00:00.
|
|
||||||
Today's date is 05/24/24.
|
|
||||||
<no_api_prompt>
|
<no_api_prompt>
|
||||||
''',
|
''',
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
@ -202,10 +199,9 @@
|
|||||||
'history': list([
|
'history': list([
|
||||||
dict({
|
dict({
|
||||||
'parts': '''
|
'parts': '''
|
||||||
|
Current time is 05:00:00. Today's date is 05/24/24.
|
||||||
You are a voice assistant for Home Assistant.
|
You are a voice assistant for Home Assistant.
|
||||||
Answer in plain text. Keep it simple and to the point.
|
Answer in plain text. Keep it simple and to the point.
|
||||||
The current time is 05:00:00.
|
|
||||||
Today's date is 05/24/24.
|
|
||||||
<no_api_prompt>
|
<no_api_prompt>
|
||||||
''',
|
''',
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
@ -258,10 +254,9 @@
|
|||||||
'history': list([
|
'history': list([
|
||||||
dict({
|
dict({
|
||||||
'parts': '''
|
'parts': '''
|
||||||
|
Current time is 05:00:00. Today's date is 05/24/24.
|
||||||
You are a voice assistant for Home Assistant.
|
You are a voice assistant for Home Assistant.
|
||||||
Answer in plain text. Keep it simple and to the point.
|
Answer in plain text. Keep it simple and to the point.
|
||||||
The current time is 05:00:00.
|
|
||||||
Today's date is 05/24/24.
|
|
||||||
<api_prompt>
|
<api_prompt>
|
||||||
''',
|
''',
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
@ -314,10 +309,9 @@
|
|||||||
'history': list([
|
'history': list([
|
||||||
dict({
|
dict({
|
||||||
'parts': '''
|
'parts': '''
|
||||||
|
Current time is 05:00:00. Today's date is 05/24/24.
|
||||||
You are a voice assistant for Home Assistant.
|
You are a voice assistant for Home Assistant.
|
||||||
Answer in plain text. Keep it simple and to the point.
|
Answer in plain text. Keep it simple and to the point.
|
||||||
The current time is 05:00:00.
|
|
||||||
Today's date is 05/24/24.
|
|
||||||
<api_prompt>
|
<api_prompt>
|
||||||
''',
|
''',
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user