Skip to content

Commit

Permalink
Typescript checking
Browse files Browse the repository at this point in the history
  • Loading branch information
platypii committed Jun 6, 2024
1 parent 67ffbd7 commit 15ad34b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: CI
on:
pull_request:
push:

jobs:
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm i
- run: tsc
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"test": "vitest run"
},
"devDependencies": {
"@types/node": "20.14.2",
"typescript": "5.4.5",
"vitest": "1.6.0"
}
}
8 changes: 7 additions & 1 deletion src/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const systemPrompt = 'You are a machine learning web application named "hyperpar
'The quickest way to get started is to upload a dataset and start exploring.'
const messages = [{ role: 'system', content: systemPrompt }]

/**
* @param {Object} chatInput
*/
function sendToServer(chatInput) {
return new Promise((resolve, reject) => {
const json = JSON.stringify(chatInput)
Expand Down Expand Up @@ -44,6 +47,9 @@ function sendToServer(chatInput) {
})
}

/**
* @param {string[]} args
*/
function write(...args) {
args.forEach(s => process.stdout.write(s))
}
Expand All @@ -60,7 +66,7 @@ function chat() {

write(colors.system, 'question: ', colors.normal)

process.stdin.on('data', async (input) => {
process.stdin.on('data', async (/** @type {string} */ input) => {
input = input.trim()
if (input === 'exit') {
process.exit()
Expand Down
1 change: 0 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

if (process.argv[2] === 'chat') {
require('./chat').chat()
return
} else {
console.log('usage: hyperparam chat')
}
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"lib": ["esnext", "dom"],
"module": "nodenext",
"noEmit": true,
"resolveJsonModule": true,
"strict": true,
},
"include": ["src", "test"]
}

0 comments on commit 15ad34b

Please sign in to comment.