Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,9 @@ from models import ChatRequest
|
|
| 14 |
from ui_html import HOME_HTML
|
| 15 |
from utils import clamp01, get_user_text
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
app = FastAPI(title="GMAT Solver v3", version="3.1.0")
|
| 19 |
|
|
@@ -130,6 +133,10 @@ async def chat(request: Request) -> JSONResponse:
|
|
| 130 |
hidden_context, actual_user_message = split_unity_message(full_text)
|
| 131 |
game_fields = extract_game_context_fields(hidden_context)
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
tone = clamp01(req_data.get("tone", req.tone), 0.5)
|
| 134 |
verbosity = clamp01(req_data.get("verbosity", req.verbosity), 0.5)
|
| 135 |
transparency = clamp01(req_data.get("transparency", req.transparency), 0.5)
|
|
@@ -151,6 +158,7 @@ async def chat(request: Request) -> JSONResponse:
|
|
| 151 |
options_text=game_fields["options"],
|
| 152 |
question_category=game_fields["category"],
|
| 153 |
question_difficulty=game_fields["difficulty"],
|
|
|
|
| 154 |
)
|
| 155 |
|
| 156 |
return JSONResponse(
|
|
|
|
| 14 |
from ui_html import HOME_HTML
|
| 15 |
from utils import clamp01, get_user_text
|
| 16 |
|
| 17 |
+
from retrieval_engine import RetrievalEngine
|
| 18 |
+
|
| 19 |
+
retriever = RetrievalEngine()
|
| 20 |
|
| 21 |
app = FastAPI(title="GMAT Solver v3", version="3.1.0")
|
| 22 |
|
|
|
|
| 133 |
hidden_context, actual_user_message = split_unity_message(full_text)
|
| 134 |
game_fields = extract_game_context_fields(hidden_context)
|
| 135 |
|
| 136 |
+
# NEW
|
| 137 |
+
context = retriever.search(actual_user_message)
|
| 138 |
+
context_text = "\n".join(context)
|
| 139 |
+
|
| 140 |
tone = clamp01(req_data.get("tone", req.tone), 0.5)
|
| 141 |
verbosity = clamp01(req_data.get("verbosity", req.verbosity), 0.5)
|
| 142 |
transparency = clamp01(req_data.get("transparency", req.transparency), 0.5)
|
|
|
|
| 158 |
options_text=game_fields["options"],
|
| 159 |
question_category=game_fields["category"],
|
| 160 |
question_difficulty=game_fields["difficulty"],
|
| 161 |
+
retrieval_context=context_text,
|
| 162 |
)
|
| 163 |
|
| 164 |
return JSONResponse(
|