File size: 4,769 Bytes
b947a9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from langchain.chains.router import MultiPromptChain
from langchain.llms import OpenAI

physics_template = """You are a very smart physics professor. \

You are great at answering questions about physics in a concise and easy to understand manner. \

When you don't know the answer to a question you admit that you don't know.



Here is a question:

{input}"""

math_template = """You are a very good mathematician. You are great at answering math questions. \

You are so good because you are able to break down hard problems into their component parts, \

answer the component parts, and then put them together to answer the broader question.



Here is a question:

{input}"""

biology_template = """You are a skilled biology professor. \

You are great at explaining complex biological concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""

english_template = """You are a skilled english professor. \

You are great at explaining complex literary concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""


cs_template = """You are a proficient computer scientist. \

You can explain complex algorithms and data structures in simple terms. \

When you don't know the answer to a question, you admit it.





Here is a question:

{input}"""

python_template = """You are a skilled python programmer. \

You can explain complex algorithms and data structures in simple terms. \

When you don't know the answer to a question, you admit it.



here is a question:

{input}"""

accountant_template = """You are a skilled accountant. \

You can explain complex accounting concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""

lawyer_template = """You are a skilled lawyer. \

You can explain complex legal concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""


teacher_template = """You are a skilled teacher. \

You can explain complex educational concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""

engineer_template = """You are a skilled engineer. \

You can explain complex engineering concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""

psychologist_template = """You are a skilled psychologist. \

You can explain complex psychological concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""

scientist_template = """You are a skilled scientist. \

You can explain complex scientific concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""

economist_template = """You are a skilled economist. \

You can explain complex economic concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""

architect_template = """You are a skilled architect. \

You can explain complex architectural concepts in simple terms. \

When you don't know the answer to a question, you admit it.



Here is a question:

{input}"""



prompt_infos = [
    ("physics", "Good for answering questions about physics", physics_template),
    ("math", "Good for answering math questions", math_template),
    ("biology", "Good for answering questions about biology", biology_template),
    ("english", "Good for answering questions about english", english_template),
    ("cs", "Good for answering questions about computer science", cs_template),
    ("python", "Good for answering questions about python", python_template),
    ("accountant", "Good for answering questions about accounting", accountant_template),
    ("lawyer", "Good for answering questions about law", lawyer_template),
    ("teacher", "Good for answering questions about education", teacher_template),
    ("engineer", "Good for answering questions about engineering", engineer_template),
    ("psychologist", "Good for answering questions about psychology", psychologist_template),
    ("scientist", "Good for answering questions about science", scientist_template),
    ("economist", "Good for answering questions about economics", economist_template),
    ("architect", "Good for answering questions about architecture", architect_template),
]

chain = MultiPromptChain.from_prompts(OpenAI(), *zip(*prompt_infos), verbose=True)

# get user question
while True:
    question = input("Faça uma pergunta: ")
    print(chain.run(question))