evals 1.0.6 → 1.0.7
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 +4 -57
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,12 +39,12 @@ To save the file, press `Ctrl + X`, then `Y`, then `Enter`. Then, run `source ~/
|
|
|
39
39
|
## Example usage
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
|
|
42
|
+
npx evals@latest fetch-evals
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
npx evals@latest run-evals
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
## Example BaseModel
|
|
47
|
+
## Example Prompt BaseModel
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
50
|
export interface ModelSettings {
|
|
@@ -84,66 +84,13 @@ class BaseModel {
|
|
|
84
84
|
* @returns Promise<{ response: string, prompts: Prompt[] }>
|
|
85
85
|
*/
|
|
86
86
|
async callModel(userMessage: string = ''): Promise<{ response: string; prompts: Prompt[] }> {
|
|
87
|
-
throw new Error('callModel method needs to be implemented
|
|
87
|
+
throw new Error('callModel method needs to be implemented');
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export default BaseModel;
|
|
92
92
|
```
|
|
93
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
94
|
|
|
148
95
|
## LICENSE
|
|
149
96
|
|