-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path2-prompt-templates.py
More file actions
46 lines (35 loc) · 1008 Bytes
/
2-prompt-templates.py
File metadata and controls
46 lines (35 loc) · 1008 Bytes
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
from dotenv import load_dotenv, find_dotenv
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
ROLE = "profesor"
COUNTRY = "Singapura"
"""
Load OpenAI API key
"""
_ = load_dotenv(find_dotenv())
"""
Language Model
"""
chat_llm = ChatOpenAI(temperature=0.0)
# template = """
# Apa persyaratan untuk menjadi seorang {role} di {country}?
# Jawaban harus dalam Bahasa Indonesia.
# """
# prompt = ChatPromptTemplate.from_template(template)
# # Assign variable to the template
# final_prompt = prompt.format(
# role=ROLE,
# country=COUNTRY
# )
next_month = "Desember"
template = """
Bulan ini merupakan bulan Agustus, bulan depan merupakan bulan {month}.
Apakah pertanyaan tersebut benar? Jika salah, jelaskan letak kesalahannya.
"""
prompt = ChatPromptTemplate.from_template(template)
final_prompt = prompt.format(
month=next_month
)
response = chat_llm.predict(final_prompt)
print(f"Final prompt: {final_prompt}")
print(f"Response: {response}")