Spaces:
Sleeping
Sleeping
Update app.py
Browse files12345617 unmodified lines2425262728293042 unmodified lines737475767778import gradio as grimport requestsimport os# Configuration17 unmodified linesprint("SUCCESS: HF_API_KEY loaded securely.")# Funcation definitiondef call_langflow(message, history):"""Call Langflow API and return the response42 unmodified linesexcept (KeyError, IndexError) as e:return f"Error parsing response: {str(e)}\nResponse: {data}"# Create Gradio Chat Interfacechat = gr.ChatInterface(fn=call_langflow,12345678917 unmodified lines27282930313233343542 unmodified lines787980818283848586878889909192939495969798import gradio as grimport requestsimport osfrom fastapi import FastAPIfrom fastapi.middleware.cors import CORSMiddlewarefrom ping import add_ping_route# Configuration17 unmodified linesprint("SUCCESS: HF_API_KEY loaded securely.")# Function that calls the LangFlow chatdef call_langflow(message, history):"""Call Langflow API and return the response42 unmodified linesexcept (KeyError, IndexError) as e:return f"Error parsing response: {str(e)}\nResponse: {data}"#Create FastAPI App for health check.app = FastAPI(title="Chatbot with Ping API")# Optional CORS setupapp.add_middleware(CORSMiddleware,allow_origins=["*"],allow_credentials=True,allow_methods=["*"],allow_headers=["*"],)# Add /ping route from ping.pyadd_ping_route(app, call_langflow)# Create Gradio Chat Interfacechat = gr.ChatInterface(fn=call_langflow,
app.py+21-1