From 11b4e3e41087c3f8d2caac51ff8f7f0dc6025455 Mon Sep 17 00:00:00 2001 From: Ted Benson Date: Wed, 8 Nov 2023 09:15:16 -0500 Subject: [PATCH] Debugging tag --- src/api.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/api.py b/src/api.py index 44d25b0..7db8569 100644 --- a/src/api.py +++ b/src/api.py @@ -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]: @@ -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)