Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug? cannot read properties of undefined reading split req.model #291

Open
hershkoy opened this issue Mar 26, 2023 · 11 comments
Open

bug? cannot read properties of undefined reading split req.model #291

hershkoy opened this issue Mar 26, 2023 · 11 comments

Comments

@hershkoy
Copy link

Check this image:

when running from windows (#4) the request has both req.model and req.models (in plural).

but in docker compose (#3), the req object has only the req.model, and as a result the code crashes.
What am I missing?

image

@Kaillxu
Copy link

Kaillxu commented Mar 27, 2023

Same issue over here

@aptfx
Copy link

aptfx commented Mar 27, 2023

Same here. Actually exactly the same trying it to get running on macOS it always ends up breaking down on the "model.split()"

@devunpack
Copy link

I adjusted the sample code to "alpaca.7B" and was able to get it to run.

const Dalai = require('dalai')
new Dalai().request({
model: "alpaca.7B",
prompt: "The following is a conversation between a programmer and github issue thread",
}, (token) => {
process.stdout.write(token)
})

@hershkoy
Copy link
Author

I manually changed /root/dalai/node_modules/dalai/index.js:219 to:

let [Core, Model] = req.models[0].split(".")

now it runs, but I still get no output from the model.

image

@FarzamA
Copy link

FarzamA commented Mar 28, 2023

This only happens when you have just 1 model downloaded when you have 2 or more the issue no longer exists

@Johnreidsilver
Copy link

same on ubuntu

@jb-reefer
Copy link

jb-reefer commented Mar 29, 2023

Yeah, this is a showstopping bug for me on macOS - downloading >1 model does fix it though.

@jopek
Copy link

jopek commented Mar 29, 2023

in the meantime, you can have the entire dalai and alpaca in your own new npm-project:

mkdir dalai-alpaca
cd dalai-alpaca
npm init -y
npm install dalai

npx dalai alpaca install 7b

edit the node_modules/dalai/bin/web/views/index.ejs file, jump to line 299 (inside form.addEventListener('submit', (e) => {...}) and add the line:

config.model = form.querySelector('#model option[selected]').value

save.
now the selected model from the dropdown is sent along to the backend, which expects the object model to be part of the request.

now you can serve:

npx dalai serve

@abulka
Copy link

abulka commented Apr 3, 2023

@jopek Thanks for this. Though for some reason my browser page model select html never gets the attribute selected even though I choose the model from the dropdown, so your code line fails too. I only have one model. So I replaced your code with config.model = "alpaca.7B" and it works after that.

@thebaldgeek
Copy link

Same error here.
I have downloaded the 13B and 7B models as it was suggested, it did not fix it.
On the browser page, my drop down selection box is empty.
I get the .modeles error after clicking 'go'.
Unsure how to apply the 'fix' that is talked in the previous few posts.

> query: { method: 'installed', models: [] }
modelsPath C:\Users\beno\dalai\alpaca\models
{ modelFolders: [ '13B' ] }
modelsPath C:\Users\beno\dalai\llama\models
{ modelFolders: [ '7B' ] }
> query: {
  seed: -1,
  threads: 4,
  n_predict: 200,
  top_k: 40,
  top_p: 0.9,
  temp: 0.8,
  repeat_last_n: 64,
  repeat_penalty: 1.3,
  debug: true,
  models: [],
  prompt: 'Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n' +
    '\n' +
    '### Instruction:\n' +
    '>hello world\n' +
    '\n' +
    '### Response:\n',
  id: 'TS-1680493538734-68985'
}
C:\Users\beno\AppData\Local\npm-cache\_npx\3c737cbb02d79cc9\node_modules\dalai\index.js:219
    let [Core, Model] = req.model.split(".")
                                  ^

TypeError: Cannot read properties of undefined (reading 'split')
    at Dalai.query (C:\Users\beno\AppData\Local\npm-cache\_npx\3c737cbb02d79cc9\node_modules\dalai\index.js:219:35)
    at Socket.<anonymous> (C:\Users\beno\AppData\Local\npm-cache\_npx\3c737cbb02d79cc9\node_modules\dalai\index.js:534:20)
    at Socket.emit (node:events:513:28)
    at Socket.emitUntyped (C:\Users\beno\AppData\Local\npm-cache\_npx\3c737cbb02d79cc9\node_modules\socket.io\dist\typed-events.js:69:22)
    at C:\Users\beno\AppData\Local\npm-cache\_npx\3c737cbb02d79cc9\node_modules\socket.io\dist\socket.js:703:39
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

Node.js v18.15.0```

@jopek
Copy link

jopek commented Apr 3, 2023

@abulka

Though for some reason my browser page model select html never gets the attribute selected even though I choose the model from the dropdown, so your code line fails too. I only have one model.

the attribute itself is set on the option-HTMLElement. it is not a property the is reflected back to the dom. but if you set the option selected property, then that one option is the one set and visible on the select html element.

to see what i mean navigate to https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option_selected
open the developer tools. the console type in document.querySelectorAll('select#cars option') and you should be greeted with a NodeList of four option elements.

> Array.from(temp1.querySelectorAll("select option")).map(opt=>opt.selected)
< (4) [true, false, false, false]

if you select the 3rd option "vw", the result should be [false, false, true, false]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants