evals 0.0.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +47 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- This is the Javascript SDK for Umbrage Evals. It will have both TypeScript and JavaScript support.
5
+ This is the Javascript SDK for Umbrage Evals. It also supports TypeScript.
6
6
 
7
7
  ## Installation
8
8
 
@@ -16,6 +16,52 @@ npm install evals
16
16
 
17
17
  - Node.js (or another JavaScript runtime environment like Bun)
18
18
 
19
+ ## Example usage
20
+
21
+ ```typescript
22
+ import Evals from 'evals';
23
+
24
+ const evals = new Evals('your-umbrage-evals-api-key-goes-here'); // Get your API key from the Umbrage Evals Dashboard
25
+
26
+ // Get the timestamp for the request so we can log the response time from the model
27
+ const request_timestamp = new Date();
28
+
29
+ // Setting model in a variable since it's going to be passed in two places, one for the model and one for Umbrage Evals
30
+ const model = 'gpt-3.5-turbo';
31
+
32
+ // Call the model
33
+ const chatResponse = await openai.createChatCompletion({
34
+ model,
35
+ messages,
36
+ max_tokens: reservedTokensForResponse,
37
+ temperature: 0.2,
38
+ });
39
+
40
+ // Get the timestamp for the response so we can log the response time from the model
41
+ const response_timestamp = new Date();
42
+
43
+ // Log the prompt and response data to Umbrage Evals
44
+ const logResponse = await evals.logPrompt({
45
+ prompt_name: 'unique_prompt_name', // A unique name specific to this prompt. This is what will show up in the Dashboard under your Project.
46
+ environment: 'development', // Which environment you're using, e.g. development, test, staging, production
47
+ model,
48
+ model_settings: { // Optional, but recommended if you want to track model settings
49
+ temperature: 0.2,
50
+ max_tokens: 512,
51
+ },
52
+ prompts: messages.map((message) => ({
53
+ prompt_type: message.role, // Make sure you have an array with prompt_type and prompt_text
54
+ prompt_text: message.content,
55
+ })),
56
+ response: chatResponse.data.choices[0].message.content, // Map the final text response from the model to the response field
57
+ request_timestamp,
58
+ response_timestamp, // Pass the JavaScript Date objects for the request and response timestamps
59
+ })
60
+
61
+ console.log(logResponse) // { status: 200, body: 'Prompt and response logged successfully' }
62
+
63
+ ```
64
+
19
65
  ## LICENSE
20
66
  Copyright (c) 2023 Umbrage Studios, LLC
21
67
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
7
- "version": "0.0.6",
7
+ "version": "1.0.0",
8
8
  "description": "Umbrage Evals SDK",
9
9
  "scripts": {
10
10
  "build": "bun build --target=node ./src/index.ts --outfile=dist/index.js && bun run build:declaration",