LLM response models for prompting and response validation

This commit is contained in:
2026-10-02 22:36:19 +02:00
parent 3b93c5988b
commit 3754b3e4a9
4 changed files with 136 additions and 53 deletions
+5 -5
View File
@@ -7,7 +7,7 @@ from photools3.llm_session import LlmSession
not LlmSession(system_prompt="").is_api_reachable(), reason="API not available"
)
def test_llm_session(llm_session, test_photo):
llm_session.system_prompt = "Return only JSON format: {'keywords': ['...']}"
llm_session.system_prompt = "Return only JSON format: {'text': '...'}"
result = llm_session.call(
prompt="keywords for the attached picture", photos=[test_photo]
)
@@ -21,7 +21,7 @@ def test_llm_session_captions_and_keywords(
llm_session_captions_and_keywords, test_photo
):
result = llm_session_captions_and_keywords.call(photos=[test_photo])
assert "caption" in result
assert "tags" in result
assert isinstance(result["caption"], str)
assert isinstance(result["tags"], list)
assert result.caption
assert result.tags
assert isinstance(result.caption, str)
assert isinstance(result.tags, list)