llama-index

Форк
0
87 строк · 2.9 Кб
1
from llama_index.legacy.prompts.base import PromptTemplate
2
from llama_index.legacy.prompts.prompt_type import PromptType
3

4
"""Single select prompt.
5

6
PromptTemplate to select one out of `num_choices` options provided in `context_list`,
7
given a query `query_str`.
8

9
Required template variables: `num_chunks`, `context_list`, `query_str`
10

11
"""
12
SingleSelectPrompt = PromptTemplate
13

14
"""Multiple select prompt.
15

16
PromptTemplate to select multiple candidates (up to `max_outputs`) out of `num_choices`
17
options provided in `context_list`, given a query `query_str`.
18

19
Required template variables: `num_chunks`, `context_list`, `query_str`,
20
    `max_outputs`
21
"""
22
MultiSelectPrompt = PromptTemplate
23

24

25
# single select
26
DEFAULT_SINGLE_SELECT_PROMPT_TMPL = (
27
    "Some choices are given below. It is provided in a numbered list "
28
    "(1 to {num_choices}), "
29
    "where each item in the list corresponds to a summary.\n"
30
    "---------------------\n"
31
    "{context_list}"
32
    "\n---------------------\n"
33
    "Using only the choices above and not prior knowledge, return "
34
    "the choice that is most relevant to the question: '{query_str}'\n"
35
)
36

37

38
DEFAULT_SINGLE_SELECT_PROMPT = PromptTemplate(
39
    template=DEFAULT_SINGLE_SELECT_PROMPT_TMPL, prompt_type=PromptType.SINGLE_SELECT
40
)
41

42

43
# multiple select
44
DEFAULT_MULTI_SELECT_PROMPT_TMPL = (
45
    "Some choices are given below. It is provided in a numbered "
46
    "list (1 to {num_choices}), "
47
    "where each item in the list corresponds to a summary.\n"
48
    "---------------------\n"
49
    "{context_list}"
50
    "\n---------------------\n"
51
    "Using only the choices above and not prior knowledge, return the top choices "
52
    "(no more than {max_outputs}, but only select what is needed) that "
53
    "are most relevant to the question: '{query_str}'\n"
54
)
55

56

57
DEFAULT_MULTIPLE_SELECT_PROMPT = PromptTemplate(
58
    template=DEFAULT_MULTI_SELECT_PROMPT_TMPL, prompt_type=PromptType.MULTI_SELECT
59
)
60

61
# single pydantic select
62
DEFAULT_SINGLE_PYD_SELECT_PROMPT_TMPL = (
63
    "Some choices are given below. It is provided in a numbered list "
64
    "(1 to {num_choices}), "
65
    "where each item in the list corresponds to a summary.\n"
66
    "---------------------\n"
67
    "{context_list}"
68
    "\n---------------------\n"
69
    "Using only the choices above and not prior knowledge, generate "
70
    "the selection object and reason that is most relevant to the "
71
    "question: '{query_str}'\n"
72
)
73

74

75
# multiple pydantic select
76
DEFAULT_MULTI_PYD_SELECT_PROMPT_TMPL = (
77
    "Some choices are given below. It is provided in a numbered "
78
    "list (1 to {num_choices}), "
79
    "where each item in the list corresponds to a summary.\n"
80
    "---------------------\n"
81
    "{context_list}"
82
    "\n---------------------\n"
83
    "Using only the choices above and not prior knowledge, return the top choice(s) "
84
    "(no more than {max_outputs}, but only select what is needed) by generating "
85
    "the selection object and reasons that are most relevant to the "
86
    "question: '{query_str}'\n"
87
)
88

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.