Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 0 additions & 101 deletions tests/unittests/models/test_llm_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,107 +187,6 @@ def test_append_instructions_with_string_list_multiple_calls():
assert request.config.system_instruction == expected


def test_append_instructions_with_content():
"""Test that append_instructions works with types.Content (new behavior)."""
request = LlmRequest()

# Create a Content object
content = types.Content(
role='user', parts=[types.Part(text='This is content-based instruction')]
)

# Append content
request.append_instructions(content)

# Should be set as system_instruction
assert len(request.contents) == 0
assert request.config.system_instruction == content


def test_append_instructions_with_content_multiple_calls():
"""Test multiple calls to append_instructions with Content objects."""
request = LlmRequest()

# Add some existing content first
existing_content = types.Content(
role='user', parts=[types.Part(text='Existing content')]
)
request.contents.append(existing_content)

# First Content instruction
content1 = types.Content(
role='user', parts=[types.Part(text='First instruction')]
)
request.append_instructions(content1)

# Should be set as system_instruction, existing content unchanged
assert len(request.contents) == 1
assert request.contents[0] == existing_content
assert request.config.system_instruction == content1

# Second Content instruction
content2 = types.Content(
role='user', parts=[types.Part(text='Second instruction')]
)
request.append_instructions(content2)

# Second Content should be merged with first in system_instruction
assert len(request.contents) == 1
assert request.contents[0] == existing_content
assert isinstance(request.config.system_instruction, types.Content)
assert len(request.config.system_instruction.parts) == 2
assert request.config.system_instruction.parts[0].text == 'First instruction'
assert request.config.system_instruction.parts[1].text == 'Second instruction'


def test_append_instructions_with_content_multipart():
"""Test append_instructions with Content containing multiple parts."""
request = LlmRequest()

# Create Content with multiple parts (text and potentially files)
content = types.Content(
role='user',
parts=[
types.Part(text='Text instruction'),
types.Part(text='Additional text part'),
],
)

request.append_instructions(content)

assert len(request.contents) == 0
assert request.config.system_instruction == content
assert len(request.config.system_instruction.parts) == 2
assert request.config.system_instruction.parts[0].text == 'Text instruction'
assert (
request.config.system_instruction.parts[1].text == 'Additional text part'
)


def test_append_instructions_mixed_string_and_content():
"""Test mixing string list and Content instructions."""
request = LlmRequest()

# First add string instructions
request.append_instructions(['String instruction'])
assert request.config.system_instruction == 'String instruction'

# Then add Content instruction
content = types.Content(
role='user', parts=[types.Part(text='Content instruction')]
)
request.append_instructions(content)

# String and Content should be merged in system_instruction
assert len(request.contents) == 0
assert isinstance(request.config.system_instruction, types.Content)
assert len(request.config.system_instruction.parts) == 2
assert request.config.system_instruction.parts[0].text == 'String instruction'
assert (
request.config.system_instruction.parts[1].text == 'Content instruction'
)


def test_append_instructions_empty_string_list():
"""Test append_instructions with empty list of strings."""
request = LlmRequest()
Expand Down