Spaces:
Runtime error
Runtime error
setting key and llm
Browse files
app.py
CHANGED
@@ -19,8 +19,8 @@ index_file = "vector_stores/canvas-discussions.index"
|
|
19 |
grading_model = 'gpt-4'
|
20 |
qa_model = 'gpt-3.5-turbo-16k'
|
21 |
|
22 |
-
llm =
|
23 |
-
embeddings =
|
24 |
|
25 |
grader = None
|
26 |
grader_qa = None
|
@@ -71,7 +71,8 @@ def set_model(history):
|
|
71 |
|
72 |
|
73 |
def ingest(url, canvas_api_key, openai_api_key, history):
|
74 |
-
global grader
|
|
|
75 |
text = f"Download data from {url} and ingest it to grade discussions"
|
76 |
ingest_canvas_discussions(url, canvas_api_key)
|
77 |
grader = Grader(grading_model)
|
@@ -80,6 +81,13 @@ def ingest(url, canvas_api_key, openai_api_key, history):
|
|
80 |
return get_grading_status(history)
|
81 |
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
def start_grading(url, canvas_api_key, openai_api_key, history):
|
84 |
global grader, grader_qa
|
85 |
text = f"Start grading discussions from {url}"
|
|
|
19 |
grading_model = 'gpt-4'
|
20 |
qa_model = 'gpt-3.5-turbo-16k'
|
21 |
|
22 |
+
llm = None
|
23 |
+
embeddings = None
|
24 |
|
25 |
grader = None
|
26 |
grader_qa = None
|
|
|
71 |
|
72 |
|
73 |
def ingest(url, canvas_api_key, openai_api_key, history):
|
74 |
+
global grader, llm, embeddings
|
75 |
+
set_key_and_llm(openai_api_key)
|
76 |
text = f"Download data from {url} and ingest it to grade discussions"
|
77 |
ingest_canvas_discussions(url, canvas_api_key)
|
78 |
grader = Grader(grading_model)
|
|
|
81 |
return get_grading_status(history)
|
82 |
|
83 |
|
84 |
+
def set_key_and_llm(openai_api_key):
|
85 |
+
global llm, embeddings
|
86 |
+
os.environ['OPENAI_API_KEY'] = openai_api_key
|
87 |
+
llm = ChatOpenAI(model_name=qa_model, temperature=0, verbose=True)
|
88 |
+
embeddings = OpenAIEmbeddings(model='text-embedding-ada-002')
|
89 |
+
|
90 |
+
|
91 |
def start_grading(url, canvas_api_key, openai_api_key, history):
|
92 |
global grader, grader_qa
|
93 |
text = f"Start grading discussions from {url}"
|