RFTSystems commited on
Commit
37907ba
·
verified ·
1 Parent(s): eea425a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -39
app.py CHANGED
@@ -1,47 +1,19 @@
1
  # =========================================================
2
- # NexFrame Chat simplified version (text only)
3
- # Works directly on Hugging Face with Colab API backend
4
  # =========================================================
5
  import gradio as gr
6
- import requests
7
- import os
8
 
9
- # ---- environment variables (set in Hugging Face Settings → Variables) ----
10
- API_URL = os.getenv("NEXFRAME_API_URL", "")
11
- API_KEY = os.getenv("NEXFRAME_API_KEY", "")
12
- # --------------------------------------------------------------------------
13
 
14
- def talk_to_nexframe(user_input: str):
15
- """
16
- Sends user text to the Colab API and returns the reply.
17
- If API_URL is missing, shows an offline message instead.
18
- """
19
- if not API_URL:
20
- return "🧠 NexFrame is offline — please set NEXFRAME_API_URL in your Space settings."
21
- try:
22
- response = requests.post(
23
- API_URL,
24
- headers={"X-API-Key": API_KEY},
25
- json={"query": user_input},
26
- timeout=30,
27
- )
28
- data = response.json()
29
- # Expecting JSON with an 'answer' field
30
- return data.get("answer") or str(data)
31
- except Exception as e:
32
- return f"[Connection error: {e}]"
33
-
34
- # ---- Simple Gradio chat interface ----
35
- chat = gr.ChatInterface(
36
- fn=talk_to_nexframe,
37
- title="🧠 NexFrame Chat",
38
- description="Rendered Frame Theory — Ask NexFrame anything.",
39
- examples=[
40
- ["Explain gravity in Rendered Frame Theory."],
41
- ["What does τ_eff mean in RFT?"],
42
- ["How does NexFrame understand consciousness?"]
43
- ],
44
  )
45
 
46
  if __name__ == "__main__":
47
- chat.launch()
 
1
  # =========================================================
2
+ # NexFrame minimal Gradio starter
3
+ # (no API, just proves the Space runs)
4
  # =========================================================
5
  import gradio as gr
 
 
6
 
7
+ def echo(message):
8
+ # simple placeholder reply
9
+ return f"🧠 NexFrame received: {message}"
 
10
 
11
+ demo = gr.ChatInterface(
12
+ fn=echo,
13
+ title="🧠 NexFrame Chat Offline Mode",
14
+ description="This simple version checks that the Space starts correctly.",
15
+ examples=["Hello NexFrame!", "Test message"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  )
17
 
18
  if __name__ == "__main__":
19
+ demo.launch()