Spaces:
Runtime error
Runtime error
File size: 2,845 Bytes
4bc1c81 156026c 4bc1c81 156026c 4bc1c81 156026c 4bc1c81 156026c 4bc1c81 9243bfc 4bc1c81 5fa769b 4bc1c81 |
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import gradio as gr
import guidance
from dotenv import load_dotenv
load_dotenv()
def indiQuesGrade(question, answer, role, exp):
evaluatorModel = guidance.llms.OpenAI('gpt-3.5-turbo')
evaluationSys = guidance('''
{{#system~}}
You are an expert system in Evaluating the answer provided by an interviewee in an interview.
Based on the question, answer given with information of Applying Role and Years of Experience, you can grade the answer on appropriate grading measures.
You are very skilled in grading the answers accurately and justifiably.
{{~/system}}
{{#user~}}
Now, you are provided with Interviewee's Question, his job role he applied to, and his years of experience he has with it.
You are now asked to generate suitable/appropriate grading measures for the question and grade his answer according to them.
The Question asked as follows:
{{question}}
The Role he applied to is as follows :
{{role}}
The years of experience he has in it is as follows :
{{experience}}
Now, generate the grading measures according to the above question, role and experience values.
The grading measures must be generated as a array elements with names as the grading rubrics. They are placed between two square brackets, separated by commas.
Do not output the grading measures yet.
{{~/user}}
{{#assistant~}}
{{gen 'grading_measures' temperature=0.7 max_tokens=150}}
{{~/assistant}}
{{#user~}}
Here's the answer provided by the interviewee in the interview :
{{answer}}
Now, perform the evaluation on the answer according to the generated grading measures.
Output the evaluation in a JSON Format with the grading measure as key and a dictionary of score and reason as value.
The score key contains a numerical measure depicting the answer against grading measure and the reason key contains text information
about why the answer was such given such numerical grade in the evaluation measure.
Add the key of overall score to the output JSON with a dictionary as it's value. The dictionary must have two keys, score, depecting the numerical measure
as a overall evaluations score, graded against a score of 5 and the other key as reason, showing a Justification Statement.
The output response must only contain a JSON File of evaluation. Do not output any additional information other than it.
{{~/user}}
{{#assistant~}}
{{gen 'evaluation' temperature=0.5 max_tokens=1500}}
{{~/assistant}}
''', llm = evaluatorModel)
output = evaluationSys(question=question, role = role, experience = exp, answer = answer)
return output['evaluation'], output['grading_measures']
k=gr.Interface(
fn=indiQuesGrade,
inputs=['text','text','text','text'],
outputs=['json', 'text']
)
k.launch() |