Spaces:
Running
Running
File size: 1,946 Bytes
2c310c1 | 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 | """Ask Foresight — the runtime companion.
The app must boot and every other screen must keep working when there's no
`OPENAI_API_KEY`, so nothing here imports LangChain at module level. `enabled()`
is the gate; `run_turn` is imported inside it.
"""
from __future__ import annotations
import os
from . import threads
__all__ = ["enabled", "model_name", "run_turn", "threads", "describe",
"greeting", "SUGGESTED_PROMPTS"]
DEFAULT_MODEL = "gpt-5.6-sol"
# Served to the client by /api/chat/config so the greeting and starter prompts can
# be tuned without a frontend deploy.
GREETING = ("Hi {first} — ask me anything about Vanderbilt. I'll look it up in real "
"campus information and show you where the answer came from.")
GREETING_ANONYMOUS = ("Ask me anything about Vanderbilt. I'll look it up in real "
"campus information and show you where the answer came from.")
SUGGESTED_PROMPTS = [
{"label": "Find me a club for what I'm into", "domain": "crew"},
{"label": "What does add/drop actually mean?", "domain": "vu"},
{"label": "How do I find summer research?", "domain": "future"},
{"label": "I feel behind everyone else.", "domain": "strengths"},
]
def greeting(first_name: str = "") -> str:
return GREETING.format(first=first_name) if first_name else GREETING_ANONYMOUS
def model_name() -> str:
return os.environ.get("FORESIGHT_CHAT_MODEL", DEFAULT_MODEL)
def enabled() -> bool:
"""Whether the companion can actually answer.
False means no API key is configured. The UI reads this and says so honestly
rather than letting a student type into a box that will error.
"""
return bool(os.environ.get("OPENAI_API_KEY"))
def run_turn(*args, **kwargs):
from .graph import run_turn as _run_turn
return _run_turn(*args, **kwargs)
def describe() -> dict:
return {"enabled": enabled(), "model": model_name() if enabled() else None}
|