Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,63 +1,28 @@
|
|
1 |
import gradio as gr
|
2 |
-
from lunacode import smart_luna_answer
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
response_text = smart_luna_answer(text, max_tokens=max_tokens)
|
23 |
-
audio_path = text_to_speech_luna(response_text)
|
24 |
-
return response_text, audio_path
|
25 |
-
|
26 |
-
# CHAT INTERFACE
|
27 |
-
chat_interface = gr.Interface(
|
28 |
-
fn=text_chat,
|
29 |
-
inputs=[
|
30 |
-
gr.Textbox(label="Your Message", placeholder="Ask me anything..."),
|
31 |
-
gr.State([]), # Chat history
|
32 |
-
gr.Slider(minimum=128, maximum=2048, value=512, step=1, label="Max tokens"),
|
33 |
-
gr.Textbox(value="You are a helpful AI assistant.", label="System Prompt"),
|
34 |
-
],
|
35 |
-
outputs=[
|
36 |
-
gr.Chatbot(label="Luna Chat"),
|
37 |
-
gr.State([])
|
38 |
],
|
39 |
-
title="Luna
|
40 |
-
|
41 |
-
|
42 |
-
# VOICE INTERFACE
|
43 |
-
voice_interface = gr.Interface(
|
44 |
-
fn=voice_chat,
|
45 |
-
inputs=[
|
46 |
-
gr.Audio( type="filepath", label="Speak to Luna"),
|
47 |
-
gr.Slider(minimum=128, maximum=2048, value=512, step=1, label="Max tokens")
|
48 |
-
],
|
49 |
-
outputs=[
|
50 |
-
gr.Textbox(label="Luna's Response"),
|
51 |
-
gr.Audio(label="Luna Speaks")
|
52 |
-
],
|
53 |
-
title="Luna Voice"
|
54 |
-
)
|
55 |
-
|
56 |
-
# COMBINE INTO TABS
|
57 |
-
demo = gr.TabbedInterface(
|
58 |
-
[chat_interface, voice_interface],
|
59 |
-
["Chat with Luna", "Voice with Luna"]
|
60 |
)
|
61 |
|
62 |
if __name__ == "__main__":
|
63 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from lunacode import smart_luna_answer
|
3 |
+
|
4 |
+
def respond(
|
5 |
+
message,
|
6 |
+
history: list[tuple[str, str]],
|
7 |
+
system_message,
|
8 |
+
max_tokens,
|
9 |
+
):
|
10 |
+
try:
|
11 |
+
result = smart_luna_answer(message, max_tokens=max_tokens)
|
12 |
+
return result
|
13 |
+
except Exception as e:
|
14 |
+
return f"Error: {str(e)}"
|
15 |
+
|
16 |
+
demo = gr.ChatInterface(
|
17 |
+
fn=respond,
|
18 |
+
additional_inputs=[
|
19 |
+
gr.Textbox(value="You are a helpful AI assistant.", label="System message"),
|
20 |
+
gr.Slider(minimum=128, maximum=2048, value=512, step=1, label="Max new tokens"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
],
|
22 |
+
title="Luna AI — Code & Web Enhanced Assistant",
|
23 |
+
description="Ask Luna questions, generate code, and explore smart AI-powered answers with web context!",
|
24 |
+
theme="default"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
)
|
26 |
|
27 |
if __name__ == "__main__":
|
28 |
+
demo.launch()
|