Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyeo1010 committed Jun 3, 2024
1 parent 995dd53 commit 81c3b06
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion recipes/llm-voice-assistant/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ picoLLM Inference Engine supports many open-weight models. The models are on
Install the required packages using `yarn`:

```console
yarn isntall
yarn install
```

or using `npm`:
Expand Down
7 changes: 6 additions & 1 deletion recipes/llm-voice-assistant/web/public/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ window.onload = () => {
let streamCalls = 0;

try {
await Picovoice.init(accessKey.value, {
await Picovoice.init(accessKey.value,
{
modelFile: modelFile.files[0],
cacheFilePath: modelFile.files[0].name,
},
{
onDetection: () => {
message.innerText = "Wake word detected, utter your request or question...";
humanElem = startHumanMessage();
Expand Down
16 changes: 8 additions & 8 deletions recipes/llm-voice-assistant/web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Mutex } from 'async-mutex';
import { BuiltInKeyword, PorcupineDetection, PorcupineWorker } from '@picovoice/porcupine-web';
import { CheetahTranscript, CheetahWorker } from '@picovoice/cheetah-web';
import { OrcaStreamWorker, OrcaWorker } from '@picovoice/orca-web';
import { Dialog, PicoLLMWorker } from '@picovoice/picollm-web';
import { Dialog, PicoLLMModel, PicoLLMWorker } from '@picovoice/picollm-web';
import { WebVoiceProcessor } from '@picovoice/web-voice-processor';

type PvObject = {
Expand All @@ -26,7 +26,10 @@ type PvCallback = {

let object: PvObject | null = null;

const init = async (accessKey: string, {
const init = async (
accessKey: string,
picollmModel: PicoLLMModel,
{
onDetection,

Check warning on line 33 in recipes/llm-voice-assistant/web/src/main.ts

View workflow job for this annotation

GitHub Actions / check-web-codestyle

Expected indentation of 4 spaces but found 2
onEndpoint,

Check warning on line 34 in recipes/llm-voice-assistant/web/src/main.ts

View workflow job for this annotation

GitHub Actions / check-web-codestyle

Expected indentation of 4 spaces but found 2
onTranscript,

Check warning on line 35 in recipes/llm-voice-assistant/web/src/main.ts

View workflow job for this annotation

GitHub Actions / check-web-codestyle

Expected indentation of 4 spaces but found 2
Expand Down Expand Up @@ -78,9 +81,7 @@ const init = async (accessKey: string, {

const pllm = await PicoLLMWorker.create(
accessKey,
{
modelFile: "models/picollm_params.pllm"
});
picollmModel);

const orca = await OrcaWorker.create(
accessKey,
Expand All @@ -97,9 +98,10 @@ const init = async (accessKey: string, {
let stopTokens = 0;

const stopPhrases = [
'</s>', // Llama-2, Mistral, and Mixtral
'</s>', // Llama-2, Mistral
'<end_of_turn>', // Gemma
'<|endoftext|>', // Phi-2
'<|eot_id|>', // Llama-3

Check failure on line 104 in recipes/llm-voice-assistant/web/src/main.ts

View workflow job for this annotation

GitHub Actions / check-web-codestyle

Multiple spaces found before '// Llama-3'
];

const onCheetahFlushed = async (): Promise<void> => {
Expand All @@ -109,8 +111,6 @@ const init = async (accessKey: string, {

const { completion, completionTokens } = await pllm.generate(dialog.prompt(), {
completionTokenLimit: 128,
temperature: 0.7,
topP: 0.6,
streamCallback: async token => {
if (!stopPhrases.includes(token)) {
onText(token);
Expand Down

0 comments on commit 81c3b06

Please sign in to comment.