prithivMLmods
commited on
Commit
•
9fd12f1
1
Parent(s):
73fb3c7
Update app.py
Browse files
app.py
CHANGED
@@ -1,62 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
import sambanova_gradio
|
3 |
|
4 |
-
# Function to load the selected model
|
5 |
-
def load_model(model_choice):
|
6 |
-
# Directly load the model without using the ChatInterface
|
7 |
-
model = sambanova_gradio.registry(model_choice)
|
8 |
-
return model
|
9 |
-
|
10 |
-
# Function to generate response
|
11 |
-
def generate_response(model_choice, user_input):
|
12 |
-
model = load_model(model_choice)
|
13 |
-
output = model(user_input) # Assuming model is callable like a function
|
14 |
-
return output
|
15 |
-
|
16 |
-
# Available model choices
|
17 |
-
model_choices = [
|
18 |
-
"Meta-Llama-3.2-1B-lnstruct",
|
19 |
-
"Meta-Llama-3.2-3B-Instruct",
|
20 |
-
"Meta-Llama-3.1-88-Instruct",
|
21 |
-
"Meta-Llama-3.1-405B-lnstruct",
|
22 |
-
"Meta-Llama-3.1-70B-lnstruct"
|
23 |
-
]
|
24 |
-
|
25 |
-
# Gradio interface
|
26 |
with gr.Blocks() as demo:
|
27 |
-
gr.
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
choices=model_choices,
|
32 |
-
label="Choose a Meta-Llama Model",
|
33 |
-
value="Meta-Llama-3.2-3B-Instruct" # Default selected model
|
34 |
-
)
|
35 |
-
|
36 |
-
# Textbox for user input
|
37 |
-
input_box = gr.Textbox(
|
38 |
-
label="Input",
|
39 |
-
placeholder="Ask a question..."
|
40 |
-
)
|
41 |
-
|
42 |
-
# Output textbox for displaying the response
|
43 |
-
output_box = gr.Textbox(label="Output")
|
44 |
-
|
45 |
-
# Button to generate a response
|
46 |
-
generate_button = gr.Button("Generate Response")
|
47 |
-
|
48 |
-
# Example inputs
|
49 |
-
examples = gr.Examples(
|
50 |
-
examples=["Explain quantum gravity to a 5-year-old.", "How many R are there in the word Strawberry?"],
|
51 |
-
inputs=input_box
|
52 |
-
)
|
53 |
-
|
54 |
-
# Define button click action
|
55 |
-
generate_button.click(
|
56 |
-
fn=generate_response,
|
57 |
-
inputs=[model_choice, input_box],
|
58 |
-
outputs=output_box
|
59 |
-
)
|
60 |
|
61 |
-
|
62 |
-
demo.launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
import sambanova_gradio
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
with gr.Blocks() as demo:
|
5 |
+
with gr.Tab("405B"):
|
6 |
+
gr.load('Meta-Llama-3.1-405B-Instruct', src=sambanova_gradio.registry)
|
7 |
+
with gr.Tab("70B"):
|
8 |
+
gr.load('Meta-Llama-3.1-70B-Instruct-8k', src=sambanova_gradio.registry)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
demo.launch()
|
|