From 7f03bdac9a7048307de84f6c0d427de28db1b38b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2024 17:49:59 +0000 Subject: [PATCH] chore(internal): codegen related update (#105) --- .github/workflows/ci.yml | 1 + .gitignore | 1 + README.md | 14 +++++++++- .../audio/transcriptions.test.ts | 2 +- .../api-resources/audio/translations.test.ts | 2 +- tests/api-resources/chat/completions.test.ts | 27 ++++++++++++------- tests/api-resources/embeddings.test.ts | 2 +- tests/api-resources/models.test.ts | 8 +++--- 8 files changed, 40 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 491db96..d791adb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ on: pull_request: branches: - main + - next jobs: lint: diff --git a/.gitignore b/.gitignore index 9a5858a..3eed6dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.prism.log node_modules yarn-error.log codegen.log diff --git a/README.md b/README.md index df2290a..fe2244d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This library provides convenient access to the Groq REST API from server-side TypeScript or JavaScript. -The REST API documentation can be found [on console.groq.com](https://console.groq.com/docs). The full API of this library can be found in [api.md](api.md). +The REST API documentation can be found on [console.groq.com](https://console.groq.com/docs). The full API of this library can be found in [api.md](api.md). It is generated with [Stainless](https://www.stainlessapi.com/). @@ -329,6 +329,18 @@ The following runtimes are supported: - Vercel Edge Runtime. - Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time). - Nitro v2.6 or greater. +- Web browsers: disabled by default to avoid exposing your secret API credentials. Enable browser support by explicitly setting `dangerouslyAllowBrowser` to true'. +
+ More explanation + ### Why is this dangerous? + Enabling the `dangerouslyAllowBrowser` option can be dangerous because it exposes your secret API credentials in the client-side code. Web browsers are inherently less secure than server environments, + any user with access to the browser can potentially inspect, extract, and misuse these credentials. This could lead to unauthorized access using your credentials and potentially compromise sensitive data or functionality. + ### When might this not be dangerous? + In certain scenarios where enabling browser support might not pose significant risks: + - Internal Tools: If the application is used solely within a controlled internal environment where the users are trusted, the risk of credential exposure can be mitigated. + - Public APIs with Limited Scope: If your API has very limited scope and the exposed credentials do not grant access to sensitive data or critical operations, the potential impact of exposure is reduced. + - Development or debugging purpose: Enabling this feature temporarily might be acceptable, provided the credentials are short-lived, aren't also used in production environments, or are frequently rotated. +
Note that React Native is not supported at this time. diff --git a/tests/api-resources/audio/transcriptions.test.ts b/tests/api-resources/audio/transcriptions.test.ts index aa27c59..128fb05 100644 --- a/tests/api-resources/audio/transcriptions.test.ts +++ b/tests/api-resources/audio/transcriptions.test.ts @@ -28,7 +28,7 @@ describe('resource transcriptions', () => { file: await toFile(Buffer.from('# my file contents'), 'README.md'), model: 'whisper-large-v3', language: 'string', - prompt: 'string', + prompt: 'prompt', response_format: 'json', temperature: 0, timestamp_granularities: ['word', 'segment'], diff --git a/tests/api-resources/audio/translations.test.ts b/tests/api-resources/audio/translations.test.ts index 12e391e..585dea5 100644 --- a/tests/api-resources/audio/translations.test.ts +++ b/tests/api-resources/audio/translations.test.ts @@ -27,7 +27,7 @@ describe('resource translations', () => { const response = await groq.audio.translations.create({ file: await toFile(Buffer.from('# my file contents'), 'README.md'), model: 'whisper-1', - prompt: 'string', + prompt: 'prompt', response_format: 'json', temperature: 0, }); diff --git a/tests/api-resources/chat/completions.test.ts b/tests/api-resources/chat/completions.test.ts index 358eb24..0690d40 100644 --- a/tests/api-resources/chat/completions.test.ts +++ b/tests/api-resources/chat/completions.test.ts @@ -11,7 +11,7 @@ const groq = new Groq({ describe('resource completions', () => { test('create: only required params', async () => { const responsePromise = groq.chat.completions.create({ - messages: [{ content: 'string', role: 'system' }], + messages: [{ content: 'content', role: 'system' }], model: 'string', }); const rawResponse = await responsePromise.asResponse(); @@ -25,14 +25,14 @@ describe('resource completions', () => { test('create: required and optional params', async () => { const response = await groq.chat.completions.create({ - messages: [{ content: 'string', role: 'system', name: 'string', tool_call_id: 'string' }], + messages: [{ content: 'content', role: 'system', name: 'name', tool_call_id: 'tool_call_id' }], model: 'string', frequency_penalty: -2, function_call: 'none', functions: [ - { description: 'string', name: 'string', parameters: { foo: 'bar' } }, - { description: 'string', name: 'string', parameters: { foo: 'bar' } }, - { description: 'string', name: 'string', parameters: { foo: 'bar' } }, + { description: 'description', name: 'name', parameters: { foo: 'bar' } }, + { description: 'description', name: 'name', parameters: { foo: 'bar' } }, + { description: 'description', name: 'name', parameters: { foo: 'bar' } }, ], logit_bias: { foo: 0 }, logprobs: true, @@ -48,13 +48,22 @@ describe('resource completions', () => { temperature: 1, tool_choice: 'none', tools: [ - { type: 'function', function: { description: 'string', name: 'string', parameters: { foo: 'bar' } } }, - { type: 'function', function: { description: 'string', name: 'string', parameters: { foo: 'bar' } } }, - { type: 'function', function: { description: 'string', name: 'string', parameters: { foo: 'bar' } } }, + { + type: 'function', + function: { description: 'description', name: 'name', parameters: { foo: 'bar' } }, + }, + { + type: 'function', + function: { description: 'description', name: 'name', parameters: { foo: 'bar' } }, + }, + { + type: 'function', + function: { description: 'description', name: 'name', parameters: { foo: 'bar' } }, + }, ], top_logprobs: 0, top_p: 1, - user: 'string', + user: 'user', }); }); }); diff --git a/tests/api-resources/embeddings.test.ts b/tests/api-resources/embeddings.test.ts index 0ae949f..7356c36 100644 --- a/tests/api-resources/embeddings.test.ts +++ b/tests/api-resources/embeddings.test.ts @@ -28,7 +28,7 @@ describe('resource embeddings', () => { input: 'The quick brown fox jumped over the lazy dog', model: 'nomic-embed-text-v1_5', encoding_format: 'float', - user: 'string', + user: 'user', }); }); }); diff --git a/tests/api-resources/models.test.ts b/tests/api-resources/models.test.ts index fb2fb5e..b27f63b 100644 --- a/tests/api-resources/models.test.ts +++ b/tests/api-resources/models.test.ts @@ -10,7 +10,7 @@ const groq = new Groq({ describe('resource models', () => { test('retrieve', async () => { - const responsePromise = groq.models.retrieve('string'); + const responsePromise = groq.models.retrieve('model'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource models', () => { test('retrieve: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect(groq.models.retrieve('string', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(groq.models.retrieve('model', { path: '/_stainless_unknown_path' })).rejects.toThrow( Groq.NotFoundError, ); }); @@ -44,7 +44,7 @@ describe('resource models', () => { }); test('delete', async () => { - const responsePromise = groq.models.delete('string'); + const responsePromise = groq.models.delete('model'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -56,7 +56,7 @@ describe('resource models', () => { test('delete: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect(groq.models.delete('string', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(groq.models.delete('model', { path: '/_stainless_unknown_path' })).rejects.toThrow( Groq.NotFoundError, ); });