https://github.com/contextco/context-node
https://github.com/contextco/context-node
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/contextco/context-node
- Owner: contextco
- Created: 2023-06-03T18:18:21.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-20T11:13:44.000Z (about 2 years ago)
- Last Synced: 2024-06-22T01:28:59.665Z (about 2 years ago)
- Language: TypeScript
- Size: 268 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Context Node Library
[](https://npmjs.com/package/@contextco/context-node)
The Context Node library provides a convenient way to interface with the Context APIs. We include pre-defined classes and operations to interact with API resources.
## Installation
### NPM
```shell
npm install @contextco/context-node
```
### Yarn
```shell
yarn add @contextco/context-node
```
## Usage
The library needs to be configured with your Context API key, which is available in the [Context Settings Dashboard](https://go.getcontext.ai/settings).
### Example
```typescript
import { ContextAPI, ContextAPIOptionalParams, KnownMessageRole, Credential } from "context-js";
const options: ContextAPIOptionalParams = {
credential: new Credential(process.env.CONTEXT_TOKEN),
};
const c = new ContextAPI(options);
await c.log.conversation({
body: {
conversation: {
messages: [
{ message: "You are a helpful assistant.", role: KnownMessageRole.System, rating: 0 },
{ message: "Hi, how are you doing?", role: KnownMessageRole.User, rating: 0 },
{ message: "I'm doing super well, how are you?", role: KnownMessageRole.Assistant, rating: 1 }
],
}
}
})
```
## Appendix
```yaml
typescript: true
output-folder: generated
source-code-folder-path: src
package-name: "@contextco/context-generated"
clear-output-folder: true
credential-default-policy-type: BearerTokenCredentialPolicy
azure-arm: false
add-credentials: true
credential-scopes: all
models-mode: msrest
generate-metadata: true
use:
- "@autorest/typescript@6.0.8"
```