Spaces:
Sleeping
Sleeping
liudongqing
commited on
Commit
·
a66f412
1
Parent(s):
3e60b85
Use the open api to do the score
Browse files- app.py +7 -8
- requirements.txt +2 -1
app.py
CHANGED
@@ -4,13 +4,10 @@ from threading import Thread
|
|
4 |
import gradio as gr
|
5 |
import spaces
|
6 |
from PIL import Image
|
7 |
-
from
|
8 |
import os
|
9 |
|
10 |
-
client =
|
11 |
-
"openai/gpt-4o-mini", # or other models like "openai/gpt-4"
|
12 |
-
token=os.environ["OPENAI_API_KEY"] # Your OpenAI API key
|
13 |
-
)
|
14 |
|
15 |
# from zipnn import zipnn_hf
|
16 |
|
@@ -58,13 +55,15 @@ def score_with_gpt(text):
|
|
58 |
+ "4. The words and phrases are appropriate for the context."
|
59 |
+ "5. Scale the score from 0 to 100."
|
60 |
},
|
61 |
-
{"role": "user", "content": text}
|
62 |
]
|
63 |
|
64 |
-
return client.
|
|
|
65 |
messages=messages,
|
66 |
-
max_tokens=500
|
67 |
)
|
|
|
68 |
|
69 |
|
70 |
def score_it(input_img):
|
|
|
4 |
import gradio as gr
|
5 |
import spaces
|
6 |
from PIL import Image
|
7 |
+
from openai import OpenAI
|
8 |
import os
|
9 |
|
10 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
|
|
|
|
|
|
11 |
|
12 |
# from zipnn import zipnn_hf
|
13 |
|
|
|
55 |
+ "4. The words and phrases are appropriate for the context."
|
56 |
+ "5. Scale the score from 0 to 100."
|
57 |
},
|
58 |
+
{"role": "user", "content": f"{prompt}, The essay is: \"text \""}
|
59 |
]
|
60 |
|
61 |
+
return client.chat.completions.create(
|
62 |
+
model="gpt-4o-mini", # or "gpt-3.5-turbo"
|
63 |
messages=messages,
|
64 |
+
max_tokens=500,
|
65 |
)
|
66 |
+
|
67 |
|
68 |
|
69 |
def score_it(input_img):
|
requirements.txt
CHANGED
@@ -2,4 +2,5 @@ torch==2.4.0
|
|
2 |
transformers==4.46.2
|
3 |
accelerate>=0.26.0
|
4 |
zipnn==0.3.4
|
5 |
-
huggingface_hub
|
|
|
|
2 |
transformers==4.46.2
|
3 |
accelerate>=0.26.0
|
4 |
zipnn==0.3.4
|
5 |
+
huggingface_hub
|
6 |
+
openai
|