File size: 1,854 Bytes
6060e42
36684d4
253fdb8
 
b60feca
253fdb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68ed3e8
6060e42
 
 
253fdb8
 
 
 
 
 
 
 
a09cbe5
253fdb8
 
 
 
327c011
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
43
44
45
46
47
import streamlit as st
from streamlit import session_state
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
import pandas as pd
from sklearn.preprocessing import LabelEncoder
import numpy as np
def gpt4_score(m_answer, s_answer):
    response = openai.ChatCompletion.create(
      model="gpt-4",
      messages=[
        {
          "role": "system",
          "content": "You are UPSC answers evaluater. You will be given model answer and student answer. Evaluate it by comparing with the model answer. \n<<REMEMBER>>\nIt is 10 marks question. Student can recieve maximum 5 marks. Give marks in the range of 0.25. (ex. 0,0.25,0.5...)\nThere are 3 parts in the answer. Introduction (1 marks), body (3 marks) and conclusion (1 marks). If the student answer and model answer is not relevant then give 0 marks.\ngive output in json form. Give output in this format {\"intro\":,\"body\":,\"con\":,\"total\":}\n<<OUTPUT>>\n"
        },
        {
          "role": "assistant",
          "content": f"Model answer: {m_answer}"},
        {
          "role": "user",
          "content": f"Student answer: {s_answer}"}
      ],
      temperature=0,
      max_tokens=701,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0
    )
    return response.choices[0].message.content
st.write("# Auto Score Generation! 👋")


if 'score' not in session_state:
    session_state['score']= ""
    
text1= st.text_area(label= "Please write the Model Answer bellow", 
              placeholder="What does the text say?")
text2= st.text_area(label= "Please write the Student Answer bellow", 
              placeholder="What does the text say?")
def classify(text1,text2):
    session_state['score'] = gpt4_score(text1,text2)


st.text_area("result", value=session_state['score'])

st.button("Submit", on_click=classify, args=[text1,text2])