themeetjani commited on
Commit
253fdb8
1 Parent(s): 711f46b

Update pages/Auto_Score_Generation.py

Browse files
Files changed (1) hide show
  1. pages/Auto_Score_Generation.py +42 -10
pages/Auto_Score_Generation.py CHANGED
@@ -1,14 +1,46 @@
1
  import streamlit as st
2
-
3
- st.set_page_config(
4
- page_title="Auto_Score_Generation.py",
5
- page_icon="👋",
6
- )
7
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  st.write("# Auto Score Generation! 👋")
9
 
10
 
11
- st.markdown(
12
- """
13
- **Work in progress!!!** """
14
- )
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import os
3
+ import openai
4
+ import pandas as pd
5
+ from sklearn.preprocessing import LabelEncoder
6
+ import numpy as np
7
+ def gpt4_score(m_answer, s_answer):
8
+ response = openai.ChatCompletion.create(
9
+ model="gpt-4",
10
+ messages=[
11
+ {
12
+ "role": "system",
13
+ "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"
14
+ },
15
+ {
16
+ "role": "assistant",
17
+ "content": f"Model answer: {m_answer}"},
18
+ {
19
+ "role": "user",
20
+ "content": f"Student answer: {s_answer}"}
21
+ ],
22
+ temperature=0,
23
+ max_tokens=701,
24
+ top_p=1,
25
+ frequency_penalty=0,
26
+ presence_penalty=0
27
+ )
28
+ return json.loads(response.choices[0].message.content)
29
  st.write("# Auto Score Generation! 👋")
30
 
31
 
32
+ if 'score' not in session_state:
33
+ session_state['score']= ""
34
+
35
+ st.title("Core Risk Category Classifier")
36
+ text1= st.text_area(label= "Please write the Model Answer bellow",
37
+ placeholder="What does the text say?")
38
+ text2= st.text_area(label= "Please write the Student Answer bellow",
39
+ placeholder="What does the text say?")
40
+ def classify(text1,text2):
41
+ session_state['topic_class'] = gpt4_score(text1,text2)
42
+
43
+
44
+ st.text_area("result", value=session_state['score'])
45
+
46
+ st.button("Classify", on_click=classify, args=[text1,text2])