Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,6 @@ from typing import Optional
|
|
| 7 |
from fastapi.responses import JSONResponse
|
| 8 |
from openai import OpenAI
|
| 9 |
|
| 10 |
-
# Create a router for our API endpoints
|
| 11 |
-
router = APIRouter()
|
| 12 |
-
|
| 13 |
# Create the FastAPI app
|
| 14 |
app = FastAPI()
|
| 15 |
|
|
@@ -22,6 +19,10 @@ app.add_middleware(
|
|
| 22 |
allow_headers=["*"],
|
| 23 |
)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# Root endpoint for health checks
|
| 26 |
@app.get("/")
|
| 27 |
async def root():
|
|
@@ -29,7 +30,6 @@ async def root():
|
|
| 29 |
|
| 30 |
# Slack configuration
|
| 31 |
SLACK_VERIFICATION_TOKEN = os.getenv("SLACK_VERIFICATION_TOKEN")
|
| 32 |
-
# Add your Slack user ID (you can find this in your Slack profile)
|
| 33 |
ALLOWED_SLACK_USER_ID = os.getenv("YOUR_SLACK_USER_ID")
|
| 34 |
|
| 35 |
# Load KB
|
|
@@ -354,9 +354,6 @@ async def _process_slack_command(conversation_id: str, response_url: str):
|
|
| 354 |
headers={"Content-Type": "application/json"}
|
| 355 |
)
|
| 356 |
|
| 357 |
-
# Include the router with the base path
|
| 358 |
-
app.include_router(router, prefix="/api" if os.getenv('HF_SPACE') else "")
|
| 359 |
-
|
| 360 |
async def send_chatwoot_message(conversation_id: str, content: str):
|
| 361 |
message_payload = {
|
| 362 |
"content": content,
|
|
|
|
| 7 |
from fastapi.responses import JSONResponse
|
| 8 |
from openai import OpenAI
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
# Create the FastAPI app
|
| 11 |
app = FastAPI()
|
| 12 |
|
|
|
|
| 19 |
allow_headers=["*"],
|
| 20 |
)
|
| 21 |
|
| 22 |
+
# Create and include router
|
| 23 |
+
router = APIRouter(prefix="/api" if os.getenv('HF_SPACE') else "")
|
| 24 |
+
app.include_router(router)
|
| 25 |
+
|
| 26 |
# Root endpoint for health checks
|
| 27 |
@app.get("/")
|
| 28 |
async def root():
|
|
|
|
| 30 |
|
| 31 |
# Slack configuration
|
| 32 |
SLACK_VERIFICATION_TOKEN = os.getenv("SLACK_VERIFICATION_TOKEN")
|
|
|
|
| 33 |
ALLOWED_SLACK_USER_ID = os.getenv("YOUR_SLACK_USER_ID")
|
| 34 |
|
| 35 |
# Load KB
|
|
|
|
| 354 |
headers={"Content-Type": "application/json"}
|
| 355 |
)
|
| 356 |
|
|
|
|
|
|
|
|
|
|
| 357 |
async def send_chatwoot_message(conversation_id: str, content: str):
|
| 358 |
message_payload = {
|
| 359 |
"content": content,
|