Camila Salinas Camacho commited on
Commit
19b9274
1 Parent(s): 1309da8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -58
app.py CHANGED
@@ -1,60 +1,7 @@
1
  import gradio as gr
2
- import subprocess
3
- from gradio.mix import Parallel
4
- from transformers import AutoTokenizer, AutoModelForCausalLM
5
- import os
6
- import openai
7
- import json
8
 
9
- # Set your OpenAI API key
10
- openai.api_key = "your_openai_api_key"
11
-
12
- # Define a list of models you want to use
13
- models = {
14
- "ChatGPT": "gpt3.5-turbo-0613",
15
- "LLaMA": "lmsys/llama-13b",
16
- "Vicuna": "lmsys/vicuna-13b-v1.3",
17
- "Alpaca": "lmsys/alpaca-7B",
18
- "Flan-T5": "lmsys/fastchat-t5-3b-v1.0",
19
- }
20
-
21
- # Define a function to run your `run_llm.py` script with the selected model
22
- def run_llm(model, text, prompt_type):
23
- if "ChatGPT" in model:
24
- # Use your `run_llm.py` script for ChatGPT
25
- script = "python run_llm.py ... --model {} --text '{}' --prompt_type {}".format(
26
- model, text, prompt_type
27
- )
28
- else:
29
- # Use your `run_llm.py` script for other models
30
- script = "python run_llm.py ... --model {} --text '{}' --prompt_type {}".format(
31
- models[model], text, prompt_type
32
- )
33
-
34
- result = subprocess.check_output(script, shell=True, text=True)
35
- return result
36
-
37
- # Create a Gradio interface for each model and each strategy
38
- interfaces = {}
39
- for model in models:
40
- for strategy in range(1, 4):
41
- name = f"{model} - Strategy {strategy}"
42
- interface = gr.Interface(
43
- fn=Parallel(
44
- run_llm, model=model, prompt_type=strategy
45
- ),
46
- inputs="textbox",
47
- outputs="text",
48
- title=name,
49
- live=True,
50
- )
51
- interfaces[name] = interface
52
-
53
- if __name__ == "__main__":
54
- gr.Interface(
55
- [interfaces[name] for name in interfaces],
56
- title="LLM Strategies",
57
- live=True,
58
- share=True,
59
- server_port=7860,
60
- ).launch()
 
1
  import gradio as gr
 
 
 
 
 
 
2
 
3
+ with gr.Blocks() as demo:
4
+ with gr.Row():
5
+ btn0 = gr.Button("Button 0", scale=0)
6
+ btn1 = gr.Button("Button 1", scale=1)
7
+ btn2 = gr.Button("Button 2", scale=2)