Skip to content

Commit 02f340d

Browse files
committed
add course attribute for async LLM modes
1 parent 72c1da2 commit 02f340d

7 files changed

Lines changed: 35 additions & 11 deletions

File tree

bases/rsptx/admin_server_api/routers/instructor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ async def get_course_settings(
378378
"enable_compare_me": course_attrs.get("enable_compare_me", "false"),
379379
"show_points": course_attrs.get("show_points") == "true",
380380
"groupsize": course_attrs.get("groupsize", "3"),
381+
"enable_async_llm_modes": course_attrs.get("enable_async_llm_modes", "false"),
381382
}
382383

383384
return templates.TemplateResponse("admin/instructor/course_settings.html", context)

bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/AssignmentExercisesList/AssignmentExercisesTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const AssignmentExercisesTable = ({
123123
const [reorderExercises] = useReorderAssignmentExercisesMutation();
124124
const [updateAssignmentQuestions] = useUpdateAssignmentQuestionsMutation();
125125
const { selectedAssignment } = useSelectedAssignment();
126-
const { data: hasApiKey = false } = useHasApiKeyQuery();
126+
const { data: { hasApiKey = false, asyncLlmModesEnabled = false } = {} } = useHasApiKeyQuery();
127127
const isPeerAsync =
128128
selectedAssignment?.kind === "Peer" && selectedAssignment?.peer_async_visible === true;
129129
const dataTableRef = useRef<DataTable<Exercise[]>>(null);
@@ -354,7 +354,7 @@ export const AssignmentExercisesTable = ({
354354
/>
355355
)}
356356
/>
357-
{isPeerAsync && (
357+
{isPeerAsync && asyncLlmModesEnabled && (
358358
<Column
359359
resizeable={false}
360360
style={{ width: "12rem" }}

bases/rsptx/assignment_server_api/assignment_builder/src/store/assignmentExercise/assignmentExercise.logic.api.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,17 @@ export const assignmentExerciseApi = createApi({
167167
body
168168
})
169169
}),
170-
hasApiKey: build.query<boolean, void>({
170+
hasApiKey: build.query<{ hasApiKey: boolean; asyncLlmModesEnabled: boolean }, void>({
171171
query: () => ({
172172
method: "GET",
173173
url: "/assignment/instructor/has_api_key"
174174
}),
175-
transformResponse: (response: DetailResponse<{ has_api_key: boolean }>) =>
176-
response.detail.has_api_key
175+
transformResponse: (
176+
response: DetailResponse<{ has_api_key: boolean; async_llm_modes_enabled: boolean }>
177+
) => ({
178+
hasApiKey: response.detail.has_api_key,
179+
asyncLlmModesEnabled: response.detail.async_llm_modes_enabled
180+
})
177181
}),
178182
copyQuestion: build.mutation<
179183
DetailResponse<{ status: string; question_id: number; message: string }>,

bases/rsptx/assignment_server_api/routers/instructor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,10 +1391,16 @@ async def add_api_token(
13911391
@instructor_role_required()
13921392
@with_course()
13931393
async def has_api_key(request: Request, user=Depends(auth_manager), course=None):
1394-
"""Return whether the course has at least one API token configured."""
1394+
"""Return whether the course has at least one API token configured and whether async LLM modes are enabled."""
13951395
tokens = await fetch_all_api_tokens(course.id)
1396+
course_attrs = await fetch_all_course_attributes(course.id)
1397+
async_llm_modes_enabled = course_attrs.get("enable_async_llm_modes", "false") == "true"
13961398
return make_json_response(
1397-
status=status.HTTP_200_OK, detail={"has_api_key": len(tokens) > 0}
1399+
status=status.HTTP_200_OK,
1400+
detail={
1401+
"has_api_key": len(tokens) > 0,
1402+
"async_llm_modes_enabled": async_llm_modes_enabled,
1403+
},
13981404
)
13991405

14001406

bases/rsptx/web2py_server/applications/runestone/controllers/peer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,12 @@ def peer_async():
766766
(db.assignment_questions.assignment_id == assignment_id)
767767
& (db.assignment_questions.question_id == current_question.id)
768768
).select().first()
769-
question_use_llm = bool(aq.use_llm) if aq else False
770-
llm_enabled = _llm_enabled() and question_use_llm
769+
async_llm_modes_enabled = course_attrs.get("enable_async_llm_modes", "false") == "true"
770+
if async_llm_modes_enabled:
771+
question_use_llm = bool(aq.use_llm) if aq else False
772+
llm_enabled = _llm_enabled() and question_use_llm
773+
else:
774+
llm_enabled = _llm_enabled()
771775
try:
772776
db.useinfo.insert(
773777
course_id=auth.user.course_name,

bases/rsptx/web2py_server/applications/runestone/views/peer/peer_async.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h2>Peer Instruction Question (After Class)</h2>
5454
<li>Answer the question as best you can.</li>
5555
<li>Then, in the space provided write a justification for your answer.</li>
5656
{{ if llm_enabled: }}
57-
<li>Discuss the question with an AI peer — explain your reasoning and respond to their questions.</li>
57+
<li>Discuss the question with an LLM peer — explain your reasoning and respond to their questions.</li>
5858
{{ else: }}
5959
<li>Read the discussion between other students on why they answered the question the way they did.</li>
6060
{{ pass }}
@@ -359,7 +359,7 @@ <h3>Congratulations, you have completed this assignment!</h3>
359359
const disclaimer = document.getElementById("llmDisclaimer");
360360
if (disclaimer) disclaimer.style.display = "block";
361361
}
362-
chat.innerHTML = "<p><em>Thinking about your explanation…</em></p>";
362+
chat.innerHTML = "<p><em>Processing your explanation…</em></p>";
363363

364364
async function showStandardDiscussion(chat, nextStep, showInstructorNote) {
365365
const resp = await fetch("/runestone/peer/get_async_explainer", {

components/rsptx/templates/admin/instructor/course_settings.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ <h3>{{ course.course_name }}</h3>
215215
<div class="setting-description">Display points instead of percentages (default is percent)</div>
216216
</div>
217217

218+
<div class="settingsbox">
219+
<div class="checkbox-container">
220+
<input type="checkbox" id="async_llm_modes" {% if enable_async_llm_modes=="true" %}checked{% endif %}
221+
onchange="updateCourse(this,'enable_async_llm_modes')">
222+
<label for="async_llm_modes">Enable Async LLM Modes for Peer Instruction</label>
223+
</div>
224+
<div class="setting-description">Allow per-question LLM chat mode selection in asynchronous peer instruction activities</div>
225+
</div>
226+
218227
<div class="settingsbox">
219228
<label for="groupsize">Group Size for Peer Instruction</label>
220229
<select id="groupsize" onchange="updateCourse(this,'groupsize')">

0 commit comments

Comments
 (0)