Skip to content

Commit

Permalink
chore: Update sdk-react
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith committed Dec 11, 2024
1 parent df1acf4 commit b74edef
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions sdk-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ It can be used to interact with an existing run by specifying the `runId`:
const { messages, run, createMessage, start } = useRun({
clusterId: 'your-cluster-id',
apiSecret: 'your-api-secret',
authType: 'customer', // or 'cluster'
authType: 'custom', // or 'cluster'
// pollInterval: 1000, // Optional: defaults to 1000ms
});

Expand All @@ -70,7 +70,7 @@ It can be used to create a new run by specifying an `initialPrompt`:
const { messages, run, createMessage, start } = useRun({
clusterId: 'your-cluster-id',
apiSecret: 'your-api-secret',
authType: 'customer', // or 'cluster'
authType: 'custom', // or 'cluster'
// pollInterval: 1000, // Optional: defaults to 1000ms
});

Expand Down Expand Up @@ -99,7 +99,7 @@ You can handle errors by providing an `onError` callback:
const { messages, run, createMessage } = useRun({
clusterId: 'your-cluster-id',
apiSecret: 'your-api-secret',
authType: 'customer', // or 'cluster'
authType: 'custom', // or 'cluster'
configId: 'your-config-id',
onError: (error) => {
console.error('Run error:', error);
Expand Down
4 changes: 2 additions & 2 deletions sdk-react/demo/TestPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useRun } from '../src';

type TestPageProps = {
baseUrl?: string;
customerProvidedSecret?: string;
apiSecret?: string;
apiSecret: string;
authType?: 'custom' | 'cluster';
clusterId: string;
configId: string;
initialPrompt?: string;
Expand Down
8 changes: 2 additions & 6 deletions sdk-react/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export const definition = {
.describe(
"Enable additional logging (Including prompts and results) for use by Inferable support",
),
enableCustomerAuth: z.boolean().optional(),
enableCustomAuth: z.boolean().optional(),
enableRunConfigs: z.boolean().optional(),
enableKnowledgebase: z.boolean().optional(),
}),
Expand All @@ -359,7 +359,7 @@ export const definition = {
additionalContext: VersionedTextsSchema.nullable(),
createdAt: z.date(),
debug: z.boolean(),
enableCustomerAuth: z.boolean(),
enableCustomAuth: z.boolean(),
enableRunConfigs: z.boolean(),
enableKnowledgebase: z.boolean(),
lastPingAt: z.date().nullable(),
Expand Down Expand Up @@ -1092,7 +1092,6 @@ export const definition = {
attachedFunctions: z.array(z.string()),
resultSchema: anyObject.nullable(),
inputSchema: anyObject.nullable(),
public: z.boolean(),
createdAt: z.date(),
updatedAt: z.date(),
versions: z.array(
Expand All @@ -1104,7 +1103,6 @@ export const definition = {
attachedFunctions: z.array(z.string()),
resultSchema: anyObject.nullable(),
inputSchema: anyObject.nullable(),
public: z.boolean(),
}),
),
}),
Expand Down Expand Up @@ -1133,7 +1131,6 @@ export const definition = {
attachedFunctions: z.array(z.string()).optional(),
resultSchema: anyObject.optional(),
inputSchema: z.object({}).passthrough().optional().nullable(),
public: z.boolean(),
}),
responses: {
201: z.object({ id: z.string() }),
Expand Down Expand Up @@ -1161,7 +1158,6 @@ export const definition = {
attachedFunctions: z.array(z.string()).optional(),
resultSchema: z.object({}).passthrough().optional().nullable(),
inputSchema: z.object({}).passthrough().optional().nullable(),
public: z.boolean(),
}),
responses: {
200: z.object({
Expand Down
6 changes: 3 additions & 3 deletions sdk-react/src/createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export const createApiClient = ({
}: {
baseUrl?: string;
clientAbortController?: AbortController;
authType?: 'customer' | 'cluster';
authType?: 'custom' | 'cluster';
apiSecret?: string
}) => {
const baseHeaders = authType === 'customer' ? {
Authorization: `customer ${apiSecret}`
const baseHeaders = authType === 'custom' ? {
Authorization: `custom ${apiSecret}`
} : {
Authorization: `bearer ${apiSecret}`
};
Expand Down
2 changes: 1 addition & 1 deletion sdk-react/src/hooks/useRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ClientInferRequest, ClientInferResponseBody } from '@ts-rest/core';
type UseRunOptions = {
clusterId: string;
apiSecret: string;
authType?: 'customer' | 'cluster';
authType?: 'custom' | 'cluster';
baseUrl?: string;
pollInterval?: number;
onError?: (error: Error) => void;
Expand Down

0 comments on commit b74edef

Please sign in to comment.