TIMBOVILL commited on
Commit
5d135b7
·
verified ·
1 Parent(s): 0995863

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -40
app.py CHANGED
@@ -65,45 +65,33 @@ def process_video(text):
65
 
66
  return output_path
67
 
68
- def chat_interface():
69
- return gr.Interface(
70
- fn=generate_response,
71
- inputs=[
72
- gr.Textbox(label="Prompt"),
73
- gr.Textbox(label="History", type="text"),
74
- gr.Dropdown(choices=["llama3-70b-8192", "llama3-8b-8192", "mixtral-8x7b-32768", "gemma-7b-it"], label="Model"),
75
- gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Temperature"),
76
- gr.Slider(minimum=1, maximum=32192, step=1, label="Max Tokens"),
77
- gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Top P"),
78
- gr.Number(precision=0, label="Seed")
79
- ],
80
- outputs=gr.Textbox(label="Response"),
81
- title="YTSHorts Maker - Chat Interface",
82
- description="Powered by GROQ.",
83
- live=True # Enable live updates for the chat interface
84
- )
85
-
86
- def process_video_interface():
87
- return gr.Interface(
88
- fn=process_video,
89
- inputs=gr.Textbox(label="Text (8 words max per line)"),
90
- outputs=gr.Video(label="Processed Video"),
91
- title="YTSHorts Maker - Video Processing",
92
- description="Select a video file from 'videos' folder, add text, and process.",
93
- )
94
-
95
- # Initialize each interface separately
96
- chat = chat_interface()
97
- video_processor = process_video_interface()
98
-
99
- # Now initialize the demo interface correctly
100
- demo = gr.Interface(
101
- fn=None, # No main function needed for multi-interface setup
102
- interfaces=[chat, video_processor],
103
- title="YTSHorts Maker",
104
- description="Powered by GROQ, MoviePy, and other tools.",
105
- theme="soft",
106
- )
107
 
108
- # Launch the demo interface
109
  demo.launch()
 
65
 
66
  return output_path
67
 
68
+ additional_inputs = [
69
+ gr.Dropdown(choices=["llama3-70b-8192", "llama3-8b-8192", "mixtral-8x7b-32768", "gemma-7b-it"], value="llama3-70b-8192", label="Model"),
70
+ gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.5, label="Temperature", info="Controls diversity of the generated text. Lower is more deterministic, higher is more creative."),
71
+ gr.Slider(minimum=1, maximum=32192, step=1, value=4096, label="Max Tokens", info="The maximum number of tokens that the model can process in a single response.<br>Maximums: 8k for gemma 7b, llama 7b & 70b, 32k for mixtral 8x7b."),
72
+ gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.5, label="Top P", info="A method of text generation where a model will only consider the most probable next tokens that make up the probability p."),
73
+ gr.Number(precision=0, value=42, label="Seed", info="A starting point to initiate generation, use 0 for random")
74
+ ]
75
+
76
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="red", secondary_hue="pink")) as demo:
77
+ with gr.Tabs():
78
+ with gr.TabItem("Chat"):
79
+ chat_interface = gr.ChatInterface(
80
+ fn=generate_response,
81
+ chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
82
+ additional_inputs=additional_inputs,
83
+ title="YTSHorts Maker",
84
+ description="Powered by GROQ, MoviePy, and other tools.",
85
+ )
86
+ with gr.TabItem("Video Processing"):
87
+ text_input = gr.Textbox(lines=5, label="Text (8 words max per line)")
88
+ process_button = gr.Button("Process Video")
89
+ video_output = gr.Video(label="Processed Video")
90
+
91
+ process_button.click(
92
+ fn=process_video,
93
+ inputs=[text_input],
94
+ outputs=video_output,
95
+ )
 
 
 
 
 
 
 
 
 
 
 
96
 
 
97
  demo.launch()