File size: 974 Bytes
a8a2d3f
d56b284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8a2d3f
 
d56b284
 
 
 
 
 
 
 
a8a2d3f
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import gradio as gr
import openai
import os


MODEL = "gpt-3.5-turbo"

try:
    openai.api_key = os.getenv("OPENAI_API_KEY")
except:
    print("Set the OPENAI_API_KEY environment variable")
    exit()
    
def get_prompt(essay):
    return f"""
    Provide an estimate score and sub-scores for the following ACT writing sample using the ACT scoring rubric.
    For each sub-score also provide one example of support and one example of what could be improved.
    Each score should be a single number with one decimal point of accuracy and not a range.
    This is the provided writing sample:
    "{essay}"
    """



def grade_essay(essay):
    response = openai.ChatCompletion.create(
        model=MODEL,
        messages=[{"role":"user", "content":get_prompt(essay)}],
        temperature=1,
        max_tokens=1000
    )
    
    return response['choices'][0]['message']['content']


demo = gr.Interface(fn=grade_essay, inputs="text", outputs="text")

demo.launch()