-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
43 lines (35 loc) · 1.09 KB
/
setup.py
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
import mindsdb_sdk
import os
import sqlite3
from dotenv import load_dotenv
load_dotenv()
# Connecting to the database and create the table
db_path = os.path.abspath(os.getcwd()) + "\\quiz_database.db"
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS quiz_table (
topic TEXT,
question TEXT,
option_a TEXT,
option_b TEXT,
option_c TEXT,
option_d TEXT,
correct_answer CHAR(1)
)
""")
server = mindsdb_sdk.connect()
server.ml_engines.create(
"minds_endpoint_engine",
"minds_endpoint",
connection_data={"minds_endpoint_api_key": os.getenv("API_KEY")},
)
project = server.create_project("ai_quiz_bot")
project = server.get_project("ai_quiz_bot")
project.models.create(
name="quizzes_generator",
predict="quiz_data",
engine="minds_endpoint_engine",
max_tokens=512,
prompt_template="Generate only {{number_of_questions}} short quiz questions about {{topic}} with 4 multiple-choice options (A, B, C, D) and the correct option letter. Format the output in parsable json as: [{'q':...,A,B,C,D,correct},{...}]",
)