Refactor and simplify API
There should (for now) be only these endpoints:
-
/register: This is a post endpoint. Mostly as the current endpoint regarding registration: takes a CAS jwt and the username to register for a course. the course should be a payload json "course_name" : "...". error returned if course does not exist (currently only gdds). On the same register endpoint, if we do a post request as a admin user (should be verified via the jwt), we can enroll students manually into courses, and as administrator. The Payload should be a json with {"action": "register_user", user: "cas login name", "course":"course_name"}, or {"action":"register_administrator", ...}. For a simple user to register themselves, it should be {"action" : "register_self", "course" : "course_name"}, and the username is read from the jwt.
-
/info: get request, simply return the current version, and an array of all available models to query, and if the user is an admin. the version will be stored in future deployments in a environment variable set during deployment of the docker container. $PROMP_GENERATOR_API_VERSION. available models should be stored in e.g., the database, same as user info.
-
/prompt: The only prompt endpoint, the payload determines what to do. Multiple optinal parameters. In the backend, there should be a default json that is merged with the submitted version. Certain values can only be overwritten as an admin, this is easily setup with a simple function, an example is here:
def merge_json(a, b, overwrite=false):
for k, v in b.items():
if isinstance(v, dict) and k in a and isinstance(a[k], dict):
merge_json(a[k], v, strategy)
elif overwrite or k not in a:
a[k] = v
return a
Example, formatted by chat-gpt because i'm too lazy:
{
// POST /api/evaluate-prompt
// --- USER REQUEST (default) ---
"user_request": {
"prompt": "default", // regular users can only use the default prompt
"prompt_data": {
"notebook": "notebook_123", // notebook identifier or serialized content
"cell_id": "abc123hash", // hash/id of the cell being evaluated
"messages": [
// complete conversation history visible to the user
{ "role": "user", "content": "I tried to implement a sorting algorithm..." },
{ "role": "assistant", "content": "You're missing a return statement." }
]
}
},
// --- ADMIN REQUEST (custom prompt) ---
"admin_request": {
"prompt": "custom", // admin can use a custom system prompt
"prompt_data": {
"messages": [
// arbitrary conversation structure, including system messages
{ "role": "system", "content": "You are a teaching assistant for Python exercises." },
{ "role": "user", "content": "Explain this student's error clearly but briefly." },
{ "role": "assistant", "content": "Sure, send me the code." }
],
"insert_solution": true, // optionally include model solution in evaluation
"insert_hints": true, // optionally include model solution in evaluation
"llm": {
"model_name": "qwen-3",
"model_parameters": {
"temperature": 0.7,
"top_p": 0.8,
"presence_penalty": 1,
"max_tokens": 16384,
"timeout": 60 // optional override for default timeout
}
}
}
},
// --- BACKEND DEFAULTS (applied to user requests, merged with admin request.) ---
"backend_defaults": {
"prompt": "default",
"llm": {
"model_name": "qwen-3",
"model_parameters": {
"temperature": 0.7,
"top_p": 0.8,
"presence_penalty": 1,
"max_tokens": 16384,
"timeout": 30
}
},
"insert_solution": false
}
}
And finally, a simple endpoint for downloading the files (this can be kept mostly as is). Should simply be "/download_course_files/", and check if the user is enrolled in the course (via CAS jwt) that is requested, or an admin (can download all).