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))