eyes-mdfjbots125 commited on
Commit
afe13f2
ยท
verified ยท
1 Parent(s): 01fb5c9

Fix: gradio>=5.0.0 + full file upload (Python 3.13 compat)

Browse files
Files changed (3) hide show
  1. README.md +2 -2
  2. app.py +35 -20
  3. requirements.txt +1 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: ๐ŸŒ
4
  colorFrom: purple
5
  colorTo: blue
6
  sdk: gradio
7
- sdk_version: 4.44.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
@@ -22,7 +22,7 @@ tags:
22
 
23
  # NEO-2 โ€” mdfjbots
24
 
25
- NEO-1 + real internet search (DuckDuckGo) with license filtering.
26
  Only CC BY, CC0 and Public Domain sources are used.
27
 
28
  **Source:** [github.com/mdfjbotss/neo-1](https://github.com/mdfjbotss/neo-1)
 
4
  colorFrom: purple
5
  colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 5.0.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
22
 
23
  # NEO-2 โ€” mdfjbots
24
 
25
+ NEO-1 + real internet search (DuckDuckGo) with license filtering.
26
  Only CC BY, CC0 and Public Domain sources are used.
27
 
28
  **Source:** [github.com/mdfjbotss/neo-1](https://github.com/mdfjbotss/neo-1)
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import os
2
  import time
3
  import gradio as gr
4
 
@@ -37,27 +36,30 @@ def respond(message, history):
37
  text = message.strip().lower()
38
 
39
  if is_calculator_request(message):
40
- name = extract_username(history)
41
  greeting = (
42
  f"Sure! ๐Ÿ˜€ {name}, here's our calculator:\n\n"
43
- "๐Ÿงฎ **NEO-1 Virtual Calculator**\n"
44
  "Type any math operation and I'll solve it instantly.\n\n"
45
  "**Examples:** `5 + 3` `12 * 7` `100 / 4` `2 ** 8` (power)\n\n"
46
  "_Say 'exit calculator' to go back._"
47
  )
48
  history = add_turn(history, message)
49
- for h in stream_tokens(greeting, history): yield h, ""
 
50
  return
51
 
52
  if text in ("exit calculator", "close calculator", "quit calculator", "back to chat"):
53
  history = add_turn(history, message, "Alright, back to normal chat. Ask me anything! ๐Ÿ˜Š")
54
- yield history, ""; return
 
55
 
56
  if calculator_mode_active(history) or is_math_operation(message):
57
  result = solve_operation(message)
58
  if result is not None:
59
  history = add_turn(history, message)
60
- for h in stream_tokens(format_result(message, result), history): yield h, ""
 
61
  return
62
 
63
  roblox_type, roblox_name = detect_roblox(message)
@@ -65,7 +67,8 @@ def respond(message, history):
65
  history = add_turn(history, message, "๐Ÿ” Searching for player on Roblox...")
66
  yield history, ""
67
  history[-1]["content"] = format_player(search_player(roblox_name))
68
- yield history, ""; return
 
69
  if roblox_type == "game":
70
  history = add_turn(history, message, "๐Ÿ” Searching for game on Roblox...")
71
  yield history, ""
@@ -74,12 +77,14 @@ def respond(message, history):
74
  if data and "error" not in data:
75
  result += "\n\n๐Ÿ’ก **What is this game about?**\n" + generate_game_explanation(data)
76
  history[-1]["content"] = result
77
- yield history, ""; return
 
78
 
79
  response = find_custom_response(message)
80
  if response:
81
  history = add_turn(history, message)
82
- for h in stream_tokens(response, history): yield h, ""
 
83
  return
84
 
85
  history = add_turn(history, message, "๐ŸŒ Searching the web...")
@@ -89,7 +94,8 @@ def respond(message, history):
89
  summary = summarize(message, web_result)
90
  if summary:
91
  history[-1]["content"] = ""
92
- for h in stream_tokens(summary, history): yield h, ""
 
93
  return
94
 
95
  error_type = web_result.get("error_type", "")
@@ -105,22 +111,31 @@ def respond(message, history):
105
  yield history, ""
106
 
107
  with gr.Blocks(title="NEO-2 โ€” mdfjbots") as demo:
108
- gr.Markdown("# ๐Ÿค– NEO-2\n### Conversational AI with web search ยท mdfjbots")
109
- chatbot = gr.Chatbot(show_label=False, height=480,
110
- avatar_images=(None, "https://api.dicebear.com/7.x/bottts/svg?seed=neo2"))
 
 
111
  with gr.Row():
112
- input_box = gr.Textbox(placeholder="Type your message... (e.g. 'what is a black hole?')",
113
- show_label=False, scale=9, container=False, autofocus=True)
114
- btn_send = gr.Button("Send", scale=1, variant="primary")
 
 
115
  btn_clear = gr.Button("๐Ÿ—‘๏ธ Clear", size="sm")
116
- gr.Examples(["Hello, who are you?", "search player Builderman", "search game Adopt Me",
117
- "what is a supernova?", "calculator", "what is linux"], inputs=input_box)
 
 
 
118
  input_box.submit(fn=respond, inputs=[input_box, chatbot], outputs=[chatbot, input_box])
119
  btn_send.click(fn=respond, inputs=[input_box, chatbot], outputs=[chatbot, input_box])
120
  btn_clear.click(fn=lambda: ([], ""), outputs=[chatbot, input_box])
121
 
122
  if __name__ == "__main__":
123
  if start_server:
124
- try: start_server()
125
- except Exception: pass
 
 
126
  demo.queue().launch()
 
 
1
  import time
2
  import gradio as gr
3
 
 
36
  text = message.strip().lower()
37
 
38
  if is_calculator_request(message):
39
+ name = extract_username(history)
40
  greeting = (
41
  f"Sure! ๐Ÿ˜€ {name}, here's our calculator:\n\n"
42
+ "๐Ÿงฎ **NEO-2 Virtual Calculator**\n"
43
  "Type any math operation and I'll solve it instantly.\n\n"
44
  "**Examples:** `5 + 3` `12 * 7` `100 / 4` `2 ** 8` (power)\n\n"
45
  "_Say 'exit calculator' to go back._"
46
  )
47
  history = add_turn(history, message)
48
+ for h in stream_tokens(greeting, history):
49
+ yield h, ""
50
  return
51
 
52
  if text in ("exit calculator", "close calculator", "quit calculator", "back to chat"):
53
  history = add_turn(history, message, "Alright, back to normal chat. Ask me anything! ๐Ÿ˜Š")
54
+ yield history, ""
55
+ return
56
 
57
  if calculator_mode_active(history) or is_math_operation(message):
58
  result = solve_operation(message)
59
  if result is not None:
60
  history = add_turn(history, message)
61
+ for h in stream_tokens(format_result(message, result), history):
62
+ yield h, ""
63
  return
64
 
65
  roblox_type, roblox_name = detect_roblox(message)
 
67
  history = add_turn(history, message, "๐Ÿ” Searching for player on Roblox...")
68
  yield history, ""
69
  history[-1]["content"] = format_player(search_player(roblox_name))
70
+ yield history, ""
71
+ return
72
  if roblox_type == "game":
73
  history = add_turn(history, message, "๐Ÿ” Searching for game on Roblox...")
74
  yield history, ""
 
77
  if data and "error" not in data:
78
  result += "\n\n๐Ÿ’ก **What is this game about?**\n" + generate_game_explanation(data)
79
  history[-1]["content"] = result
80
+ yield history, ""
81
+ return
82
 
83
  response = find_custom_response(message)
84
  if response:
85
  history = add_turn(history, message)
86
+ for h in stream_tokens(response, history):
87
+ yield h, ""
88
  return
89
 
90
  history = add_turn(history, message, "๐ŸŒ Searching the web...")
 
94
  summary = summarize(message, web_result)
95
  if summary:
96
  history[-1]["content"] = ""
97
+ for h in stream_tokens(summary, history):
98
+ yield h, ""
99
  return
100
 
101
  error_type = web_result.get("error_type", "")
 
111
  yield history, ""
112
 
113
  with gr.Blocks(title="NEO-2 โ€” mdfjbots") as demo:
114
+ gr.Markdown("# ๐ŸŒ NEO-2\n### Conversational AI with web search ยท mdfjbots")
115
+ chatbot = gr.Chatbot(
116
+ show_label=False, height=480, type="messages",
117
+ avatar_images=(None, "https://api.dicebear.com/7.x/bottts/svg?seed=neo2"),
118
+ )
119
  with gr.Row():
120
+ input_box = gr.Textbox(
121
+ placeholder="Type your message... (e.g. 'what is a black hole?')",
122
+ show_label=False, scale=9, container=False, autofocus=True,
123
+ )
124
+ btn_send = gr.Button("Send", scale=1, variant="primary")
125
  btn_clear = gr.Button("๐Ÿ—‘๏ธ Clear", size="sm")
126
+ gr.Examples(
127
+ ["Hello, who are you?", "search player Builderman", "search game Adopt Me",
128
+ "what is a supernova?", "calculator", "what is linux"],
129
+ inputs=input_box,
130
+ )
131
  input_box.submit(fn=respond, inputs=[input_box, chatbot], outputs=[chatbot, input_box])
132
  btn_send.click(fn=respond, inputs=[input_box, chatbot], outputs=[chatbot, input_box])
133
  btn_clear.click(fn=lambda: ([], ""), outputs=[chatbot, input_box])
134
 
135
  if __name__ == "__main__":
136
  if start_server:
137
+ try:
138
+ start_server()
139
+ except Exception:
140
+ pass
141
  demo.queue().launch()
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- gradio>=4.44.0
2
  requests>=2.31.0
3
  ddgs>=6.0.0
 
1
+ gradio>=5.0.0
2
  requests>=2.31.0
3
  ddgs>=6.0.0