Spaces:
Sleeping
Sleeping
AI Assistant
feat: add support for Gemini API and implement state management for quiz turns and answers
b85377a Download app/services/state_manager.py from amer003100/securityChatbot: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/amer003100/securityChatbot/resolve/main/app/services/state_manager.py
- Command line
-
hf download hf://spaces/amer003100/securityChatbot/app/services/state_manager.py
-
curl -L -o state_manager.py https://huggingface.co/spaces/amer003100/securityChatbot/resolve/main/app/services/state_manager.py
1.09 kB
| from typing import Dict | |
| user_states: Dict[str, str] = {} | |
| user_scenarios: Dict[str, str] = {} | |
| user_levels: Dict[str, str] = {} | |
| user_turns: Dict[str, int] = {} | |
| user_quiz_answer: Dict[str, str] = {} | |
| def get_state(user_id: str) -> str: | |
| return user_states.get(user_id, "NORMAL") | |
| def set_state(user_id: str, state: str): | |
| user_states[user_id] = state | |
| def get_scenario(user_id: str) -> str: | |
| return user_scenarios.get(user_id, "1") | |
| def set_scenario(user_id: str, scenario_key: str): | |
| user_scenarios[user_id] = scenario_key | |
| def get_level(user_id: str) -> str: | |
| return user_levels.get(user_id, "1") | |
| def set_level(user_id: str, level_key: str): | |
| user_levels[user_id] = level_key | |
| def get_turn(user_id: str) -> int: | |
| return user_turns.get(user_id, 0) | |
| def increment_turn(user_id: str): | |
| user_turns[user_id] = get_turn(user_id) + 1 | |
| def reset_turns(user_id: str): | |
| user_turns[user_id] = 0 | |
| def set_quiz_answer(user_id: str, answer: str): | |
| user_quiz_answer[user_id] = answer | |
| def get_quiz_answer(user_id: str) -> str: | |
| return user_quiz_answer.get(user_id, "") |