-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai_engine.py
More file actions
60 lines (50 loc) · 2.12 KB
/
ai_engine.py
File metadata and controls
60 lines (50 loc) · 2.12 KB
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
"""
Simulated AI engine for generating quests with random variation.
"""
from typing import List, Dict
import random
class LLMConfig:
"""Configuration for the AI engine."""
def __init__(self, model_name: str = "sim-model-v1", temperature: float = 0.3):
self.model_name = model_name
self.temperature = temperature
class LLMEngine:
"""Simulated AI engine for quest generation."""
def __init__(self, config: LLMConfig):
self.config = config
def generate_quests(self, goal: str, n: int = 5, mode: str = "ai_sim") -> List[Dict]:
"""
Generate quests with random names, descriptions, points, and difficulty.
Args:
goal (str): The user’s goal.
n (int): Number of quests.
mode (str): Mode, for compatibility ("ai_sim").
Returns:
List[Dict]: List of generated quests.
"""
suffixes = ["Quick Win", "Mini Habit", "Boost", "Momentum", "Push Forward", "Step Forward", "Micro Task"]
used_names = set()
quests = []
for i in range(n):
available = [s for s in suffixes if s not in used_names]
if not available:
available = suffixes
suffix = random.choice(available)
used_names.add(suffix)
points = random.randint(5, 15)
difficulty = random.choice(["easy", "medium", "hard"])
descriptions = [
f"Do a short action to help with the goal: {goal}. Keep it manageable.",
f"Perform a small step toward: {goal}. Make it achievable today.",
f"Take a tiny action to progress with: {goal}. Keep it consistent.",
f"Small activity to support {goal}. Stay focused and repeatable.",
f"Quick task to advance {goal}. Keep it light and achievable."
]
description = random.choice(descriptions)
quests.append({
"name": f"{goal} - {suffix}",
"description": description,
"points": points,
"difficulty": difficulty
})
return quests