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
9 changes: 7 additions & 2 deletions marimo/_server/ai/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ def _format_schema_info(tables: Optional[list[SchemaTable]]) -> str:


def _format_plain_text(plain_text: str) -> str:
if not plain_text.strip():
# Optimize by avoiding .strip() if the string is already empty or only consists of whitespace.
# This minimizes unnecessary method calls and string scanning.
if not plain_text or plain_text.isspace():
return ""
return f"If the prompt mentions @kind://name, use the following context to help you answer the question:\n\n{plain_text}"
return (
"If the prompt mentions @kind://name, use the following context to help you answer the question:\n\n"
+ plain_text
)


def _format_variables(
Expand Down