From c490cd47ec7beb50578020ac7c07ee7a5b0821a4 Mon Sep 17 00:00:00 2001 From: Rutger Cappendijk Date: Wed, 30 Aug 2023 14:02:07 +0200 Subject: [PATCH] updated documentation --- aleph_alpha_client/prompt_template.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/aleph_alpha_client/prompt_template.py b/aleph_alpha_client/prompt_template.py index 4d6f99e..167059d 100644 --- a/aleph_alpha_client/prompt_template.py +++ b/aleph_alpha_client/prompt_template.py @@ -62,12 +62,22 @@ def _join_character( def embed_prompt(self, prompt: Prompt) -> str: """Embeds a prompt in a prompt template - Adds whitespace between text items if there is no whitespace between them. In case of non-text prompt items, this embeds them into the end result. + Example: + >>> user_prompt = Prompt( + [ + Tokens.from_token_ids([1, 2, 3]), + Text.from_text("cool"), + Image.from_file(Path("path-to-image")), + ] + ) + >>> template = PromptTemplate("Question: {{user_prompt}}\\n Answer: ") + >>> prompt = template.to_prompt(user_prompt=template.embed_prompt(user_prompt)) + Parameters: - items: a sequence of items to embed in the prompt + prompt: prompt to embed in the template """ prompt_text = "" last_item = None