Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,9 @@
|
|
| 1 |
import os
|
| 2 |
-
|
| 3 |
-
os.environ['GOOGLE_API_KEY'] = "AIzaSyA5LzhPqWiUEEms-AnlYqI75C8YhggrMkw"
|
| 4 |
-
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 5 |
-
import google.generativeai as genai
|
| 6 |
import openai
|
| 7 |
-
os.environ["OPENAI_API_KEY"] =
|
| 8 |
openai.api_key = "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"
|
| 9 |
|
| 10 |
-
def
|
| 11 |
messages = [{"role": "user", "content": prompt}]
|
| 12 |
response = openai.ChatCompletion.create(
|
| 13 |
model=model,
|
|
@@ -57,11 +53,6 @@ def generate_questions(topic):
|
|
| 57 |
print(f"Context: {mcqs}")
|
| 58 |
question = extract_questions(mcqs)
|
| 59 |
return question, mcqs
|
| 60 |
-
def get_completion(text):
|
| 61 |
-
|
| 62 |
-
model = genai.GenerativeModel('gemini-pro')
|
| 63 |
-
response = model.generate_content(text)
|
| 64 |
-
return response.text
|
| 65 |
|
| 66 |
def extract_questions(mcq):
|
| 67 |
prompt_sum = f'''Given questions {mcq}, select one question and present to the user with the options. Do not show the correct answer.'''
|
|
|
|
| 1 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import openai
|
| 3 |
+
os.environ["OPENAI_API_KEY"] = os.getenv('openai')
|
| 4 |
openai.api_key = "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"
|
| 5 |
|
| 6 |
+
def get_completion(prompt, model="gpt-3.5-turbo"):
|
| 7 |
messages = [{"role": "user", "content": prompt}]
|
| 8 |
response = openai.ChatCompletion.create(
|
| 9 |
model=model,
|
|
|
|
| 53 |
print(f"Context: {mcqs}")
|
| 54 |
question = extract_questions(mcqs)
|
| 55 |
return question, mcqs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
def extract_questions(mcq):
|
| 58 |
prompt_sum = f'''Given questions {mcq}, select one question and present to the user with the options. Do not show the correct answer.'''
|