Skip to content

Commit 659cf62

Browse files
chore: break long lines in snippets into multiline
1 parent 98345f3 commit 659cf62

File tree

4 files changed

+72
-13
lines changed

4 files changed

+72
-13
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ const search = await client.search
218218

219219
// Chat completions error handling
220220
const streamChunk = await client.chat.completions
221-
.create({ messages: [{ role: 'user', content: 'What is the capital of France?' }], model: 'sonar' })
221+
.create({
222+
messages: [{ role: 'user', content: 'What is the capital of France?' }],
223+
model: 'sonar',
224+
})
222225
.catch(async (err) => {
223226
if (err instanceof Perplexity.APIError) {
224227
console.log(err.status); // 400

tests/api-resources/async/chat/completions.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ describe('resource completions', () => {
6363
},
6464
],
6565
tool_call_id: 'tool_call_id',
66-
tool_calls: [{ id: 'id', function: { arguments: 'arguments', name: 'name' }, type: 'function' }],
66+
tool_calls: [
67+
{
68+
id: 'id',
69+
function: { arguments: 'arguments', name: 'name' },
70+
type: 'function',
71+
},
72+
],
6773
},
6874
],
6975
model: 'model',
@@ -142,7 +148,13 @@ describe('resource completions', () => {
142148
image_results_enhanced_relevance: true,
143149
search_context_size: 'low',
144150
search_type: 'fast',
145-
user_location: { city: 'city', country: 'country', latitude: 0, longitude: 0, region: 'region' },
151+
user_location: {
152+
city: 'city',
153+
country: 'country',
154+
latitude: 0,
155+
longitude: 0,
156+
region: 'region',
157+
},
146158
},
147159
},
148160
idempotency_key: 'idempotency_key',

tests/api-resources/chat/completions.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ describe('resource completions', () => {
6363
},
6464
],
6565
tool_call_id: 'tool_call_id',
66-
tool_calls: [{ id: 'id', function: { arguments: 'arguments', name: 'name' }, type: 'function' }],
66+
tool_calls: [
67+
{
68+
id: 'id',
69+
function: { arguments: 'arguments', name: 'name' },
70+
type: 'function',
71+
},
72+
],
6773
},
6874
],
6975
model: 'model',
@@ -142,7 +148,13 @@ describe('resource completions', () => {
142148
image_results_enhanced_relevance: true,
143149
search_context_size: 'low',
144150
search_type: 'fast',
145-
user_location: { city: 'city', country: 'country', latitude: 0, longitude: 0, region: 'region' },
151+
user_location: {
152+
city: 'city',
153+
country: 'country',
154+
latitude: 0,
155+
longitude: 0,
156+
region: 'region',
157+
},
146158
},
147159
});
148160
});

tests/index.test.ts

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ describe('instantiate client', () => {
8787
error: jest.fn(),
8888
};
8989

90-
const client = new Perplexity({ logger: logger, logLevel: 'debug', apiKey: 'My API Key' });
90+
const client = new Perplexity({
91+
logger: logger,
92+
logLevel: 'debug',
93+
apiKey: 'My API Key',
94+
});
9195

9296
await forceAPIResponseForClient(client);
9397
expect(debugMock).toHaveBeenCalled();
@@ -107,7 +111,11 @@ describe('instantiate client', () => {
107111
error: jest.fn(),
108112
};
109113

110-
const client = new Perplexity({ logger: logger, logLevel: 'info', apiKey: 'My API Key' });
114+
const client = new Perplexity({
115+
logger: logger,
116+
logLevel: 'info',
117+
apiKey: 'My API Key',
118+
});
111119

112120
await forceAPIResponseForClient(client);
113121
expect(debugMock).not.toHaveBeenCalled();
@@ -157,7 +165,11 @@ describe('instantiate client', () => {
157165
};
158166

159167
process.env['PERPLEXITY_LOG'] = 'debug';
160-
const client = new Perplexity({ logger: logger, logLevel: 'off', apiKey: 'My API Key' });
168+
const client = new Perplexity({
169+
logger: logger,
170+
logLevel: 'off',
171+
apiKey: 'My API Key',
172+
});
161173

162174
await forceAPIResponseForClient(client);
163175
expect(debugMock).not.toHaveBeenCalled();
@@ -173,7 +185,11 @@ describe('instantiate client', () => {
173185
};
174186

175187
process.env['PERPLEXITY_LOG'] = 'not a log level';
176-
const client = new Perplexity({ logger: logger, logLevel: 'debug', apiKey: 'My API Key' });
188+
const client = new Perplexity({
189+
logger: logger,
190+
logLevel: 'debug',
191+
apiKey: 'My API Key',
192+
});
177193
expect(client.logLevel).toBe('debug');
178194
expect(warnMock).not.toHaveBeenCalled();
179195
});
@@ -543,7 +559,11 @@ describe('retries', () => {
543559
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
544560
};
545561

546-
const client = new Perplexity({ apiKey: 'My API Key', timeout: 10, fetch: testFetch });
562+
const client = new Perplexity({
563+
apiKey: 'My API Key',
564+
timeout: 10,
565+
fetch: testFetch,
566+
});
547567

548568
expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
549569
expect(count).toEqual(2);
@@ -573,7 +593,11 @@ describe('retries', () => {
573593
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
574594
};
575595

576-
const client = new Perplexity({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
596+
const client = new Perplexity({
597+
apiKey: 'My API Key',
598+
fetch: testFetch,
599+
maxRetries: 4,
600+
});
577601

578602
expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
579603

@@ -597,7 +621,11 @@ describe('retries', () => {
597621
capturedRequest = init;
598622
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
599623
};
600-
const client = new Perplexity({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
624+
const client = new Perplexity({
625+
apiKey: 'My API Key',
626+
fetch: testFetch,
627+
maxRetries: 4,
628+
});
601629

602630
expect(
603631
await client.request({
@@ -659,7 +687,11 @@ describe('retries', () => {
659687
capturedRequest = init;
660688
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
661689
};
662-
const client = new Perplexity({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
690+
const client = new Perplexity({
691+
apiKey: 'My API Key',
692+
fetch: testFetch,
693+
maxRetries: 4,
694+
});
663695

664696
expect(
665697
await client.request({

0 commit comments

Comments
 (0)