tudormunteanu commited on
Commit
881e6c7
1 Parent(s): 1e0e52a

add streamlit

Browse files
Files changed (2) hide show
  1. app.py +25 -31
  2. requirements.txt +3 -0
app.py CHANGED
@@ -1,11 +1,11 @@
1
  # app.py
2
 
3
  import os
4
- import gradio as gr
5
  from transformers import AutoTokenizer, AutoModelForCausalLM
6
  import torch
7
 
8
- # Initialize model and tokenizer
9
  def load_model(model_size: str = "32B"):
10
  """
11
  Load model and tokenizer based on size selection
@@ -58,36 +58,30 @@ def process_query(query: str, model_size: str = "7B") -> str:
58
  return f"Error: {str(e)}"
59
 
60
  def main():
61
- with gr.Blocks() as demo:
62
- with gr.Row():
63
- model_size = gr.Radio(
64
- choices=["0.5B", "1.5B", "3B", "7B", "14B", "32B"],
65
- label="Qwen2.5-Coder Model Size:",
66
- value="32B"
67
- )
68
-
69
- with gr.Row():
70
- input_text = gr.Textbox(
71
- lines=5,
72
- label="Input",
73
- placeholder="Enter your query here..."
74
- )
75
-
76
- with gr.Row():
77
- output_text = gr.Textbox(
78
- lines=10,
79
- label="Output"
80
- )
81
-
82
- submit_btn = gr.Button("Generate")
83
-
84
- submit_btn.click(
85
- fn=process_query,
86
- inputs=[input_text, model_size],
87
- outputs=output_text
88
- )
89
 
90
- demo.launch(max_threads=5)
 
 
 
 
 
 
 
91
 
92
  if __name__ == "__main__":
93
  main()
 
1
  # app.py
2
 
3
  import os
4
+ import streamlit as st
5
  from transformers import AutoTokenizer, AutoModelForCausalLM
6
  import torch
7
 
8
+ @st.cache_resource
9
  def load_model(model_size: str = "32B"):
10
  """
11
  Load model and tokenizer based on size selection
 
58
  return f"Error: {str(e)}"
59
 
60
  def main():
61
+ st.title("Qwen2.5-Coder Interface")
62
+
63
+ # Model size selection
64
+ model_size = st.radio(
65
+ "Select Model Size:",
66
+ options=["0.5B", "1.5B", "3B", "7B", "14B", "32B"],
67
+ index=5 # Default to 32B (last option)
68
+ )
69
+
70
+ # Input text area
71
+ query = st.text_area(
72
+ "Input",
73
+ placeholder="Enter your query here...",
74
+ height=150
75
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
+ # Generate button
78
+ if st.button("Generate"):
79
+ if query:
80
+ with st.spinner("Generating response..."):
81
+ response = process_query(query, model_size)
82
+ st.text_area("Output", value=response, height=300)
83
+ else:
84
+ st.warning("Please enter a query first.")
85
 
86
  if __name__ == "__main__":
87
  main()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ streamlit