Skip to content

Commit

Permalink
chore(internal): codegen related update (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 26, 2024
1 parent c08717b commit 7b53f7c
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- main
- next

jobs:
lint:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.prism.log
node_modules
yarn-error.log
codegen.log
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

Expand Down Expand Up @@ -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'.
<details>
<summary>More explanation</summary>
### 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.
</details>

Note that React Native is not supported at this time.

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/audio/transcriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/audio/translations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
27 changes: 18 additions & 9 deletions tests/api-resources/chat/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
Expand All @@ -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',
});
});
});
2 changes: 1 addition & 1 deletion tests/api-resources/embeddings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
});
});
8 changes: 4 additions & 4 deletions tests/api-resources/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
);
});
Expand All @@ -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;
Expand All @@ -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,
);
});
Expand Down

0 comments on commit 7b53f7c

Please sign in to comment.