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
15 changes: 15 additions & 0 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ class GPT4PluginConfig(Config):
default_system_prompt: str = Field(
"", description="System prompt that will be prepended before every request"
)
tag_prompt_on_output: Optional[bool] = Field(
False,
description="Whether to tag the prompt used on the output block emitted. Can be used for debugging.",
)

@classmethod
def config_cls(cls) -> Type[Config]:
Expand Down Expand Up @@ -293,6 +297,17 @@ def _generate_with_retry() -> Any:
)

for output_block in output_blocks:
# For debugging, we may want to finish by creating a tag that contains the prompt.
if self.config.tag_prompt_on_output:
Tag.create(
self.client,
file_id=output_block.file_id,
block_id=output_block.id,
kind="debug",
name="prompt",
value={"messages": messages}
)

output_block.finish_stream()

usage_reports = self._calculate_usage(messages, output_texts, completion_id)
Expand Down