Spaces:
Runtime error
Runtime error
jeevavijay10
commited on
Commit
•
9694995
1
Parent(s):
379710f
prototype of feedback with ai
Browse files- app.py +37 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
import openai
|
4 |
+
|
5 |
+
openai.api_type = os.environ["OPENAI_API_TYPE"]
|
6 |
+
openai.api_base = os.environ["OPENAI_API_BASE"]
|
7 |
+
openai.api_version = os.environ["OPENAI_API_VERSION"]
|
8 |
+
openai.api_key = os.environ["OPENAI_API_KEY"]
|
9 |
+
|
10 |
+
|
11 |
+
def chatbot(inputAssignment):
|
12 |
+
choices = openai.ChatCompletion.create(
|
13 |
+
engine="Itekgpt35",
|
14 |
+
messages=[
|
15 |
+
{"role": "system",
|
16 |
+
"content": "•\tYou are an Assistive chatbot whose primary goal is to help teachers with providing feedbacks on student's work. \n•\tProvide concise replies that are polite and professional. \n•\tDo not answer questions that are not related to academics and respond with \"I can only help with any academic questions you may have.\". \n•\tIf you do not know the answer to a question, respond by saying “I do not know the answer to your question. You may be able to find your answer with a teacher”"},
|
17 |
+
{"role": "user",
|
18 |
+
"content": f"Evaluate the following assignment.\n${inputAssignment}"},
|
19 |
+
],
|
20 |
+
temperature=0,
|
21 |
+
max_tokens=800,
|
22 |
+
top_p=0.95,
|
23 |
+
frequency_penalty=0,
|
24 |
+
presence_penalty=0,
|
25 |
+
stop=None)
|
26 |
+
response = choices.choices[0].message.content
|
27 |
+
print(response)
|
28 |
+
return response
|
29 |
+
|
30 |
+
|
31 |
+
iface = gr.Interface(fn=chatbot,
|
32 |
+
inputs=gr.inputs.Textbox(
|
33 |
+
label="Provide an assignment to evaluate."),
|
34 |
+
outputs="text",
|
35 |
+
title="Formative Feedback")
|
36 |
+
|
37 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
openai
|
2 |
+
gradio
|