Skip to content

Commit

Permalink
added more info, configs and a shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Ariton authored and Adrian Ariton committed Nov 16, 2023
1 parent 107594a commit 6deff3b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 20 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ navigate to that directory and start a simple Python server:
python -m http.server
```

## Building and adding chattutor

Check out the README.md file in chattutor_setup folder,
or simply run

```sh
./build.sh```
## Development
The majority of this book is written as Jupyter notebooks. Learn more about
Expand Down
29 changes: 21 additions & 8 deletions book/chattutor_setup/chattutor.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@
*
* COURSE_URL: the base url for the course
*
* SERVER_PORT: the port listen to Chattutor
* server if ran locally. Used ONLY for testing
* purposes
*
* RUN_LOCALLY: true if and only if course is tested
* locally. For production it should be false,
* for testing it should be true.
*
* IS_STATIC: true if ran statically on a index.html
* file, false if ran on a server, either local or online
* Usually true for jupyter books
*/
const RUN_LOCALLY = true;
const TEST_MODE = false;
const IS_STATIC = true;

const EMBEDDING_COLLECTION_NAME = "photonicsbootcamp12";
const TEST_MODE = true;
const COURSE_URL = "https://byucamacholab.github.io/Photonics-Bootcamp"
const SERVER_PORT = 5000
const COURSE_URL = "https://byucamacholab.github.io/Photonics-Bootcamp"
/**
* --------------- TESTING CONFIGS ----------------
* ChatTutor can be embedded on default applications
Expand All @@ -61,9 +68,15 @@ const SERVER_PORT = 5000
*
* This configuration is ONLY used for testing and
* will have no weight in production mode
* (TEST_MODE = false)
* (RUN_LOCALLY = false)
*
* SERVER_PORT: the port listen to Chattutor
* server if ran locally. Used ONLY for testing
* purposes (TEST_MODE = false)
*/
const BUILT_WITH = "JUPYTER-NOTEBOOK"
const BUILT_WITH = "JUPYTER-NOTEBOOK"
const SERVER_PORT = 5000

/**
* JUPYTER-NOTEBOOK Specific configurations.
*/
Expand Down
14 changes: 2 additions & 12 deletions book/chattutor_setup/chattutor.min.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Configures UI
const embed_mode = true;


// Constants for embed mode and UI elements

// import {lightMode, darkMode, setProperties} from "./constants.js";
// import {alert} from "./nicealert.js"
// import { clearFileInput } from "./fileupload.js";
// import { JSONparse } from "./jsonparse.js";
// import { chattutor_embed } from "./chattutor.html.js";
// import { setFromDoc, clearFromDoc } from "./from_doc_ext.js";

let headers = new Headers();

headers.append('Content-Type', 'application/json');
Expand Down Expand Up @@ -45,7 +35,7 @@ var conversation = [];
var original_file = "";
let lastMessageId = null;
var stopGeneration = false
let selectedModel = "gpt-3.5-turbo" //document.getElementById('modelDropdown').value
let selectedModel = "gpt-3.5-turbo"

function setupEmbedMode_URL() {

Expand All @@ -59,7 +49,7 @@ function setupEmbedMode_URL() {
})

path = window.location.pathname
if (BUILT_WITH == "JUPYTER-NOTEBOOK" && TEST_MODE == true) {
if (BUILT_WITH == "JUPYTER-NOTEBOOK" && RUN_LOCALLY == true && IS_STATIC == true) {
const BUILD_HTML_JUPYTER_NOTEBOOK_FOLDER = "_build/html"
ind = path.indexOf(BUILD_HTML_JUPYTER_NOTEBOOK_FOLDER);
end = ind + BUILD_HTML_JUPYTER_NOTEBOOK_FOLDER.length;
Expand Down
40 changes: 40 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
jupyter-book build --all book
python3 ./book/chattutor_setup/install.py
bold=$(tput bold)
normal=$(tput sgr0)
GREEN='\033[1;32m'
NC='\033[0m' # No Color
echo "
"
printf "${GREEN}===============================================================================${NC}
The course is now built and ${bold}chattutor ${normal}is added to it.
• To bypass CORS issue when testing on a local server/
static page (if ${bold}TEST_MODE ${normal}is set to false in
${bold}chattutor.config.js${normal}), start chrome with --disable-security
option:
Examples:
${bold}MACOS${normal}:
$ open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security
${bold}LINUX${normal}:
$ google-chrome --disable-web-security
(*) If you need access to local files for dev purposes like AJAX or JSON, you can use --allow-file-access-from-files flag.
"
echo "
${bold}WINDOWS${normal}:
$ "C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-web-security --disable-gpu --user-data-dir=%LOCALAPPDATA%\Google\chromeTemp
! Since Chrome 22+ you will get an error message that says:
⚠ You are using an unsupported command-line flag: --disable-web-security. Stability and security will suffer.
"
echo "
However you can just ignore that message while developing.
"

0 comments on commit 6deff3b

Please sign in to comment.