evals 0.0.6 → 1.0.1

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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Umbrage Evals JavaScript SDK
1
+ # Umbrage Evals JavaScript CLI
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 CLI for Umbrage Evals. It also supports TypeScript.
6
6
 
7
7
  ## Installation
8
8
 
@@ -16,7 +16,137 @@ npm install evals
16
16
 
17
17
  - Node.js (or another JavaScript runtime environment like Bun)
18
18
 
19
+ ## Environment
20
+
21
+ You will need to set the following environment variables:
22
+
23
+ ```bash
24
+ UMBRAGE_EVALS_API_KEY=<your api key for the umbrage evals project>
25
+ OPENAI_API_KEY=<your openai api key>
26
+ ```
27
+
28
+ These can be set in your `~/.bashrc` or `~/.zshrc` file on Mac or Linux, or in your `~/.bash_profile` file on Windows.
29
+
30
+ It would look like:
31
+
32
+ ```bash
33
+ export UMBRAGE_EVALS_API_KEY=<your api key for the umbrage evals project>
34
+ export OPENAI_API_KEY=<your openai api key>
35
+ ```
36
+
37
+ To save the file, press `Ctrl + X`, then `Y`, then `Enter`. Then, run `source ~/.bashrc` or `source ~/.zshrc` on Mac or Linux, or `source ~/.bash_profile` on Windows.
38
+
39
+ ## Example usage
40
+
41
+ ```bash
42
+ umbrage-cli fetch-evals
43
+
44
+ umbrage-cli run-evals
45
+ ```
46
+
47
+ ## Example BaseModel
48
+
49
+ ```typescript
50
+ export interface ModelSettings {
51
+ temperature: number;
52
+ [key: string]: any;
53
+ }
54
+
55
+ export interface Prompt {
56
+ prompt_type: string;
57
+ prompt_text: string;
58
+ }
59
+
60
+ export interface Config {
61
+ promptName: string;
62
+ modelName: string;
63
+ modelSettings: ModelSettings;
64
+ environment: string;
65
+ }
66
+
67
+ class BaseModel {
68
+ promptName: string;
69
+ modelName: string;
70
+ modelSettings: ModelSettings;
71
+ environment: string;
72
+
73
+ constructor(config: Config) {
74
+ this.promptName = config.promptName;
75
+ this.modelName = config.modelName;
76
+ this.modelSettings = config.modelSettings;
77
+ this.environment = config.environment || 'development';
78
+ }
79
+
80
+ /**
81
+ * This method should be overridden in subclasses.
82
+ * It should return an object containing the response and the prompts array.
83
+ * @param userMessage The user message to be processed by the model, optional.
84
+ * @returns Promise<{ response: string, prompts: Prompt[] }>
85
+ */
86
+ async callModel(userMessage: string = ''): Promise<{ response: string; prompts: Prompt[] }> {
87
+ throw new Error('callModel method needs to be implemented in subclasses');
88
+ }
89
+ }
90
+
91
+ export default BaseModel;
92
+ ```
93
+
94
+ ## Example Prompt (OpenAI API)
95
+
96
+ ```typescript
97
+ import BaseModel from './BaseModel';
98
+ import OpenAI from 'openai';
99
+
100
+ class ChevySalesCopilotPrompt extends BaseModel {
101
+ constructor() {
102
+ const config = {
103
+ promptName: 'Chevy Sales Copilot',
104
+ modelName: 'gpt-4',
105
+ modelSettings: { temperature: 0.2 },
106
+ environment: 'development'
107
+ };
108
+ super(config);
109
+
110
+ this.openai = new OpenAI(); // Assumes OPENAI_API_KEY is set in environment
111
+ this.messages = [
112
+ { role: 'system', content: 'You are a Chevy Sales Copilot assistant. You can only help with topics related to sales at Chevrolet. If asked your name your name is "Sales Copilot".' }
113
+ ];
114
+ }
115
+
116
+ async callModel(userMessage) {
117
+ try {
118
+ // Update messages with user input
119
+ const updatedMessages = [...this.messages, { role: 'user', content: userMessage }];
120
+
121
+ const modelResponse = await this.openai.chat.completions.create({
122
+ model: this.modelName,
123
+ messages: updatedMessages,
124
+ temperature: this.modelSettings.temperature,
125
+ });
126
+
127
+ const response = modelResponse.choices[0].message.content;
128
+
129
+ const prompts = updatedMessages.map(message => ({
130
+ prompt_type: message.role,
131
+ prompt_text: message.content,
132
+ }));
133
+
134
+ return { response, prompts };
135
+ } catch (error) {
136
+ console.error('Error:', error);
137
+ throw error;
138
+ }
139
+ }
140
+ }
141
+
142
+ const prompt = new ChevySalesCopilotPrompt();
143
+
144
+ export default prompt;
145
+
146
+ ```
147
+
19
148
  ## LICENSE
149
+
20
150
  Copyright (c) 2023 Umbrage Studios, LLC
21
151
 
22
152
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: