modelmix 2.4.2 → 2.4.4

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 +76 -76
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -115,7 +115,82 @@ Here's a quick example to get you started:
115
115
  .stream((data) => { console.log(data.message); });
116
116
  ```
117
117
  4. Find the files for this example at: [/ModelMix/demo](https://github.com/clasen/ModelMix/tree/master/demo).
118
-
118
+
119
+ ## 🔄 Templating Methods
120
+
121
+ ### `replace` Method
122
+
123
+ The `replace` method is used to define key-value pairs for text replacement in the messages and system prompt.
124
+
125
+ #### Usage:
126
+ ```javascript
127
+ gpt.replace({ '{{key1}}': 'value1', '{{key2}}': 'value2' });
128
+ ```
129
+
130
+ #### How it works:
131
+ 1. It updates the `config.replace` object with the provided key-value pairs.
132
+ 2. In the template, placeholders like `{{key1}}` will be replaced with 'value1'.
133
+
134
+ #### Example:
135
+ ```javascript
136
+ gpt
137
+ .replace({ '{{name}}': 'Alice', '{{age}}': '30' })
138
+ .addText('Hello {{name}}, are you {{age}} years old?');
139
+ ```
140
+ This would result in the message: "Hello Alice, are you 30 years old?"
141
+
142
+ ### `replaceKeyFromFile` Method
143
+
144
+ The `replaceKeyFromFile` method is similar to `replace`, but it reads the replacement value from a file.
145
+
146
+ #### Usage:
147
+ ```javascript
148
+ messageHandler.replaceKeyFromFile('longText', './path/to/file.txt');
149
+ ```
150
+
151
+ #### How it works:
152
+ 1. It reads the content of the specified file synchronously.
153
+ 2. It then calls the `replace` method, using the provided key and the file content as the value.
154
+
155
+ #### Example:
156
+ ```javascript
157
+ messageHandler
158
+ .replaceKeyFromFile('article_file_contents', './article.txt')
159
+ .addText('Please summarize this article: article_file_contents');
160
+ ```
161
+ This would replace `article_file_contents` with the entire content of 'article.txt'.
162
+
163
+ ### When to use each method:
164
+ - Use `replace` for short, inline replacements or dynamically generated content.
165
+ - Use `replaceKeyFromFile` for longer texts or content that's stored externally.
166
+
167
+ Both methods allow for flexible content insertion, enabling you to create dynamic and customizable prompts for your AI model interactions.
168
+
169
+ ## 🐛 Enabling Debug Mode
170
+
171
+ To activate debug mode in ModelMix and view detailed request information, follow these two steps:
172
+
173
+ 1. In the ModelMix constructor, include `debug: true` in the configuration:
174
+
175
+ ```javascript
176
+ const mix = new ModelMix({
177
+ config: {
178
+ debug: true
179
+ // ... other configuration options ...
180
+ }
181
+ });
182
+ ```
183
+
184
+ 2. When running your script from the command line, use the `DEBUG=ModelMix*` prefix:
185
+
186
+ ```
187
+ DEBUG=ModelMix* node your_script.js
188
+ ```
189
+
190
+ When you run your script this way, you'll see detailed information about the requests in the console, including the configuration and options used for each AI model request.
191
+
192
+ This information is valuable for debugging and understanding how ModelMix is processing your requests.
193
+
119
194
  ## 📚 ModelMix Class Overview
120
195
 
121
196
  ```javascript
@@ -234,81 +309,6 @@ new MixLMStudio(args = { config: {}, options: {} })
234
309
  - `url`: The endpoint URL to which the model sends requests.
235
310
  - **options**: Default options for Ollama model instances.
236
311
 
237
- ## Explanation of `replace` and `replaceKeyFromFile` Methods
238
-
239
- ### `replace` Method
240
-
241
- The `replace` method is used to define key-value pairs for text replacement in the messages and system prompt.
242
-
243
- #### Usage:
244
- ```javascript
245
- gpt.replace({ '{{key1}}': 'value1', '{{key2}}': 'value2' });
246
- ```
247
-
248
- #### How it works:
249
- - It updates the `config.replace` object with the provided key-value pairs.
250
- - In the template, placeholders like `{{key1}}` will be replaced with 'value1'.
251
-
252
- #### Example:
253
- ```javascript
254
- gpt
255
- .replace({ '{{name}}': 'Alice', '{{age}}': '30' })
256
- .addText('Hello {{name}}, are you {{age}} years old?');
257
- ```
258
- This would result in the message: "Hello Alice, are you 30 years old?"
259
-
260
- ### `replaceKeyFromFile` Method
261
-
262
- The `replaceKeyFromFile` method is similar to `replace`, but it reads the replacement value from a file.
263
-
264
- #### Usage:
265
- ```javascript
266
- messageHandler.replaceKeyFromFile('longText', './path/to/file.txt');
267
- ```
268
-
269
- #### How it works:
270
- 1. It reads the content of the specified file synchronously.
271
- 2. It then calls the `replace` method, using the provided key and the file content as the value.
272
-
273
- #### Example:
274
- ```javascript
275
- messageHandler
276
- .replaceKeyFromFile('article_file_contents', './article.txt')
277
- .addText('Please summarize this article: article_file_contents');
278
- ```
279
- This would replace `article_file_contents` with the entire content of 'article.txt'.
280
-
281
- ### When to use each method:
282
- - Use `replace` for short, inline replacements or dynamically generated content.
283
- - Use `replaceKeyFromFile` for longer texts or content that's stored externally.
284
-
285
- Both methods allow for flexible content insertion, enabling you to create dynamic and customizable prompts for your AI model interactions.
286
-
287
- ## Enabling Debug Mode in ModelMix
288
-
289
- To activate debug mode in ModelMix and view detailed request information, follow these two steps:
290
-
291
- 1. In the ModelMix constructor, include `debug: true` in the configuration:
292
-
293
- ```javascript
294
- const mix = new ModelMix({
295
- config: {
296
- debug: true
297
- // ... other configuration options ...
298
- }
299
- });
300
- ```
301
-
302
- 2. When running your script from the command line, use the `DEBUG=ModelMix*` prefix:
303
-
304
- ```
305
- DEBUG=ModelMix* node your_script.js
306
- ```
307
-
308
- When you run your script this way, you'll see detailed information about the requests in the console, including the configuration and options used for each AI model request.
309
-
310
- This information is valuable for debugging and understanding how ModelMix is processing your requests.
311
-
312
312
  ## 🤝 Contributing
313
313
 
314
314
  Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the [GitHub repository](https://github.com/clasen/ModelMix).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modelmix",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "description": "🧬 ModelMix - Unified API for Diverse AI Language Models.",
5
5
  "main": "index.js",
6
6
  "repository": {