Spaces:
Runtime error
Runtime error
initial model done
Browse files- README.md +1 -1
- app.py +66 -4
- requirements.txt +1 -0
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: LLM Comparer
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
|
|
|
| 1 |
---
|
| 2 |
title: LLM Comparer
|
| 3 |
+
emoji: ⚖️
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
app.py
CHANGED
|
@@ -1,8 +1,70 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
def greet(name):
|
| 5 |
-
return os.environ.get("prompts")
|
| 6 |
|
| 7 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 8 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
import requests
|
| 4 |
+
import openai
|
| 5 |
+
|
| 6 |
+
def greet(modelpath1="",modelpath2="",modelpath3="",modelpath4="",modelpath5=""):
|
| 7 |
+
names = [modelpath1,modelpath2,modelpath3,modelpath4,modelpath5]
|
| 8 |
+
names = [name for name in names if name != ""]
|
| 9 |
+
if names == []:
|
| 10 |
+
return "Please enter at least one model name."
|
| 11 |
+
if len(names) < 2:
|
| 12 |
+
return "Please enter at least 2 model names."
|
| 13 |
+
urls = []
|
| 14 |
+
for name in names:
|
| 15 |
+
urls.append("https://huggingface.co/" + name + "/raw/main/config.json")
|
| 16 |
+
|
| 17 |
+
configs = []
|
| 18 |
+
index_to_ignore =[]
|
| 19 |
+
for i in range(len(urls)):
|
| 20 |
+
get_result = requests.get(urls[i])
|
| 21 |
+
if get_result.status_code == 200:
|
| 22 |
+
configs.append(get_result.json())
|
| 23 |
+
else:
|
| 24 |
+
configs.append("")
|
| 25 |
+
index_to_ignore.append(i)
|
| 26 |
+
if configs == []:
|
| 27 |
+
return "Could not find any models. Please check the model name."
|
| 28 |
+
|
| 29 |
+
gpt_input = ""
|
| 30 |
+
gpt_input += os.environ["prompts"] +"\n\n"
|
| 31 |
+
for i in range(len(names)):
|
| 32 |
+
if i not in index_to_ignore:
|
| 33 |
+
gpt_input += "modelname: " + names[i] + "\n" + " config file:" + str(configs[i]) + "\n\n"
|
| 34 |
+
|
| 35 |
+
openai.api_key = os.environ["APIKEY"]
|
| 36 |
+
|
| 37 |
+
respose = openai.ChatCompletion.create(
|
| 38 |
+
model="gpt-3.5-turbo",
|
| 39 |
+
messages=[
|
| 40 |
+
{
|
| 41 |
+
"role": "system",
|
| 42 |
+
"content": gpt_input
|
| 43 |
+
},
|
| 44 |
+
],
|
| 45 |
+
)
|
| 46 |
+
response_text = respose["choices"][0]["message"]["content"]
|
| 47 |
+
# get the first | to the last |
|
| 48 |
+
response_text = response_text[response_text.find("|")+1:response_text.rfind("|")+1]
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
return response_text
|
| 52 |
+
|
| 53 |
+
text1 = gr.inputs.Textbox(placeholder="ower/modelname1", label="Input modelname like rinna/japanese-gpt-neox-3.6b",lines=1,optional=False)
|
| 54 |
+
text2 = gr.inputs.Textbox(placeholder="ower/modelname2", label="model 2",lines=1,optional=False)
|
| 55 |
+
text3 = gr.inputs.Textbox(placeholder="ower/modelname3", label="model 3",lines=1,optional=True)
|
| 56 |
+
|
| 57 |
+
if __name__ == '__main__':
|
| 58 |
+
interFace = gr.Interface(fn=greet,
|
| 59 |
+
inputs=[text1,text2,text3],
|
| 60 |
+
outputs=[gr.Markdown(value="")],
|
| 61 |
+
title="LLM Comparer⚖️",
|
| 62 |
+
description="Plsease copy and paste the owner name / model name from the Hugging Face model hub.",
|
| 63 |
+
theme='finlaymacklon/smooth_slate',
|
| 64 |
+
allow_flagging=False,
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
interFace.launch(share=False)
|
| 68 |
+
|
| 69 |
|
|
|
|
|
|
|
| 70 |
|
|
|
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
requests
|