@revenium/perplexity 1.0.17 → 1.0.19
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
|
@@ -187,54 +187,6 @@ const streamingExample = async () => {
|
|
|
187
187
|
streamingExample();
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
#### Metadata Example
|
|
191
|
-
|
|
192
|
-
Create `examples/metadata-perplexity.js`:
|
|
193
|
-
|
|
194
|
-
```javascript
|
|
195
|
-
// examples/metadata-perplexity.js
|
|
196
|
-
import { PerplexityReveniumMiddleware } from "@revenium/perplexity";
|
|
197
|
-
|
|
198
|
-
const metadataExample = async () => {
|
|
199
|
-
try {
|
|
200
|
-
const middleware = new PerplexityReveniumMiddleware();
|
|
201
|
-
const model = middleware.getGenerativeModel("sonar-pro");
|
|
202
|
-
const result = await model.createChatCompletion({
|
|
203
|
-
messages: [
|
|
204
|
-
{
|
|
205
|
-
role: "user",
|
|
206
|
-
content: "Analyze this quarterly report",
|
|
207
|
-
},
|
|
208
|
-
],
|
|
209
|
-
usageMetadata: {
|
|
210
|
-
// User tracking
|
|
211
|
-
traceId: "conv-28a7e9d4",
|
|
212
|
-
taskType: "document-analysis",
|
|
213
|
-
subscriberEmail: "user@example.com",
|
|
214
|
-
subscriberId: "user-123",
|
|
215
|
-
subscriberCredentialName: "api-key-1",
|
|
216
|
-
|
|
217
|
-
// Business context
|
|
218
|
-
organizationId: "acme-corp",
|
|
219
|
-
subscriptionId: "premium-plan",
|
|
220
|
-
productId: "business-intelligence",
|
|
221
|
-
agent: "analysis-assistant",
|
|
222
|
-
responseQualityScore: 0.95,
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
console.log("*** METADATA RESPONSE ***");
|
|
227
|
-
console.log("Response:", result.choices[0]?.message?.content);
|
|
228
|
-
console.log("✅ Metadata tracking with metering successful!");
|
|
229
|
-
} catch (error) {
|
|
230
|
-
console.error("❌ Perplexity metadata example failed:", error);
|
|
231
|
-
process.exit(1);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
metadataExample();
|
|
236
|
-
```
|
|
237
|
-
|
|
238
190
|
### Step 8: Update package.json
|
|
239
191
|
|
|
240
192
|
```json
|
|
@@ -244,8 +196,7 @@ metadataExample();
|
|
|
244
196
|
"type": "module",
|
|
245
197
|
"scripts": {
|
|
246
198
|
"test-perplexity": "node test-perplexity.js",
|
|
247
|
-
"test-perplexity-stream": "node examples/streaming-perplexity.js"
|
|
248
|
-
"test-perplexity-metadata": "node examples/metadata-perplexity.js"
|
|
199
|
+
"test-perplexity-stream": "node examples/streaming-perplexity.js"
|
|
249
200
|
},
|
|
250
201
|
"dependencies": {
|
|
251
202
|
"@revenium/perplexity": "^1.0.0"
|
|
@@ -259,8 +210,6 @@ metadataExample();
|
|
|
259
210
|
# Test streaming
|
|
260
211
|
npm run test-perplexity-stream
|
|
261
212
|
|
|
262
|
-
# Test metadata
|
|
263
|
-
npm run test-perplexity-metadata
|
|
264
213
|
```
|
|
265
214
|
|
|
266
215
|
---
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LOG_LEVELS: string[];
|
package/package.json
CHANGED