Spaces:
Sleeping
Sleeping
| import os | |
| from groq import Groq | |
| # Groq production models (updated June 2026) | |
| # Primary: best quality for spiritual/persona-heavy readings | |
| # Fast: cost-efficient fallback | |
| # Backup: strong multilingual alternative | |
| GROQ_MODELS = [ | |
| "openai/gpt-oss-120b", | |
| "openai/gpt-oss-20b", | |
| "qwen/qwen3.6-27b", | |
| "llama-3.3-70b-versatile", | |
| "llama-3.1-8b-instant", | |
| ] | |
| DEFAULT_MODEL = os.getenv("GROQ_MODEL", "openai/gpt-oss-120b") | |
| FALLBACK_MODEL = os.getenv("GROQ_FALLBACK_MODEL", "openai/gpt-oss-20b") | |
| TAROT_DECK = [ | |
| {"name": "The Fool", "id": 0, "desc": "์๋ก์ด ์์, ๋ชจํ, ์์ํจ", "image": "https://upload.wikimedia.org/wikipedia/commons/9/90/RWS_Tarot_00_Fool.jpg"}, | |
| {"name": "The Magician", "id": 1, "desc": "์ฐฝ์กฐ๋ ฅ, ๊ธฐ์ , ์์ง", "image": "https://upload.wikimedia.org/wikipedia/commons/d/de/RWS_Tarot_01_Magician.jpg"}, | |
| {"name": "The High Priestess", "id": 2, "desc": "์งํ, ์ง๊ด, ์ ๋น", "image": "https://upload.wikimedia.org/wikipedia/commons/8/88/RWS_Tarot_02_High_Priestess.jpg"}, | |
| {"name": "The Empress", "id": 3, "desc": "ํ์, ๋ชจ์ฑ, ์์ฐ", "image": "https://upload.wikimedia.org/wikipedia/commons/d/d2/RWS_Tarot_03_Empress.jpg"}, | |
| {"name": "The Emperor", "id": 4, "desc": "๊ถ์, ๊ตฌ์กฐ, ์๋ฒ์ง", "image": "https://upload.wikimedia.org/wikipedia/commons/c/c3/RWS_Tarot_04_Emperor.jpg"}, | |
| {"name": "The Hierophant", "id": 5, "desc": "์ ํต, ์ ๋ , ๊ต์ก", "image": "https://upload.wikimedia.org/wikipedia/commons/8/8d/RWS_Tarot_05_Hierophant.jpg"}, | |
| {"name": "The Lovers", "id": 6, "desc": "์ฌ๋, ์กฐํ, ์ ํ", "image": "https://upload.wikimedia.org/wikipedia/commons/3/3a/TheLovers.jpg"}, | |
| {"name": "The Chariot", "id": 7, "desc": "์น๋ฆฌ, ์์ง๋ ฅ, ์ ์ง", "image": "https://upload.wikimedia.org/wikipedia/commons/9/9b/RWS_Tarot_07_Chariot.jpg"}, | |
| {"name": "Strength", "id": 8, "desc": "์ธ๋ด, ์ฉ๊ธฐ, ๋ด๋ฉด์ ํ", "image": "https://upload.wikimedia.org/wikipedia/commons/f/f5/RWS_Tarot_08_Strength.jpg"}, | |
| {"name": "The Hermit", "id": 9, "desc": "์ฑ์ฐฐ, ๊ณ ๋ , ํ๊ตฌ", "image": "https://upload.wikimedia.org/wikipedia/commons/4/4d/RWS_Tarot_09_Hermit.jpg"}, | |
| {"name": "Wheel of Fortune", "id": 10, "desc": "์ด๋ช , ๋ณํ, ์ฃผ๊ธฐ", "image": "https://upload.wikimedia.org/wikipedia/commons/3/3c/RWS_Tarot_10_Wheel_of_Fortune.jpg"}, | |
| {"name": "Justice", "id": 11, "desc": "์ ์, ์ง์ค, ์ธ๊ณผ์๋ณด", "image": "https://upload.wikimedia.org/wikipedia/commons/e/e0/RWS_Tarot_11_Justice.jpg"}, | |
| {"name": "The Hanged Man", "id": 12, "desc": "ํฌ์, ์๋ก์ด ๊ด์ , ์ ์ง", "image": "https://upload.wikimedia.org/wikipedia/commons/2/2b/RWS_Tarot_12_Hanged_Man.jpg"}, | |
| {"name": "Death", "id": 13, "desc": "๋ณํ, ์ข ๋ฃ, ์ฌํ์", "image": "https://upload.wikimedia.org/wikipedia/commons/d/d7/RWS_Tarot_13_Death.jpg"}, | |
| {"name": "Temperance", "id": 14, "desc": "๊ท ํ, ์กฐํ, ์ธ๋ด", "image": "https://upload.wikimedia.org/wikipedia/commons/f/f8/RWS_Tarot_14_Temperance.jpg"}, | |
| {"name": "The Devil", "id": 15, "desc": "์ ํน, ์๋ฐ, ์ง์ฐฉ", "image": "https://upload.wikimedia.org/wikipedia/commons/5/55/RWS_Tarot_15_Devil.jpg"}, | |
| {"name": "The Tower", "id": 16, "desc": "ํ๊ดด, ๊ธ๋ณ, ๊นจ๋ฌ์", "image": "https://upload.wikimedia.org/wikipedia/commons/5/53/RWS_Tarot_16_Tower.jpg"}, | |
| {"name": "The Star", "id": 17, "desc": "ํฌ๋ง, ์๊ฐ, ์น์ ", "image": "https://upload.wikimedia.org/wikipedia/commons/d/db/RWS_Tarot_17_Star.jpg"}, | |
| {"name": "The Moon", "id": 18, "desc": "ํ์, ๋ถ์, ๋ฌด์์", "image": "https://upload.wikimedia.org/wikipedia/commons/7/7f/RWS_Tarot_18_Moon.jpg"}, | |
| {"name": "The Sun", "id": 19, "desc": "์ฑ๊ณต, ํ๋ ฅ, ๊ธฐ์จ", "image": "https://upload.wikimedia.org/wikipedia/commons/1/17/RWS_Tarot_19_Sun.jpg"}, | |
| {"name": "Judgement", "id": 20, "desc": "์ฌํ, ๋ถํ, ๊ฐ์ฑ", "image": "https://upload.wikimedia.org/wikipedia/commons/d/dd/RWS_Tarot_20_Judgement.jpg"}, | |
| {"name": "The World", "id": 21, "desc": "์์ฑ, ์ฑ์ทจ, ํตํฉ", "image": "https://upload.wikimedia.org/wikipedia/commons/f/ff/RWS_Tarot_21_World.jpg"}, | |
| ] | |
| def get_groq_client() -> Groq: | |
| api_key = os.getenv("GROQ_API_KEY") | |
| if not api_key: | |
| raise RuntimeError("GROQ_API_KEY environment variable is not set") | |
| return Groq(api_key=api_key) | |
| def list_available_models(api_key: str | None = None) -> list[str]: | |
| """Fetch live model list from Groq, filtered for chat use.""" | |
| try: | |
| client = Groq(api_key=api_key or os.getenv("GROQ_API_KEY")) | |
| live = [ | |
| m.id | |
| for m in client.models.list().data | |
| if "whisper" not in m.id | |
| and "orpheus" not in m.id | |
| and "prompt-guard" not in m.id | |
| and "safeguard" not in m.id | |
| ] | |
| ordered = [m for m in GROQ_MODELS if m in live] | |
| extras = [m for m in live if m not in ordered] | |
| return ordered + extras | |
| except Exception: | |
| return GROQ_MODELS.copy() | |