|
|
@ -13,8 +13,41 @@ |
|
|
|
</head> |
|
|
|
</head> |
|
|
|
<body> |
|
|
|
<body> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="module"> |
|
|
|
|
|
|
|
import { Wllama } from 'https://github.ngxson.com/wllama/esm/index.js'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(async () => { |
|
|
|
|
|
|
|
const ROOT_PATH = 'https://github.ngxson.com/wllama/examples/basic/' |
|
|
|
|
|
|
|
const CONFIG_PATHS = { |
|
|
|
|
|
|
|
'single-thread/wllama.js' : ROOT_PATH+'../../esm/single-thread/wllama.js', |
|
|
|
|
|
|
|
'single-thread/wllama.wasm' : ROOT_PATH+'../../esm/single-thread/wllama.wasm', |
|
|
|
|
|
|
|
'multi-thread/wllama.js' : ROOT_PATH+'../../esm/multi-thread/wllama.js', |
|
|
|
|
|
|
|
'multi-thread/wllama.wasm' : ROOT_PATH+'../../esm/multi-thread/wllama.wasm', |
|
|
|
|
|
|
|
'multi-thread/wllama.worker.mjs': ROOT_PATH+'../../esm/multi-thread/wllama.worker.mjs', |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
// Automatically switch between single-thread and multi-thread version based on browser support |
|
|
|
|
|
|
|
// If you want to enforce single-thread, add { "n_threads": 1 } to LoadModelConfig |
|
|
|
|
|
|
|
window.wllama = new Wllama(CONFIG_PATHS);await wllama.loadModelFromUrl( |
|
|
|
|
|
|
|
//"https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K.gguf" |
|
|
|
|
|
|
|
'https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories15M-q4_0.gguf' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function noteFromPrompt(prompt){ |
|
|
|
|
|
|
|
let y = 1.5 + Math.random() - .5 |
|
|
|
|
|
|
|
wllama.createCompletion(prompt, { |
|
|
|
|
|
|
|
nPredict: parseInt(10), |
|
|
|
|
|
|
|
sampling: { temp: 0.5, top_k: 40, top_p: 0.9, }, |
|
|
|
|
|
|
|
onNewToken: (token, piece, currentText) => { |
|
|
|
|
|
|
|
console.log( currentText ); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}).then( finalText => addNewNoteAsPostItNote(finalText, '0.2 '+y+' -.5') ) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//________________________________________________________________ |
|
|
|
//________________________________________________________________ |
|
|
|
const endpointDomainOrIP = '192.168.0.129' // note that if the certificate is NOT proper, then consider opening it first to accept it on device |
|
|
|
const endpointDomainOrIP = '192.168.0.129' // note that if the certificate is NOT proper, then consider opening it first to accept it on device |
|
|
|
// e.g https://hmd.link/?https://192.168.0.129:8443/ |
|
|
|
// e.g https://hmd.link/?https://192.168.0.129:8443/ |
|
|
@ -210,7 +243,7 @@ function parseSpeech( speechContent ) { |
|
|
|
// to consider for redo |
|
|
|
// to consider for redo |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
addedContent.push( addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") ) |
|
|
|
if (speechContent) addedContent.push( addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") ) |
|
|
|
// could become jxr code proper later, also allowing to re-execute a command again |
|
|
|
// could become jxr code proper later, also allowing to re-execute a command again |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -526,66 +559,11 @@ setTimeout( _ => { |
|
|
|
<a-sky hide-on-enter-ar color="lightgray"></a-sky> |
|
|
|
<a-sky hide-on-enter-ar color="lightgray"></a-sky> |
|
|
|
<a-troika-text anchor=left target value="instructions : \n--right pinch to move\n--left pinch to execute" position="0 0.65 -0.2" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
<a-troika-text anchor=left target value="instructions : \n--right pinch to move\n--left pinch to execute" position="0 0.65 -0.2" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
|
|
|
|
<a-troika-text anchor=left value="jxr onNextPrimaryPinch(deleteTarget)" target position=" -0.3 1.50 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
<a-troika-text anchor=left value="jxr onNextPrimaryPinch(cloneTarget)" target position=" -0.3 1.60 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-troika-text anchor=left value="jxr location.reload()" target position=" -0.3 1.30 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
<a-troika-text anchor=left value="jxr location.reload()" target position=" -0.3 1.30 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
<a-troika-text anchor=left value="jxr makeAnchorsVisibleOnTargets()" target position=" -0.3 1.20 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
<a-troika-text anchor=left value="jxr makeAnchorsVisibleOnTargets()" target position=" -0.3 1.20 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
|
|
|
|
<a-troika-text anchor=left value="forceXaxis toggling" |
|
|
|
<a-troika-text anchor=left value="jxr noteFromPrompt( 'hi said the penguin' )" target position=" -0.3 1.45 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
onreleased="console.log('run on released');forceXaxis=!forceXaxis" |
|
|
|
|
|
|
|
onpicked="console.log('run on picked');forceXaxis=!forceXaxis" |
|
|
|
|
|
|
|
target position=" -0.3 1.45 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-troika-text anchor=left value="translate targets" |
|
|
|
|
|
|
|
onreleased="toggleTranslateTargets()" |
|
|
|
|
|
|
|
onpicked="toggleTranslateTargets()" |
|
|
|
|
|
|
|
target position=" 1 1.45 -.2" rotation="0 -40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-troika-text anchor=left value="jxr setTimeout( _ => toggleAttachToSelf(), 1000); toggleAttachToSelf()" target position=" -0.3 1.25 0" rotation="0 40 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-box scale=".07 .07 .07" class="mab" target position=".3 1.6 -.5" color="brown" onreleased="snapMAB()" > |
|
|
|
|
|
|
|
<a-box scale="1.5 1.5 1" color="brown"></a-box> |
|
|
|
|
|
|
|
<a-box scale="1 1.5 1.5" color="brown"></a-box> |
|
|
|
|
|
|
|
<a-box scale="1.5 1 1.5" color="brown"></a-box> |
|
|
|
|
|
|
|
</a-box> |
|
|
|
|
|
|
|
<a-box scale=".07 .07 .07" class="mab" target position=".1 1.6 -.5" color="brown" onreleased="snapMAB()" > |
|
|
|
|
|
|
|
<a-box scale="1.5 1.5 1" color="brown"></a-box> |
|
|
|
|
|
|
|
<a-box scale="1 1.5 1.5" color="brown"></a-box> |
|
|
|
|
|
|
|
<a-box scale="1.5 1 1.5" color="brown"></a-box> |
|
|
|
|
|
|
|
</a-box> |
|
|
|
|
|
|
|
<a-box scale=".07 .07 .07" class="mab" target position=".5 1.6 -.5" color="brown" onreleased="snapMAB()" > |
|
|
|
|
|
|
|
<a-box scale="1.5 1.5 1" color="brown"></a-box> |
|
|
|
|
|
|
|
<a-box scale="1 1.5 1.5" color="brown"></a-box> |
|
|
|
|
|
|
|
<a-box scale="1.5 1 1.5" color="brown"></a-box> |
|
|
|
|
|
|
|
</a-box> |
|
|
|
|
|
|
|
<a-box scale=".07 .07 .07" class="mab" target position="-.5 1.6 -.5" color="brown" onreleased="snapMAB()" > |
|
|
|
|
|
|
|
<a-box scale="1.5 1.5 1" color="brown"></a-box> |
|
|
|
|
|
|
|
<a-box scale="1 1.5 1.5" color="brown"></a-box> |
|
|
|
|
|
|
|
<a-box scale="1.5 1 1.5" color="brown"></a-box> |
|
|
|
|
|
|
|
</a-box> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-box scale=".1 .1 .1" target position=".5 1.6 -.3" color="blue" onreleased="snapToGrid()" |
|
|
|
|
|
|
|
annotation="content:could also show/hide grid with gridHelper on pinch started and hide on release" |
|
|
|
|
|
|
|
></a-box> |
|
|
|
|
|
|
|
<a-box scale=".1 .1 .1" target position=".5 1.8 -.3" color="blue" onreleased="snapToGrid()" ></a-box> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-box scale=".1 .1 .1" position=".5 .8 -.3" color="purple" ></a-box> |
|
|
|
|
|
|
|
<a-box scale=".2 .2 .2" position=".5 .8 -.3" color="yellow" ></a-box> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-box teleporter height=".1" class="teleportable" material="color: cyan" position="3.5 0 -3.5" ></a-box> |
|
|
|
|
|
|
|
<a-box teleporter height=".1" class="teleportable" material="color: cyan" position="-4 0 4" ></a-box> |
|
|
|
|
|
|
|
<a-box teleporter height=".1" class="teleportable" material="color: cyan" position="3 3 4" > |
|
|
|
|
|
|
|
<a-troika-text anchor=left value="jxr location.reload()" target position="0 1.30 -.5" rotation="0 0 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
<!-- works to execute but not to move, should either reparent or take into account the parent offset while moving --> |
|
|
|
|
|
|
|
<!-- see pinchmoved in primary pinch in jxr-core.js as potential solution --> |
|
|
|
|
|
|
|
</a-box> |
|
|
|
|
|
|
|
<a-box teleporter height=".1" class="teleportable" material="color: cyan" position="0 0 0" ></a-box> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-box id="namedteleporter" teleporter height=".1" class="teleportable" material="color: cyan" position="2 0 2" ></a-box> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-box target teleporter height=".1" depth=".1" width=".1" class="teleportable" material="color: red" position="0 1 -.5" ></a-box> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</a-scene> |
|
|
|
</a-scene> |
|
|
|
</body> |
|
|
|
</body> |
|
|
|