Skip to content

Commit 5e89c5f

Browse files
committed
Merge branch 'main' of github.com:sethbern/rs into sethbern-main
2 parents 36c319a + 0ccdc6e commit 5e89c5f

File tree

3 files changed

+49
-12
lines changed

3 files changed

+49
-12
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,15 +1049,38 @@ def _llm_enabled():
10491049
return bool(_get_course_openai_key())
10501050

10511051
#fetch the course-wide openai API key used to enable LLM-based async peer discussion (only works for openai currently)
1052+
# def _get_course_openai_key():
1053+
# try:
1054+
# token_record = asyncio.get_event_loop().run_until_complete(
1055+
# fetch_api_token(course_id=auth.user.course_id, provider="openai")
1056+
# )
1057+
# if token_record and token_record.token:
1058+
# return token_record.token.strip()
1059+
# except Exception:
1060+
# logger.exception("Failed to fetch course-wide OpenAI token for peer LLM")
1061+
# return ""
10521062
def _get_course_openai_key():
10531063
try:
1064+
course = db(
1065+
db.courses.course_name == auth.user.course_name
1066+
).select().first()
1067+
1068+
if not course:
1069+
logger.warning("PEER LLM: no course row found")
1070+
return ""
1071+
logger.warning(f"PEER LLM course_name={auth.user.course_name}")
1072+
logger.warning(f"PEER LLM auth.user.course_id={auth.user.course_id}")
1073+
logger.warning(f"PEER LLM resolved course.id={course.id if course else None}")
10541074
token_record = asyncio.get_event_loop().run_until_complete(
1055-
fetch_api_token(course_id=auth.user.course_id, provider="openai")
1075+
fetch_api_token(course_id=course.id, provider="openai")
10561076
)
1077+
10571078
if token_record and token_record.token:
10581079
return token_record.token.strip()
1080+
10591081
except Exception:
10601082
logger.exception("Failed to fetch course-wide OpenAI token for peer LLM")
1083+
10611084
return ""
10621085

10631086

@@ -1088,4 +1111,4 @@ def _call_openai(messages):
10881111
logger.warning(f"PEER LLM CALL | provider=openai-course-token | model={model}")
10891112
resp.raise_for_status()
10901113
data = resp.json()
1091-
return data["choices"][0]["message"]["content"].strip()
1114+
return data["choices"][0]["message"]["content"].strip()

bases/rsptx/web2py_server/applications/runestone/static/js/peer.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Configuration for the PI steps and helper functions to handle step progression in the instructor's interface
2+
console.log("PEER JS VERSION TEST 12345");
23
const STEP_CONFIG = {
34
vote1: {
45
next: ['makep', 'facechat', 'makeabgroups'],
@@ -485,15 +486,17 @@ async function sendMessage(event) {
485486
input.value = "";
486487
input.focus();
487488

488-
// Disable the send button after sending a message
489-
sendButton.classList.add("disabled");
490-
llmMessageCount += 1;
491-
console.log("LLM message count:", llmMessageCount);
489+
// Only apply LLM restrictions in async mode
490+
if (window.PI_LLM_MODE === true) {
491+
sendButton.classList.add("disabled");
492+
llmMessageCount += 1;
493+
console.log("LLM message count:", llmMessageCount);
492494

493-
if (llmMessageCount >= REQUIRED_LLM_MESSAGES) {
494-
const btn = document.getElementById("readyVote2Btn");
495-
if (btn) {
496-
btn.style.display = "inline-block";
495+
if (llmMessageCount >= REQUIRED_LLM_MESSAGES) {
496+
const btn = document.getElementById("readyVote2Btn");
497+
if (btn) {
498+
btn.style.display = "inline-block";
499+
}
497500
}
498501
}
499502
}
@@ -857,6 +860,11 @@ function insertReadyVote2Button() {
857860

858861
if (!container) return;
859862

863+
const btn = document.createElement("button");
864+
btn.id = "readyVote2Btn";
865+
btn.className = "btn btn-info";
866+
btn.style.display = "none";
867+
btn.innerText = "Ready for Vote 2";
860868

861869
btn.addEventListener("click", enableSecondVoteAsync);
862870

@@ -868,11 +876,16 @@ $(function () {
868876

869877
let tinput = document.getElementById("messageText");
870878
let sendButton = document.getElementById("sendpeermsg");
871-
if (tinput && sendButton) {
879+
if (window.PI_LLM_MODE !== true && sendButton) {
880+
sendButton.classList.remove("disabled");
881+
}
882+
883+
if (tinput && sendButton && window.PI_LLM_MODE === true) {
872884
tinput.addEventListener("input", function () {
873885
let message = this.value.trim();
874-
if (message !== "") {
886+
if (window.PI_LLM_MODE !== true && sendButton) {
875887
sendButton.classList.remove("disabled");
888+
sendButton.disabled = false;
876889
} else {
877890
sendButton.classList.add("disabled");
878891
}

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ services:
183183
- DBURL=${DC_DBURL:-$DBURL}?ssl=disable
184184
- LOAD_BALANCER_HOST=${LOAD_BALANCER_HOST}
185185
- JWT_SECRET=${JWT_SECRET}
186+
- FERNET_SECRET=${FERNET_SECRET}
186187
- WEB2PY_PRIVATE_KEY=${WEB2PY_PRIVATE_KEY}
187188
- ACADEMY_MODE=True
188189
- USE_MASTER_AUTHOR=${USE_MASTER_AUTHOR:-False}

0 commit comments

Comments
 (0)