Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,9 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
# π Set NGROK token
|
| 4 |
-
os.environ["NGROK_AUTHTOKEN"] = "33Jqcou6HvfbAEgNa8h20QTpyWx_H4VDZ6RewUx96owPmgdC"
|
| 5 |
-
ngrok.set_auth_token(os.environ["NGROK_AUTHTOKEN"])
|
| 6 |
|
| 7 |
# API Configuration
|
| 8 |
-
api_key = "sk-6Ng7YDAkl0D5z20vAh7tPkmWn5hCTcZGIcl_wRiQ5NQ"
|
| 9 |
-
url = "http://localhost:7860/api/v1/run/30d9ce86-194f-44ba-a15a-f822c3ac4f57"
|
| 10 |
|
| 11 |
def query_langflow(user_input):
|
| 12 |
payload = {
|
|
@@ -24,6 +21,8 @@ def query_langflow(user_input):
|
|
| 24 |
response = requests.post(url, json=payload, headers=headers)
|
| 25 |
response.raise_for_status()
|
| 26 |
data = response.json()
|
|
|
|
|
|
|
| 27 |
if isinstance(data, dict):
|
| 28 |
return data.get("outputs", data)
|
| 29 |
return str(data)
|
|
@@ -35,7 +34,7 @@ def query_langflow(user_input):
|
|
| 35 |
|
| 36 |
# Gradio UI
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
-
gr.Markdown("## π LangFlow Chat with Gradio
|
| 39 |
|
| 40 |
chatbot = gr.Chatbot()
|
| 41 |
msg = gr.Textbox(placeholder="Ask something...")
|
|
@@ -47,10 +46,5 @@ with gr.Blocks() as demo:
|
|
| 47 |
|
| 48 |
msg.submit(chat, [msg, chatbot], [chatbot, msg])
|
| 49 |
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
public_url = ngrok.connect(port, "http").public_url
|
| 53 |
-
print(f"π Public URL (Ngrok): {public_url}")
|
| 54 |
-
|
| 55 |
-
demo.launch(server_name="0.0.0.1", server_port=port)
|
| 56 |
-
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# API Configuration
|
| 5 |
+
api_key = "sk-6Ng7YDAkl0D5z20vAh7tPkmWn5hCTcZGIcl_wRiQ5NQ" # replace with your actual key
|
| 6 |
+
url = "http://localhost:7860/api/v1/run/30d9ce86-194f-44ba-a15a-f822c3ac4f57" # LangFlow endpoint
|
| 7 |
|
| 8 |
def query_langflow(user_input):
|
| 9 |
payload = {
|
|
|
|
| 21 |
response = requests.post(url, json=payload, headers=headers)
|
| 22 |
response.raise_for_status()
|
| 23 |
data = response.json()
|
| 24 |
+
|
| 25 |
+
# Adjust based on actual LangFlow response structure
|
| 26 |
if isinstance(data, dict):
|
| 27 |
return data.get("outputs", data)
|
| 28 |
return str(data)
|
|
|
|
| 34 |
|
| 35 |
# Gradio UI
|
| 36 |
with gr.Blocks() as demo:
|
| 37 |
+
gr.Markdown("## π LangFlow Chat with Gradio")
|
| 38 |
|
| 39 |
chatbot = gr.Chatbot()
|
| 40 |
msg = gr.Textbox(placeholder="Ask something...")
|
|
|
|
| 46 |
|
| 47 |
msg.submit(chat, [msg, chatbot], [chatbot, msg])
|
| 48 |
|
| 49 |
+
# π This will show BOTH: local URL + public .gradio.live URL
|
| 50 |
+
demo.launch(server_name="0.0.0.1", server_port=7865, share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|