Skip to content

Commit

Permalink
typegen for responder
Browse files Browse the repository at this point in the history
  • Loading branch information
yujonglee committed Sep 26, 2024
1 parent 3d174ee commit 5b43356
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 48 deletions.
119 changes: 72 additions & 47 deletions core/lib/canary/prompts/responder_assistant_schema.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,77 @@
{
"type": "object",
"properties": {
"thinking": {
"type": "string"
},
"response": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["text", "reference"]
}
},
"required": ["type"],
"oneOf": [
{
"properties": {
"type": {
"const": "text"
},
"text": {
"type": "string"
}
"type": "object",
"title": "AskResponse",
"properties": {
"scratchpad": {
"type": "string"
},
"blocks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["text", "reference"]
}
},
"required": ["type"],
"oneOf": [
{
"title": "AskResponseTextBlock",
"properties": {
"type": {
"const": "text"
},
"required": ["text"]
"text": {
"type": "string"
}
},
{
"properties": {
"type": {
"const": "reference"
},
"url": {
"type": "string"
},
"title": {
"type": "string"
},
"excerpt": {
"type": "string"
}
"required": ["type", "text"],
"additionalProperties": false
},
{
"title": "AskResponseReferenceBlock",
"properties": {
"type": {
"const": "reference"
},
"required": ["url", "title", "excerpt"]
}
]
}
"title": {
"type": "string"
},
"url": {
"type": "string"
},
"sections": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"url": {
"type": "string"
},
"excerpt": {
"type": "string"
},
"explanation": {
"type": "string"
}
},
"required": ["excerpt", "explanation"],
"additionalProperties": false
}
}
},
"required": ["type", "title", "url", "sections"],
"additionalProperties": false
}
]
}
},
"required": ["thinking", "response"]
}
}
},
"required": ["blocks"],
"additionalProperties": false
}
4 changes: 3 additions & 1 deletion js/packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"test": "npm run test-utils && npm run test-storybook",
"test-utils": "vitest run",
"test-storybook": "test-storybook",
"typegen": "npx json2ts 'src/types/schema/*.json' src/types/schema"
"typegen": "npm run typegen:internal && npm run typegen:external",
"typegen:internal": "npx json2ts 'src/types/schema/*.json' src/types/schema",
"typegen:external": "npx json2ts '../../../core/lib/canary/prompts/responder_assistant_schema.json' src/types/schema/responder.d.ts"
},
"dependencies": {
"@floating-ui/dom": "^1.6.8",
Expand Down
1 change: 1 addition & 0 deletions js/packages/web/src/types/schema/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./tabs";
export * from "./responder";
26 changes: 26 additions & 0 deletions js/packages/web/src/types/schema/responder.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

export interface AskResponse {
scratchpad?: string;
blocks: (AskResponseTextBlock | AskResponseReferenceBlock)[];
}
export interface AskResponseTextBlock {
type: "text";
text: string;
}
export interface AskResponseReferenceBlock {
type: "reference";
title: string;
url: string;
sections: {
title?: string;
url?: string;
excerpt: string;
explanation: string;
}[];
}

0 comments on commit 5b43356

Please sign in to comment.