-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathprompt.py
More file actions
38 lines (30 loc) · 1.25 KB
/
prompt.py
File metadata and controls
38 lines (30 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
from abc import ABC, abstractmethod
from typing import Dict, List, Optional
from cozeloop.entities.prompt import Prompt, Message, PromptVariable
class PromptClient(ABC):
"""
Interface for PromptClient.
"""
@abstractmethod
def get_prompt(self, prompt_key: str, version: str = '', label: str = '') -> Optional[Prompt]:
"""
Get a prompt by prompt key and version.
:param prompt_key: A unique key for retrieving the prompt.
:param version: The version of the prompt. Defaults to empty, which represents fetching the latest version.
:param label: The label of the prompt. Defaults to empty.
:return: An instance of `entity.Prompt` if found, or None.
"""
@abstractmethod
def prompt_format(
self,
prompt: Prompt,
variables: Dict[str, PromptVariable]
) -> List[Message]:
"""
Format a prompt with variables.
:param prompt: Instance of the prompt to format.
:param variables: A dictionary of variables to use when formatting the prompt.
:return: A list of formatted messages (`entity.Message`) if successful, or None.
"""