Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rutger Cappendijk committed Aug 30, 2023
1 parent 2f1202d commit c490cd4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions aleph_alpha_client/prompt_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c490cd4

Please sign in to comment.