Skip to content

Commit 059c127

Browse files
authored
Drop user prompt from LLMContext (home-assistant#146787)
1 parent 56aa809 commit 059c127

File tree

7 files changed

+12
-19
lines changed

7 files changed

+12
-19
lines changed

homeassistant/components/conversation/chat_log.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ async def async_update_llm_data(
395395
llm_context = llm.LLMContext(
396396
platform=conversing_domain,
397397
context=user_input.context,
398-
user_prompt=user_input.text,
399398
language=user_input.language,
400399
assistant=DOMAIN,
401400
device_id=user_input.device_id,

homeassistant/components/mcp_server/http.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ async def get(self, request: web.Request) -> web.StreamResponse:
8888
context = llm.LLMContext(
8989
platform=DOMAIN,
9090
context=self.context(request),
91-
user_prompt=None,
9291
language="*",
9392
assistant=conversation.DOMAIN,
9493
device_id=None,

homeassistant/helpers/llm.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,19 @@ class LLMContext:
160160
"""Tool input to be processed."""
161161

162162
platform: str
163+
"""Integration that is handling the LLM request."""
164+
163165
context: Context | None
164-
user_prompt: str | None
166+
"""Context of the LLM request."""
167+
165168
language: str | None
169+
"""Language of the LLM request."""
170+
166171
assistant: str | None
172+
"""Assistant domain that is handling the LLM request."""
173+
167174
device_id: str | None
175+
"""Device that is making the request."""
168176

169177

170178
@dataclass(slots=True)
@@ -302,7 +310,7 @@ async def async_call(
302310
platform=llm_context.platform,
303311
intent_type=self.name,
304312
slots=slots,
305-
text_input=llm_context.user_prompt,
313+
text_input=None,
306314
context=llm_context.context,
307315
language=llm_context.language,
308316
assistant=llm_context.assistant,

tests/components/anthropic/test_conversation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ def completion_result(*args, messages, **kwargs):
415415
llm.LLMContext(
416416
platform="anthropic",
417417
context=context,
418-
user_prompt="Please call the test function",
419418
language="en",
420419
assistant="conversation",
421420
device_id=None,
@@ -510,7 +509,6 @@ def completion_result(*args, messages, **kwargs):
510509
llm.LLMContext(
511510
platform="anthropic",
512511
context=context,
513-
user_prompt="Please call the test function",
514512
language="en",
515513
assistant="conversation",
516514
device_id=None,

tests/components/mcp/test_init.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def create_llm_context() -> llm.LLMContext:
5858
return llm.LLMContext(
5959
platform="test_platform",
6060
context=Context(),
61-
user_prompt="test_text",
6261
language="*",
6362
assistant="conversation",
6463
device_id=None,

tests/components/ollama/test_conversation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ def completion_result(*args, messages, **kwargs):
284284
llm.LLMContext(
285285
platform="ollama",
286286
context=context,
287-
user_prompt="Please call the test function",
288287
language="en",
289288
assistant="conversation",
290289
device_id=None,
@@ -369,7 +368,6 @@ def completion_result(*args, messages, **kwargs):
369368
llm.LLMContext(
370369
platform="ollama",
371370
context=context,
372-
user_prompt="Please call the test function",
373371
language="en",
374372
assistant="conversation",
375373
device_id=None,

tests/helpers/test_llm.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def llm_context() -> llm.LLMContext:
3636
return llm.LLMContext(
3737
platform="",
3838
context=None,
39-
user_prompt=None,
4039
language=None,
4140
assistant=None,
4241
device_id=None,
@@ -162,7 +161,6 @@ async def test_assist_api(
162161
llm_context = llm.LLMContext(
163162
platform="test_platform",
164163
context=test_context,
165-
user_prompt="test_text",
166164
language="*",
167165
assistant="conversation",
168166
device_id=None,
@@ -237,7 +235,7 @@ class MyIntentHandler(intent.IntentHandler):
237235
"area": {"value": "kitchen"},
238236
"floor": {"value": "ground_floor"},
239237
},
240-
text_input="test_text",
238+
text_input=None,
241239
context=test_context,
242240
language="*",
243241
assistant="conversation",
@@ -296,7 +294,7 @@ class MyIntentHandler(intent.IntentHandler):
296294
"preferred_area_id": {"value": area.id},
297295
"preferred_floor_id": {"value": floor.floor_id},
298296
},
299-
text_input="test_text",
297+
text_input=None,
300298
context=test_context,
301299
language="*",
302300
assistant="conversation",
@@ -412,7 +410,6 @@ async def test_assist_api_prompt(
412410
llm_context = llm.LLMContext(
413411
platform="test_platform",
414412
context=context,
415-
user_prompt="test_text",
416413
language="*",
417414
assistant="conversation",
418415
device_id=None,
@@ -760,7 +757,6 @@ async def test_script_tool(
760757
llm_context = llm.LLMContext(
761758
platform="test_platform",
762759
context=context,
763-
user_prompt="test_text",
764760
language="*",
765761
assistant="conversation",
766762
device_id=None,
@@ -961,7 +957,6 @@ async def test_script_tool_name(hass: HomeAssistant) -> None:
961957
llm_context = llm.LLMContext(
962958
platform="test_platform",
963959
context=context,
964-
user_prompt="test_text",
965960
language="*",
966961
assistant="conversation",
967962
device_id=None,
@@ -1241,7 +1236,6 @@ async def test_calendar_get_events_tool(hass: HomeAssistant) -> None:
12411236
llm_context = llm.LLMContext(
12421237
platform="test_platform",
12431238
context=context,
1244-
user_prompt="test_text",
12451239
language="*",
12461240
assistant="conversation",
12471241
device_id=None,
@@ -1344,7 +1338,6 @@ async def test_todo_get_items_tool(hass: HomeAssistant) -> None:
13441338
llm_context = llm.LLMContext(
13451339
platform="test_platform",
13461340
context=context,
1347-
user_prompt="test_text",
13481341
language="*",
13491342
assistant="conversation",
13501343
device_id=None,
@@ -1451,7 +1444,6 @@ async def test_no_tools_exposed(hass: HomeAssistant) -> None:
14511444
llm_context = llm.LLMContext(
14521445
platform="test_platform",
14531446
context=context,
1454-
user_prompt="test_text",
14551447
language="*",
14561448
assistant="conversation",
14571449
device_id=None,

0 commit comments

Comments
 (0)