HemanM commited on
Commit
fdfa3ca
·
verified ·
1 Parent(s): ccae0a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -23
app.py CHANGED
@@ -1,28 +1,19 @@
1
  import gradio as gr
2
- import torch
3
- from transformers import AutoTokenizer
4
- from generate import load_model, generate_text
5
 
6
- # Settings
7
- MODEL_PATH = "evo_decoder.pt"
8
- DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
9
- TOKENIZER_NAME = "gpt2" # Or your custom tokenizer
10
- MAX_TOKENS = 50
11
 
12
- # Load tokenizer & model
13
- tokenizer = AutoTokenizer.from_pretrained(TOKENIZER_NAME)
14
- vocab_size = tokenizer.vocab_size
15
- model = load_model(vocab_size, MODEL_PATH, DEVICE)
 
 
 
 
16
 
17
- def chat(prompt):
18
- output = generate_text(model, tokenizer, prompt, max_new_tokens=MAX_TOKENS, device=DEVICE)
19
- return output
20
 
21
- # Gradio UI
22
- iface = gr.Interface(fn=chat,
23
- inputs=gr.Textbox(label="Ask Evo..."),
24
- outputs=gr.Textbox(label="Evo's Response"),
25
- title="🧠 EvoDecoder Chatbot",
26
- description="A lightweight conversational model powered by EvoDecoder")
27
-
28
- iface.launch()
 
1
  import gradio as gr
2
+ from generate.py import generate_response
 
 
3
 
4
+ def chat_with_evo(user_input):
5
+ response = generate_response(user_input)
6
+ return response
 
 
7
 
8
+ with gr.Blocks() as demo:
9
+ gr.Markdown("## 🤖 EvoDecoder Chatbot (Lightweight Conversational AI)")
10
+ with gr.Row():
11
+ with gr.Column(scale=4):
12
+ user_input = gr.Textbox(label="Ask Evo anything...", placeholder="Type your question here...")
13
+ submit_btn = gr.Button("Submit")
14
+ with gr.Column(scale=6):
15
+ response_output = gr.Textbox(label="Evo's Response")
16
 
17
+ submit_btn.click(fn=chat_with_evo, inputs=user_input, outputs=response_output)
 
 
18
 
19
+ demo.launch()