Genie Community Forum

About the API

I don’t quite understand the error. Something very wrong happened when installing an npm dependency, and the installed file is corrupted: it doesn’t match at all the package that was uploaded to npm, and it contains some typescript stuff in the js code. Try running npm ci to clean up.

That seems to have fixed it. We can now run the bootstrap and run -almond commands, but we’re now getting this error when running run-frontend --port 8080:


It seems to be something wrong with the compiler? TypeSpec[]; looks like a normal instruction.

TypeSpec[]; is not normal JS code. Something is definitely off in your setup, related to compilation of TypeScript code. I’m afraid I don’t know how to help you beyond this.

Hmm, what affects the compilation of the TypeScript code? I’m assuming that its supposed to turn TS into JS? Would it make sense to just try to delete TypeSpec[] in input_validation.js?

Edit:
TypeSpec seems to be used at least three times in the code:


Maybe we can change it to whatever name/variable its supposed to be?

Edit2:
Running tsc -p tsconfig.json to manually compile the TypeScript files already gives some errors (this is a subset):


So TypeSpec[] seems to come from the ts files. However, it already gives it as an error as you can see. Maybe this is a problem with the typescript version we have installed?

Should we degrade into an older version?

How did you install typescript 4.4 in almond-cloud? The package.json specifies ~4.3.5 4.4 doesn’t work because of some changes they made.
You should use npm ci to install dependencies to ensure that npm sticks to the exact versions specified in package-lock.json

I don’t know, for some reason our downloaded package.json file has it in this format:
image
So its ^4.4.3 instead of ~4.3.5. I’ll try changing it manually and running npm ci.

Edit:
Actually now that I look at it, somehow our package.json and package-lock.json files are both different compared to the one found in the almond-cloud github. I’ll change the entire file manually and see if that fixes the problem.

Edit2:
Unfortunately, even with a clean copy of package.json and package-lock.json, as well as running npm ci, we’re still getting the same error for both trying to compile the TypeScript files as I posted before, and running the run-frontend command.

Edit3:
I tried to reinstall the entire almond-cloud directory in case some other files are also wrong. The result is that run-almond now looks fine:


But for some reason run-frontend cant connect with it:

Any ideas on what’s causing this?

Edit4:
Somehow, the problem was fixed by remaking the workdir directory, and now the website’s deployed.


We’ll test it to see if there’s any problem with connections to the thingpedia/nlp.

Edit5:
Is there a way to stop the almond backend and frontend more elegantly? So far we’ve used ctrl+c and it causes us to have to delete the contents of the workdir (or the entire directory itself) before being able to run both backend and frontend again.

Ctrl-C is the correct way to stop the backend and frontend processes when run from a terminal. I’m not sure why you need to delete the workdir after you do that

It had something to do with the control file not deleting itself when the run-almond command has stopped. So sometimes we have to delete that file before running both run-almond and run-frontend. The error looks like this:

Strange, the socket should be deleted when the process exits. Anyway deleting just the socket is less destructive than deleting the whole workdir.

Can we have a separate page for /about? In the current web Almond, that URL redirects to the homepage which is handled by about_index.pug, which I assume should only handle the base URL. The EXTRA_ABOUT_PAGES config variable only allows us to create new pages after the /about path, but what we want is to add a page for that /about path itself.

You can edit the routing code in src/routes/about.ts if you want a dedicated about page.

This should work right:

res.render(Config.ABOUT_OVERRIDE['about'] || 'about_about', {
        page_title: req._("About Us")
});

Is there a command that I need to run after updating the route file? Because the above change doesn’t seem to work

You need to run npx make to rebuild the JS files after editing the TS code.

Doesn’t seem to solve the issue. Output of running npx make for the first time is:


And the second time showing that it was run before is:

But /about still redirects to the main page. The full about router code is:

router.get('/about', (req, res, next) => {
    //res.redirect(301, '/');
    res.render(Config.ABOUT_OVERRIDE['about'] || 'about_about', {
        page_title: req._("About Us | ISS Genie")
    });
});

Huh. No idea what’s going on. The first run of npx make rebuilt the TS code (see the line tsc) so it worked fine. And the code looks correct. Does it show a 200 or 302 log in the terminal where you’re running the frontend?

Over multiple attempts of accessing /about, both manually typing in the URL and clicking a new navbar button:

Edit:
What’s weird is that a different change I added on the about.ts file actually works. I renamed the page title of the homepage to Home and it does change correctly.

Edit2:
Could there be a router file somewhere that overwrites this somehow? I can’t think of any other reason why its not working considering my changes to other parts such as page_title for other pages works just fine.

Edit3:
I tried to change it to a different route since /about seems to be stuck with redirecting to the homepage, and it does seem to detect the new path /about/me:

router.get('/about/me', (req, res, next) => {
    res.render(Config.ABOUT_OVERRIDE['about'] || 'about_me', {
        page_title: req._("About Us | ISS Genie")
    });
});

This is before changing the about_about.pug file to about_me.pug:


This is after changing it:
image
So it detects the pug file but for some reason gives a 404 error. The pug file for the page is as follows:

extends ../layout

block page_name
  = _("About Us")

block content
  h3 The Team Behind the Project

The extends is wrong. layout.pug is in the same directory as about_about.pug so it should be ./layout.pug

Because I couldn’t get /about to not redirect to the homepage, now I’m trying to use the ABOUT_OVERRIDE config variable to do it like follows:

module.exports.ABOUT_OVERRIDE = {
  us: 'about_us.pug'
};

I changed it to this (filename about_us.pug):

extends layout

block page_name
  = _("About Us")

block content
  h3 The Team Behind the Project

Similar to how its done in the login page but it still returns a 404 error:


I’ve run the npx make step after changing the router file.

Edit:
I used EXTRA_ABOUT_PAGES instead of ABOUT_OVERRIDE and it seems to work now in /about/us.

Hi Giovanni, we’re currently editing the UI in the web Almond deployment and we’ve run into some parts that we don’t know if we can change them or not. For the register page, in register_mixins.pug there are two parts that we’re unsure of:

  1. There seems to be a input field for phone numbers that is optional. Can we remove this field entirely from the pug code? It doesn’t seem to exist in the current almond.stanford.edu website but we don’t know if removing would cause an issue in the backend of not.

  2. Can we remove the consent form? We’re not really sure what to put there but it seems wrong to use the template for that. Again, we’re unsure if removing this part will break the backend or not.

  3. Also, what should we put in the terms of services page?

  1. Yeah you can remove the phone number field from pug. It is optional and nothing will break without it.

  2. You should remove the consent form as well. Users won’t be enrolled in the research, and data won’t be collected from users. Which is correct because data goes to your NLP server, not ours, so we don’t collect any data anyway.

  3. In the terms of service and/or consent form your should put whatever terms are appropriate for your experiment. In the US, any research project that involves people needs to go through the Institutional Review Board, and approval typically involves having participants sign (click) a consent form. You’re in Australia right? I imagine you’ll have similar rules but I don’t know the specifics. If this is just a class project and not a research project, you might also get away without any terms.