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

Add examples for the usage of the package with JavaScript and TypeScript #13

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ public/
build/
dist/
docs/
example/
examples/
1 change: 1 addition & 0 deletions examples/with-js-cjs/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HYPER_API_KEY = "YOUR_HYPER_API_KEY" # Generate your Hyper API key at https://app.gethyper.ai/settings/api-keys
20 changes: 20 additions & 0 deletions examples/with-js-cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { Hyper } = require('hypercode');
const dotenv = require('dotenv');

dotenv.config();

const hyper = new Hyper(process.env.HYPER_API_KEY);

async function main() {
const { data, error } = await hyper.types.integer(
"What's the square root of 16?",
);

if (data) {
console.log(data); // 4
} else {
console.log(error);
}
}

main();
36 changes: 36 additions & 0 deletions examples/with-js-cjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions examples/with-js-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "with-js-esm",
"version": "1.0.0",
"description": "Example of using Hypercode npm package with Node.js and JavaScript in ESM format",
"author": {
"name": "Hyper AI",
"email": "[email protected]",
"url": "https://gethyper.ai"
},
"license": "MIT",
"type": "commonjs",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"dotenv": "^16.3.1",
"hypercode": "^2.2.0"
},
"keywords": [
"ai",
"llm",
"large language model",
"developer",
"tool",
"convenience"
]
}
1 change: 1 addition & 0 deletions examples/with-js-esm/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HYPER_API_KEY = "YOUR_HYPER_API_KEY" # Generate your Hyper API key at https://app.gethyper.ai/settings/api-keys
20 changes: 20 additions & 0 deletions examples/with-js-esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Hyper } from 'hypercode';
import dotenv from 'dotenv';

dotenv.config();

const hyper = new Hyper(process.env.HYPER_API_KEY);

async function main() {
const { data, error } = await hyper.types.integer(
"What's the square root of 16?",
);

if (data) {
console.log(data); // 4
} else {
console.log(error);
}
}

main();
36 changes: 36 additions & 0 deletions examples/with-js-esm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions examples/with-js-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "with-js-esm",
"version": "1.0.0",
"description": "Example of using Hypercode npm package with Node.js and JavaScript in ESM format",
"author": {
"name": "Hyper AI",
"email": "[email protected]",
"url": "https://gethyper.ai"
},
"license": "MIT",
"type": "module",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"dotenv": "^16.3.1",
"hypercode": "^2.2.0"
},
"keywords": [
"ai",
"llm",
"large language model",
"developer",
"tool",
"convenience"
]
}
1 change: 1 addition & 0 deletions examples/with-ts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HYPER_API_KEY = "YOUR_HYPER_API_KEY" # Generate your Hyper API key at https://app.gethyper.ai/settings/api-keys
20 changes: 20 additions & 0 deletions examples/with-ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Hyper } from 'hypercode';
import dotenv from 'dotenv';

dotenv.config();

const hyper = new Hyper(process.env.HYPER_API_KEY);

async function main() {
const { data, error } = await hyper.types.integer(
"What's the square root of 16?",
);

if (data) {
console.log(data); // 4
} else {
console.log(error);
}
}

main();
Loading