Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI, Request | |
| from fastapi.responses import JSONResponse | |
| from flowise import Flowise | |
| import os | |
| from dotenv import load_dotenv | |
| # Load environment variables | |
| load_dotenv() | |
| app = FastAPI() | |
| # Get Flowise host, API key, and Chatflow ID from environment variables | |
| FLOWISE_HOST = os.getenv("https://huggingface.co/spaces/joeraylo/bookreport") | |
| FLOWISE_API_KEY = os.getenv("lAZFo7LaeVXqo_v0bSXhBKOcvIsRkVobqKY1OtkFUHc") | |
| CHATFLOW_ID = os.getenv("c8f7e207-85cb-4fed-8829-f341ce75b72e") | |
| # Initialize Flowise client (only if env vars are set) | |
| flowise = None | |
| if FLOWISE_HOST and FLOWISE_API_KEY and CHATFLOW_ID: | |
| try: | |
| flowise = Flowise(host=FLOWISE_HOST, api_key=FLOWISE_API_KEY) | |
| except Exception as e: | |
| print(f"Error initializing Flowise: {e}") | |