LogicDataSolutions commited on
Commit
9f952c3
·
verified ·
1 Parent(s): 0ba731e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -1,6 +1,9 @@
1
  import gradio as gr
2
  import requests
3
  import os
 
 
 
4
 
5
 
6
  # Configuration
@@ -24,7 +27,9 @@ else:
24
  print("SUCCESS: HF_API_KEY loaded securely.")
25
 
26
 
27
- # Funcation definition
 
 
28
  def call_langflow(message, history):
29
  """
30
  Call Langflow API and return the response
@@ -73,6 +78,21 @@ def call_langflow(message, history):
73
  except (KeyError, IndexError) as e:
74
  return f"Error parsing response: {str(e)}\nResponse: {data}"
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  # Create Gradio Chat Interface
77
  chat = gr.ChatInterface(
78
  fn=call_langflow,
 
1
  import gradio as gr
2
  import requests
3
  import os
4
+ from fastapi import FastAPI
5
+ from fastapi.middleware.cors import CORSMiddleware
6
+ from ping import add_ping_route
7
 
8
 
9
  # Configuration
 
27
  print("SUCCESS: HF_API_KEY loaded securely.")
28
 
29
 
30
+
31
+
32
+ # Function that calls the LangFlow chat
33
  def call_langflow(message, history):
34
  """
35
  Call Langflow API and return the response
 
78
  except (KeyError, IndexError) as e:
79
  return f"Error parsing response: {str(e)}\nResponse: {data}"
80
 
81
+ #Create FastAPI App for health check.
82
+ app = FastAPI(title="Chatbot with Ping API")
83
+ # Optional CORS setup
84
+ app.add_middleware(
85
+ CORSMiddleware,
86
+ allow_origins=["*"],
87
+ allow_credentials=True,
88
+ allow_methods=["*"],
89
+ allow_headers=["*"],
90
+ )
91
+ # Add /ping route from ping.py
92
+ add_ping_route(app, call_langflow)
93
+
94
+
95
+
96
  # Create Gradio Chat Interface
97
  chat = gr.ChatInterface(
98
  fn=call_langflow,