Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
import os
|
| 2 |
-
from fastapi import FastAPI,
|
| 3 |
from pydantic import BaseModel
|
| 4 |
import dashscope
|
| 5 |
from dashscope import Generation
|
| 6 |
|
| 7 |
# Set up the API key for Dashscope
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
app = FastAPI()
|
| 12 |
|
|
@@ -43,9 +43,6 @@ async def solve_math(query: MathQuery):
|
|
| 43 |
answer = get_math_response(user_question)
|
| 44 |
return {"question": user_question, "answer": answer}
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
if exc.status_code == 404:
|
| 50 |
-
return {"detail": "Not Found. Use /math-solver to submit a math question."}
|
| 51 |
-
return await request.app.default_exception_handler(request, exc)
|
|
|
|
| 1 |
import os
|
| 2 |
+
from fastapi import FastAPI, Request
|
| 3 |
from pydantic import BaseModel
|
| 4 |
import dashscope
|
| 5 |
from dashscope import Generation
|
| 6 |
|
| 7 |
# Set up the API key for Dashscope
|
| 8 |
+
YOUR_API_TOKEN = os.getenv('HF_TOKEN')
|
| 9 |
+
dashscope.api_key = YOUR_API_TOKEN
|
| 10 |
|
| 11 |
app = FastAPI()
|
| 12 |
|
|
|
|
| 43 |
answer = get_math_response(user_question)
|
| 44 |
return {"question": user_question, "answer": answer}
|
| 45 |
|
| 46 |
+
@app.get("/")
|
| 47 |
+
def root():
|
| 48 |
+
return {"message": "Welcome to the FastAPI Math Solver!"}
|
|
|
|
|
|
|
|
|