File size: 3,348 Bytes
6c8a2d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from dotenv import load_dotenv
from backend.config_manager import Config
from backend.utils import ensure_directory
import os

load_dotenv()

# Set up base paths
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CONFIG_DIR = os.path.join(PROJECT_ROOT, "backend")
OUTPUT_DIR = os.path.join(PROJECT_ROOT, "output")

# Ensure directories exist
ensure_directory(CONFIG_DIR)
ensure_directory(OUTPUT_DIR)

config_path = os.path.join(CONFIG_DIR, "config.json")
config = Config(config_path)

# Default values - update API key handling
API_KEY = os.getenv('OPENAI_API_KEY') or os.getenv('GEMINI_API_KEY')
if not API_KEY:
    raise ValueError("No API key found. Please set OPENAI_API_KEY or GEMINI_API_KEY environment variable")

MODEL = "gemini-1.5-flash-8b"
BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai/"

# Add API port configuration
API_PORT = int(os.getenv('API_PORT', 8000))

CURRICULUM_INSTRUCTION = """
You are an expert AI language learning curriculum designer. Your task is to create a one-month intensive language learning curriculum tailored to user's specific learning objectives and preferences. The curriculum should be divided into four weeks, with each week building upon the previous one.

**Curriculum Design Principles:**

1.  **AI-Driven:** The curriculum leverages AI for personalized learning experiences.
2.  **Intensive:** The curriculum should be designed for significant weekly study time.
3.  **Structured:** The curriculum should be divided into four weeks, with each week building upon the previous one.
4.  **Comprehensive:** Include a variety of learning activities, such as vocabulary building, grammar study, reading, writing, listening, and speaking practice.
5.  **Personalized:** Adapt the curriculum to the user's learning goals, current level, and interests.
6.  **Measurable:** Suggest ways the user can track their progress.
7.  **Output Format:** Provide the curriculum in a valid JSON format.
8.  **Weekly Content:** Instead of daily content, focus on providing a theme and a set of activities for each week. Include the approximate time the user should invest in that week.

**Output JSON Format:**

```json
{
  "language": "target_language",
  "learning_goal": "user_provided_goal",
  "current_level": "user_provided_level",
  "weeks": [
    {
      "week": 1,
      "theme": "week_theme",
      "estimated_duration": "estimated_weekly_time",
      "activities": [
        {
          "type": "activity_type",
          "description": "activity_description"
        },
        {
          "type": "activity_type",
          "description": "activity_description"
        },
        ...
      ]
    },
    {
      "week": 2,
      "theme": "week_theme",
      "estimated_duration": "estimated_weekly_time",
      "activities": [
        {
          "type": "activity_type",
          "description": "activity_description"
        },
        ...
      ]
    },
    ...
  ]
}
"""

# Export CURRICULUM_INSTRUCTION
__all__ = ['config', 'CURRICULUM_INSTRUCTION', 'API_PORT']

# Initialize config with default values if not exists
if not config.data:
    config.set("curriculum_instruction", CURRICULUM_INSTRUCTION)
    config.set("model", MODEL)
    config.set("base_url", BASE_URL)
    config.set("api_key", API_KEY)
    config.set("api_port", API_PORT)
    config.save()