Spaces:
Paused
Paused
Commit
•
f030680
1
Parent(s):
35c46f4
Update main.py
Browse files
main.py
CHANGED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pathlib
|
3 |
+
import textwrap
|
4 |
+
import google.generativeai as genai
|
5 |
+
# from google.colab import userdata # Used to securely store the API key
|
6 |
+
# from IPython.display import display
|
7 |
+
from IPython.display import Markdown
|
8 |
+
import warnings
|
9 |
+
warnings.filterwarnings("ignore")
|
10 |
+
|
11 |
+
|
12 |
+
os.environ["GOOGLE_API_KEY"] = "AIzaSyDeEFxbAE5isnFWJK-cliU7tAS_mOjTan4"
|
13 |
+
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
|
14 |
+
|
15 |
+
model = genai.GenerativeModel("gemini-pro")
|
16 |
+
|
17 |
+
|
18 |
+
def to_markdown(text):
|
19 |
+
text = text.replace(".", "* ")
|
20 |
+
return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
|
21 |
+
|
22 |
+
# Define MCQ generator function
|
23 |
+
def mcq_generator(programming, level, number_of_questions):
|
24 |
+
response = model.generate_content(f"Write {number_of_questions} MCQ questions for language {programming} with level {level} and answer also.")
|
25 |
+
return response.text
|