Skip to content

Commit a77119e

Browse files
committed
Move prompt upgrading to system_prompt function.
1 parent d705cf2 commit a77119e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

pkg-py/src/querychat/querychat.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,27 @@ def system_prompt(
168168
prompt_path = Path(__file__).parent / "prompt" / "prompt.md"
169169
prompt_text = prompt_path.read_text()
170170

171+
data_description_str: str | None = (
172+
data_description.read_text()
173+
if isinstance(data_description, Path)
174+
else data_description
175+
)
176+
177+
extra_instructions_str: str | None = (
178+
extra_instructions.read_text()
179+
if isinstance(extra_instructions, Path)
180+
else extra_instructions
181+
)
182+
171183
return chevron.render(
172184
prompt_text,
173185
{
174186
"db_engine": data_source.db_engine,
175187
"schema": data_source.get_schema(
176188
categorical_threshold=categorical_threshold,
177189
),
178-
"data_description": data_description,
179-
"extra_instructions": extra_instructions,
190+
"data_description": data_description_str,
191+
"extra_instructions": extra_instructions_str,
180192
},
181193
)
182194

@@ -291,18 +303,6 @@ def init(
291303
greeting.read_text() if isinstance(greeting, Path) else greeting
292304
)
293305

294-
data_description_str: str | None = (
295-
data_description.read_text()
296-
if isinstance(data_description, Path)
297-
else data_description
298-
)
299-
300-
extra_instructions_str: str | None = (
301-
extra_instructions.read_text()
302-
if isinstance(extra_instructions, Path)
303-
else extra_instructions
304-
)
305-
306306
# Create the system prompt, or use the override
307307
system_prompt_ = system_prompt_override or system_prompt(
308308
data_source_obj,

0 commit comments

Comments
 (0)