Skip to content

Commit 6ff1b5c

Browse files
committed
docs(readme): add updated information to the README.md file
1 parent 513d7af commit 6ff1b5c

File tree

1 file changed

+158
-40
lines changed

1 file changed

+158
-40
lines changed

README.md

Lines changed: 158 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
# Hypercode
22

3-
Hypercode is a friendly npm package that makes it easy to get live, structured LLM responses in your application.
3+
`Hypercode` is a npm package for Node.js that allows you to consume the [Hyper APIs](https://docs.gethyper.ai) easily in your JavaScript or TypeScript projects with complete **type-safety**. `Hypercode` handles the complexity of context management and response formatting, allowing you to focus on creating dynamic and intelligent features that enhance user experience. It is a friendly npm package that makes it easy to get live, structured LLM responses with custom contexts in useful formats like integers, booleans, strings, dates, and lots more.
44

5-
With Hypercode, you can easily query language models and receive responses in useful formats like integers, booleans, strings, and dates:
5+
Create a free account today on [Hyper](https://app.gethyper.ai) to start building your own custom contexts, integrating them into your applications, generate API Keys, and use them in your projects with `Hypercode`!
6+
7+
Find the npm package [here](https://www.npmjs.com/package/hypercode)
8+
9+
[![npm version](https://badge.fury.io/js/hypercode.svg)](https://www.npmjs.com/package/hypercode)
10+
11+
**There are 3 main components to Hypercode:**
12+
13+
- Context Management (get information about the created contexts, more methods coming soon) - [Learn More](#context-management)
14+
- Response Formatting (get response in a specific format or data type) - [Learn More](#response-formatting---types-in-hypercode)
15+
- Embeddings Search (perform nuanced searches across integrated third-party data sources and internal documents) - [Learn More](#embeddings-search)
16+
17+
**Here's a quick example of how you can use Hypercode to get a boolean response:**
618

719
```javascript
8-
const isEarthFlat = await hyper.boolean('Is the earth flat?');
20+
const { data: isEarthFlat } = await hyper.types.boolean('Is the earth flat?');
921

1022
console.log(isEarthFlat); // false
1123
```
1224

1325
You can also pass information along with your queries in the form of `context`. Context represents bundles of live data with relevance to the query, ensuring the LLM his given all the information necessary to product an accurate response. You can build context objects in the [Hyper app](https://app.gethyper.ai), then use them in Hypercode:
1426

1527
```javascript
16-
const productLaunchDate = await hyper.datetime('When is the product launch?', {
17-
contextId: 'product-roadmap-context-id',
18-
});
28+
const { data: productLaunchDate } = await hyper.types.datetime(
29+
'When is the product launch?',
30+
{
31+
contextId: 'product-roadmap-context-id',
32+
},
33+
);
1934

2035
console.log(productLaunchDate); // "2024-07-31T0:00:00Z"
2136
```
@@ -26,10 +41,11 @@ The combination of structure and context in Hypercode is a powerful tool for add
2641

2742
```javascript
2843
async function prepareEmailCampaign() {
29-
const todayIsHoliday = await hyper.boolean('Is today a holiday?', {
44+
const todayIsHoliday = await hyper.types.boolean('Is today a holiday?', {
3045
contextId: 'company-holidays-context-id',
3146
});
32-
const emailSubject = await hyper.string(
47+
48+
const emailSubject = await hyper.types.string(
3349
todayIsHoliday
3450
? 'Generate a catchy subject for a post-holiday campaign'
3551
: 'Generate a catchy subject for a regular workday campaign',
@@ -56,96 +72,198 @@ prepareEmailCampaign().then((requestBody) => {
5672

5773
### Step 1: Install Hypercode
5874

59-
Start by installing the Hypercode package through npm:
75+
Start by installing the Hypercode package through your preferred package manager:
76+
77+
#### Using npm
6078

6179
```bash
62-
npm install hypercode
80+
npm i neoenv
6381
```
6482

65-
### Step 2: Set your Hyper API Key
83+
or
6684

67-
> **_NOTE:_** You can generate an API key from the [API Key Settings](https://app.gethyper.ai/settings/api-keys) page in the Hyper app.
85+
```bash
86+
npm install --save neoenv
87+
```
6888

69-
In your `.env` file, set your Hyper API Key:
89+
#### Using Yarn
7090

7191
```bash
72-
HYPER_API_KEY=your_api_key_here
92+
yarn add neoenv
7393
```
7494

75-
Make sure to replace `your_api_key_here` with your actual Hyper API key.
95+
#### Using pnpm
7696

77-
Alternatively, you can set the key yourself by calling the `hyper.init` method:
97+
```bash
98+
pnpm add neoenv
99+
```
78100

79-
```javascript
80-
require('dotenv').config();
81-
const hyper = require('hypercode');
101+
### Step 2: Set your Hyper API Key
82102

83-
hyper.init('API_KEY_HERE');
103+
> **_NOTE:_** You need to generate an API key from the [API Key Settings](https://app.gethyper.ai/settings/api-keys) page in the Hyper app.
84104
85-
// Continue with other function calls
105+
In your `.env` file, set your Hyper API Key:
106+
107+
```bash
108+
HYPER_API_KEY="your_api_key_here"
86109
```
87110

111+
Make sure to replace `your_api_key_here` with your actual Hyper API key obtained from the Hyper app.
112+
88113
### Step 3: Import Hypercode in Your Project
89114

90-
Import Hypercode in your JavaScript or TypeScript file.
115+
Import Hypercode in your JavaScript or TypeScript file to start using it:
91116

92117
```javascript
93-
const hyper = require('hypercode');
118+
import { Hyper } from 'hypercode';
119+
import dotenv from 'dotenv';
120+
121+
dotenv.config();
122+
123+
const hyper = new Hyper(process.env.HYPER_API_KEY);
124+
125+
// Use the `hyper` object to make different function calls
94126
```
95127

96128
### Step 4: Start Querying
97129

98-
Now you're ready to start querying language models with Hypercode!
130+
Now you're ready to start querying language models with your own created custom contexts with Hypercode!
99131

100-
## Types in Hypercode
132+
## Examples
101133

102-
Hypercode provides a variety of structured query types, allowing you to seamlessly integrate LLM responses into your applications. You can utilize context with `contextId` when you need the model to consider specific background information for generating a response. Here's a breakdown of the types and how they can be used:
134+
**You can find diferent example code in the [examples](https://github.com/gethyperai/hypercode/tree/main/examples) folder.**
103135

104-
- **boolean**: Get a true or false answer.
136+
## Context Management
137+
138+
Hypercode allows you to programmatically manage your contexts that are created inside the [Hyper App](https://app.gethyper.ai). You can get information about the created contexts, and more methods are coming soon. More information about contexts can be found [here](https://docs.gethyper.ai/context).
139+
140+
**Here's a quick example of how you can use Hypercode to list down all the contexts:**
141+
142+
```javascript
143+
const { data: contexts, error } = await hyper.contexts.list();
144+
145+
console.log(contexts); // [{ id: 'context-id-1', name: 'Context 1', created_at: '2023-10-28T04:28:13.971776+00:00' }, { id: 'context-id-2', name: 'Context 2', created_at: '2023-11-02T22:18:44.978052+00:00' }]
146+
```
147+
148+
## Response Formatting - Types in Hypercode
149+
150+
Hypercode provides a variety of structured query types, allowing you to seamlessly integrate LLM responses into your applications. You can utilize context with `contextId` when you need the model to consider specific background information for generating a response. More information about `types` can be found [here](https://docs.gethyper.ai/types) Here's a breakdown of the types and how they can be used:
151+
152+
- **string**: Get a simple string answer.
105153

106154
```javascript
107-
const canCatsSeeInTheDark = await hyper.boolean('Can cats see in the dark?');
108-
console.log(canCatsSeeInTheDark); // true
155+
const { data: color, error } = await hyper.types.string(
156+
"What's the color of the sky?",
157+
);
158+
159+
console.log(color); // "blue"
109160
```
110161

162+
You can pass the `contextId` as an optional parameter to all the `types` methods. The `contextId` is the id of the context that you want to use for the query. Here's one example with the `integer` method:
163+
111164
- **integer**: Get an integer answer.
112165

113166
```javascript
114-
const numberOfPatentsFiled = await hyper.integer(
167+
const { data: numberOfPatentsFiled, error } = await hyper.types.integer(
115168
'How many patents has the company filed since its inception?',
116169
{ contextId: 'company-history-context-id' },
117170
);
118-
console.log(numberOfPatentsFiled); // 50
119-
```
120171

121-
- **string**: Get a simple string answer.
122-
123-
```javascript
124-
const color = hyper.string("What's the color of the sky?");
125-
console.log(color); // "blue"
172+
console.log(numberOfPatentsFiled); // 50
126173
```
127174

128175
- **float**: Get a floating-point number answer.
129176

130177
```javascript
131-
const averageRevenueGrowth = await hyper.float(
178+
const { data: averageRevenueGrowth, error } = await hyper.types.float(
132179
"What has been the company's average revenue growth rate over the last five years?",
133180
{ contextId: 'financial-report-context-id' },
134181
);
182+
135183
console.log(averageRevenueGrowth); // 4.7
136184
```
137185

186+
- **boolean**: Get a true or false answer.
187+
188+
```javascript
189+
const { data: canCatsSeeInTheDark, error } = await hyper.types.boolean(
190+
'Can cats see in the dark?',
191+
);
192+
193+
console.log(canCatsSeeInTheDark); // true
194+
```
195+
138196
- **datetime**: Get a date and time as the answer.
139197

140198
```javascript
141-
const moonLandingDate = await hyper.datetime(
199+
const { data: moonLandingDate, error } = await hyper.types.datetime(
142200
'What is the date of the Apollo 11 moon landing?',
143201
);
202+
144203
console.log(moonLandingDate); // "1969-07-20T20:17:00Z"
145204
```
146205

206+
**You can also get the result as an array of the above types. Here are the methods for that:**
207+
208+
- `stringArray`, `integerArray`, `floatArray`, `booleanArray`, `datetimeArray` methods: Get an array of the respective type as the answer.
209+
210+
```javascript
211+
// Get an array of strings as the answer
212+
const { data } = await hyper.types.stringArray('List all department names', {
213+
contextId: 'company-structure-context-id',
214+
});
215+
216+
console.log(data); // ['Human Resources', 'Finance', 'Research and Development', 'Sales', 'Customer Support']
217+
218+
// Get an array of integers as the answer
219+
const { data } = await hyper.types.integerArray(
220+
'What is the headcount for each department?',
221+
{ contextId: 'company-structure-context-id' },
222+
);
223+
224+
// Get an array of floats as the answer
225+
const { data } = await hyper.types.floatArray(
226+
'What were the customer satisfaction ratings from the last survey?',
227+
{ contextId: 'customer-reviews-context-id' },
228+
);
229+
230+
// Get an array of booleans as the answer
231+
const { data } = await hyper.types.booleanArray(
232+
'Are services meeting performance targets?',
233+
{ contextId: 'performance-reviews-context-id' },
234+
);
235+
236+
// Get an array of datetimes as the answer
237+
const { data } = await hyper.types.datetimeArray(
238+
'What are the upcoming project deadlines?',
239+
{ contextId: 'project-management-context-id' },
240+
);
241+
```
242+
243+
## Embeddings Search
244+
245+
Utilize our Embeddings Search API to perform nuanced searches across integrated third-party data sources and internal documents. Leverage the `contextId` to scope searches to specific business contexts for enhanced relevance. More information about `search` can be found [here](https://docs.gethyper.ai/search).
246+
247+
```javascript
248+
const { data, error } = await hyper.search.execute('quarterly sales report', {
249+
contextId: 'company-sales-reports-context-id',
250+
});
251+
252+
console.log(data);
253+
```
254+
147255
## Wrapping Up
148256

149-
With Hypercode, integrating live, structured responses from language models into your application has never been easier. By handling the complexity of context management and response formatting, Hypercode empowers you to focus on creating dynamic and intelligent features that enhance user experience.
257+
With Hypercode, integrating live, structured responses in specific `types` from language models into your application has never been easier. By handling the complexity of managing the `contexts` and response formatting, Hypercode empowers you to focus on creating dynamic and intelligent features that enhance user experience. With the powerful `search` feature, developers can perform nuanced search across integrated third-party data sources and internal documents to get the most relevant results from the context.
150258

151259
Remember, the examples provided are just a starting point. The potential uses of Hypercode are limited only by your imagination and the needs of your application. Whether you're building smart assistants, data analysis tools, content generators, or any other AI-driven application, Hypercode is designed to streamline your workflow and bring the power of LLMs to your fingertips.
260+
261+
Create a free account on [Hyper](https://app.gethyper.ai) to start building your own custom contexts and integrating them into your applications today!
262+
263+
## Bugs and Features
264+
265+
See the [issues](https://github.com/gethyperai/hypercode/issues) for a list of proposed features and known issues. Feel free to raise new issues.
266+
267+
## License
268+
269+
Distributed under the MIT License. See [LICENSE](https://github.com/gethyperai/hypercode/blob/main/LICENSE) for more information. © [Hyper AI Inc.](https://gethyper.ai)

0 commit comments

Comments
 (0)