Spaces:
Sleeping
Sleeping
File size: 1,221 Bytes
0e70bef | 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 | import os
from dotenv import load_dotenv
load_dotenv()
system_prompt = os.getenv("SYSTEM_PROMPT").replace("\\n", "\n")
### String example from question ###
def str_exm_from_q(idx_q):
idx, q = idx_q
return f"""
{idx + 1}. **Câu hỏi:** ""
{q["ques"]}
""
**Lời giải:** ""
{q["ans"]}
""
"""
######################
### User prompt for question with examples ###
def user_prompt_for(question: str, examples: list) -> str:
str_examples = "".join(map(str_exm_from_q, enumerate(examples)))
return r"""
## **Ví dụ từ RAG (các bài toán tương tự đã được giải trước đó):**
""" + str_examples + r"""
---
## **Bài toán mới cần giải:**
Câu hỏi: "" """ + question + r""" ""
Hãy giải bài toán theo đúng định dạng trên và sử dụng LaTeX để trình bày công thức toán học.
"""
######################
if __name__ == "__main__":
q = r"""Viết phương trình tham số của đường thẳng đi qua điểm $\displaystyle O( 0;\ 0)$ và song song với đường $\displaystyle r:\ 3x-4y+1=0$"""
exps = [
{ "ques": "hehe", "ans": "hehe" },
{ "ques": "haha", "ans": "haha" }
]
print(user_prompt_for(q, exps)) |