Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeesha committed Nov 13, 2024
1 parent c313b7c commit 193e77b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
3 changes: 2 additions & 1 deletion sdk-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"devDependencies": {
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.22.11",
"@types/jest": "^29.5.4",
"@types/jest": "^29.5.14",
"@types/node-os-utils": "^1.3.4",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
Expand Down
31 changes: 14 additions & 17 deletions sdk-node/src/Inferable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,25 +294,22 @@ describe("Inferable SDK End to End Test", () => {
it("should be able to call the api directly", async () => {
const client = inferableInstance();

expect(
await client.api.createStructuredOutput({
params: {
clusterId: TEST_CLUSTER_ID,
},
body: {
prompt: "What is the capital of France?",
modelId: "claude-3-5-sonnet",
resultSchema: {
type: "object",
properties: {
capital: { type: "string" },
},
},
const result = await client.api.createStructuredOutput<{
capital: string;
}>({
prompt: "What is the capital of France?",
modelId: "claude-3-5-sonnet",
resultSchema: {
type: "object",
properties: {
capital: { type: "string" },
},
}),
).toEqual({
},
});

expect(result).toMatchObject({
success: true,
result: {
data: {
capital: "Paris",
},
});
Expand Down
17 changes: 16 additions & 1 deletion sdk-node/src/Inferable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,22 @@ export class Inferable {
}

public get api() {
return this.client;
return {
createStructuredOutput: async <T>(
input: Parameters<typeof this.client.createStructuredOutput>[0]["body"],
) =>
this.client
.createStructuredOutput({
params: {
clusterId: await this.getClusterId(),
},
body: input,
})
.then((r) => r.body) as Promise<{
success: boolean;
data?: T;
}>,
};
}

private async getClusterId() {
Expand Down

0 comments on commit 193e77b

Please sign in to comment.