Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Cast prompt summary tests to ChatGPT
Abi Rajafc179dba9c20
diff --git a/backend/tests/test_prompt_summary.py b/backend/tests/test_prompt_summary.pyindex 6ee5927d..644540eb 100644--- a/backend/tests/test_prompt_summary.py+++ b/backend/tests/test_prompt_summary.py@@ -1,5 +1,9 @@import ioimport sys+from typing import cast++from openai.types.chat import ChatCompletionMessageParam+from utils import format_prompt_summary, print_prompt_summary@@ -37,7 +41,7 @@ def test_print_prompt_summary():captured_output = io.StringIO()sys.stdout = captured_output- print_prompt_summary(messages)+ print_prompt_summary(cast(list[ChatCompletionMessageParam], messages))# Reset stdoutsys.stdout = sys.__stdout__@@ -62,7 +66,7 @@ def test_print_prompt_summary_long_content():captured_output = io.StringIO()sys.stdout = captured_output- print_prompt_summary(messages)+ print_prompt_summary(cast(list[ChatCompletionMessageParam], messages))# Reset stdoutsys.stdout = sys.__stdout__@@ -88,12 +92,16 @@ def test_format_prompt_summary_no_truncate():]# Test with truncation (default)- summary_truncated = format_prompt_summary(messages)+ summary_truncated = format_prompt_summary(+ cast(list[ChatCompletionMessageParam], messages)+ )assert "..." in summary_truncatedassert len(summary_truncated.split(": ", 1)[1]) <= 50 # Role + truncated content# Test without truncation- summary_full = format_prompt_summary(messages, truncate=False)+ summary_full = format_prompt_summary(+ cast(list[ChatCompletionMessageParam], messages), truncate=False+ )assert "..." not in summary_fullassert "shown in full" in summary_full@@ -107,7 +115,9 @@ def test_print_prompt_summary_no_truncate():captured_output = io.StringIO()sys.stdout = captured_output- print_prompt_summary(messages, truncate=False)+ print_prompt_summary(+ cast(list[ChatCompletionMessageParam], messages), truncate=False+ )# Reset stdoutsys.stdout = sys.__stdout__diff --git a/backend/utils.py b/backend/utils.pyindex 7ad7190b..719c0a1b 100644--- a/backend/utils.py+++ b/backend/utils.py@@ -12,7 +12,7 @@ def format_prompt_summary(prompt_messages: List[ChatCompletionMessageParam], truparts: list[str] = []for message in prompt_messages:role = message["role"]- content = message["content"]+ content = message.get("content")text = ""image_count = 0