SarahXia0405 commited on
Commit
482bc73
·
verified ·
1 Parent(s): 1213cb1

Create config.py

Browse files
Files changed (1) hide show
  1. config.py +112 -0
config.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # config.py
2
+ import os
3
+ from typing import List, Dict
4
+ from openai import OpenAI
5
+ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
6
+
7
+ # ---------- 环境变量 & OpenAI API Key ----------
8
+ OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
9
+ if not OPENAI_API_KEY:
10
+ raise RuntimeError(
11
+ "OPENAI_API_KEY is not set. Please go to Settings → Secrets and add it."
12
+ )
13
+
14
+ # ---------- 模型配置(一定要在用之前定义) ----------
15
+ DEFAULT_MODEL = "gpt-4.1-mini"
16
+ EMBEDDING_MODEL = "text-embedding-3-small"
17
+
18
+ # ---------- OpenAI 原生 Client(老代码还在用) ----------
19
+ client = OpenAI(api_key=OPENAI_API_KEY)
20
+
21
+ # ---------- LangChain 封装的 LLM & Embedding ----------
22
+ # 以后如果你想用 LangChain 的 ChatOpenAI / OpenAIEmbeddings,可以直接用这两个
23
+ llm_default = ChatOpenAI(
24
+ model=DEFAULT_MODEL,
25
+ temperature=0.5,
26
+ timeout=20,
27
+ )
28
+
29
+ embedding_client = OpenAIEmbeddings(
30
+ model=EMBEDDING_MODEL,
31
+ )
32
+
33
+ # ---------- 默认 GenAI 课程大纲 ----------
34
+ DEFAULT_COURSE_TOPICS: List[str] = [
35
+ "Week 0 – Welcome & What is Generative AI; course outcomes LO1–LO5.",
36
+ "Week 1 – Foundations of GenAI: LLMs, Transformer & self-attention, perplexity.",
37
+ "Week 2 – Foundation Models & multimodal models; data scale, bias & risks.",
38
+ "Week 3 – Choosing Pre-trained Models; open-source vs proprietary; cost vs quality.",
39
+ "Week 4 – Prompt Engineering: core principles; zero/few-shot; CoT; ReAct.",
40
+ "Week 5 – Building a Simple Chatbot; memory (short vs long term); LangChain & UI.",
41
+ "Week 6 – Review Week; cross-module consolidation & self-check prompts.",
42
+ "Week 7 – Retrieval-Augmented Generation (RAG); embeddings; hybrid retrieval.",
43
+ "Week 8 – Agents & Agentic RAG; planning, tools, knowledge augmentation.",
44
+ "Week 9 – Evaluating GenAI Apps; hallucination, bias/fairness, metrics.",
45
+ "Week 10 – Responsible AI; risks, governance, EU AI Act-style ideas.",
46
+ ]
47
+
48
+ # ---------- 学习模式 ----------
49
+ LEARNING_MODES: List[str] = [
50
+ "Concept Explainer",
51
+ "Socratic Tutor",
52
+ "Exam Prep / Quiz",
53
+ "Assignment Helper",
54
+ "Quick Summary",
55
+ ]
56
+
57
+ LEARNING_MODE_INSTRUCTIONS: Dict[str, str] = {
58
+ "Concept Explainer": (
59
+ "Explain concepts step by step. Use clear definitions, key formulas or structures, "
60
+ "and one or two simple examples. Focus on clarity over depth. Regularly check if "
61
+ "the student is following."
62
+ ),
63
+ "Socratic Tutor": (
64
+ "Use a Socratic style. Ask the student ONE short question at a time, guide them to "
65
+ "reason step by step, and only give full explanations after they try. Prioritize "
66
+ "questions and hints over long lectures."
67
+ ),
68
+ "Exam Prep / Quiz": (
69
+ "Behave like an exam prep coach. Often propose short quiz-style questions "
70
+ "(multiple choice or short answer), then explain the solutions clearly. Emphasize "
71
+ "common traps and how to avoid them."
72
+ ),
73
+ "Assignment Helper": (
74
+ "Help with assignments WITHOUT giving full final solutions. Clarify requirements, "
75
+ "break tasks into smaller steps, and provide hints, partial examples, or pseudo-code "
76
+ "instead of complete code or final answers. Encourage the student to attempt each "
77
+ "step before revealing more."
78
+ ),
79
+ "Quick Summary": (
80
+ "Provide concise, bullet-point style summaries and cheat-sheet style notes. "
81
+ "Focus on key ideas and avoid long paragraphs."
82
+ ),
83
+ }
84
+
85
+ # ---------- 上传文件类型 ----------
86
+ DOC_TYPES: List[str] = [
87
+ "Syllabus",
88
+ "Lecture Slides / PPT",
89
+ "Literature Review / Paper",
90
+ "Other Course Document",
91
+ ]
92
+
93
+ # ---------- Clare 的基础 System Prompt ----------
94
+ CLARE_SYSTEM_PROMPT = """
95
+ You are Clare, an AI teaching assistant for Hanbridge University.
96
+
97
+ Core identity:
98
+ - You are patient, encouraging, and structured like a very good TA.
99
+ - Your UI and responses should be in ENGLISH by default.
100
+ - However, you can understand BOTH English and Chinese, and you may reply in Chinese
101
+ if the student clearly prefers Chinese or asks you to.
102
+
103
+ General responsibilities:
104
+ 1. Help students understand course concepts step by step.
105
+ 2. Ask short check-up questions to confirm understanding instead of giving huge long lectures.
106
+ 3. When the student seems confused, break content into smaller chunks and use simple language first.
107
+ 4. When the student is advanced, you can switch to more technical explanations.
108
+
109
+ Safety and honesty:
110
+ - If you don’t know, say you are not sure and suggest how to verify.
111
+ - Do not fabricate references, exam answers, or grades.
112
+ """