-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
manage values, save and retrieve, handlers
- Loading branch information
1 parent
0ff791f
commit ad09777
Showing
5 changed files
with
99 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# The dictionary should contain all the block types for which the chat should be | ||
# applicable If a block has sub-blocks or sub category, that should be added in the list | ||
# applicable if a block has sub-blocks or sub category, that should be added in the list | ||
CHAT_APPLICABLE_BLOCKS = ["problem", "video"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
<body> | ||
<div class="form-container"> | ||
<form id="ol-chat-form"> | ||
<!-- Text Fields --> | ||
<label for="prompt_hint">Enter prompt hint:</label> | ||
<input type="text" id="prompt_hint" name="prompt_hint" placeholder="Enter prompt text" value="{{ prompt_hint }}" required> | ||
|
||
<div class="form-container"> | ||
<form id="ol-chat-form"> | ||
<!-- Text Fields --> | ||
<label for="prompt_hint">Enter prompt hint:</label> | ||
<input type="text" id="prompt_hint" name="prompt_hint" placeholder="Enter prompt text" required> | ||
<!-- Dropdown --> | ||
<label for="model">Select an LLM Model:</label> | ||
<select id="model_dropdown" name="model" value="{{gpt_model}}" required> | ||
<option value="">-- Select an LLM Model --</option> | ||
<option {% if gpt_model == 'GPT-4o' %} selected {% endif %}>GPT-4o</option> | ||
<option {% if gpt_model == 'gpt-4-turbo' %} selected {% endif %}>gpt-4-turbo</option> | ||
<option {% if gpt_model == 'gpt-3.5-turbo' %} selected {% endif %}>gpt-3.5-turbo</option> | ||
</select> | ||
|
||
<!-- Dropdown --> | ||
<label for="model">Select a Model:</label> | ||
<select id="model" name="model" required> | ||
<option value="">-- Select a GPT Model --</option> | ||
<option value="model1">GPT-4o</option> | ||
<option value="model2">gpt-4-turbo</option> | ||
<option value="model1">gpt-3.5-turbo</option> | ||
</select> | ||
<!-- Checkbox --> | ||
<div class="checkbox-container"> | ||
<label><input type="checkbox" id="enabled" name="enabled" {% if is_enabled %} checked {% endif %}/>Enabled</label> | ||
</div> | ||
|
||
<!-- Checkbox --> | ||
<div class="checkbox-container"> | ||
<label><input type="checkbox" id="enabled" name="enabled"/>Enabled</label> | ||
</div> | ||
|
||
<!-- Save Button --> | ||
<button type="submit">Save</button> | ||
</form> | ||
</div> | ||
</body> | ||
</html> | ||
<!-- Save Button --> | ||
<button type="submit" id="save-chat-config">Save</button> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
resources( | ||
name="ol_chat_js", | ||
sources=["src_js/*.js","lib/*.js"], | ||
sources=["*.js"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
(function($) { | ||
'use strict'; | ||
|
||
function OpenLearningChatView(runtime, element) { | ||
const saveButton = element.querySelector("#save-chat-config"); | ||
|
||
const chat_form = element.querySelector("#ol-chat-form") | ||
chat_form.addEventListener("submit", function(event) { | ||
event.preventDefault(); | ||
var studioRuntime = new window.StudioRuntime.v1(); | ||
|
||
const promptHintField = element.querySelector("#prompt_hint"); | ||
const modelDropdown = element.querySelector("#model_dropdown"); | ||
const enabledCheck = element.querySelector("#enabled"); | ||
// Get the handler URL | ||
const handlerUrl = studioRuntime.handlerUrl(element, 'update_chat_config'); | ||
var dataToPost = {"prompt": promptHintField.value, "gpt_model": modelDropdown.value, "is_enabled": enabledCheck.checked}; | ||
|
||
$.ajax({ | ||
url: handlerUrl, | ||
method: 'POST', | ||
data: JSON.stringify(dataToPost), | ||
contentType: 'application/json; charset=utf-8', | ||
success: function (response) { | ||
// Handle successful response | ||
alert("Saved successfully!"); | ||
}, | ||
error: function (xhr, status, error) { | ||
// Handle error response | ||
alert("Some Error!!!"); | ||
} | ||
}); | ||
|
||
}); | ||
} | ||
function initializeOLChat(runtime, element) { | ||
return new OpenLearningChatView(runtime, element); | ||
} | ||
|
||
window.OLChatInit = initializeOLChat; | ||
}($)); |