Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
array,
enum as enumType,
maxValue,
minValue,
number,
object,
pipe,
string,
} from 'valibot'
import { array, enum as enumType, number, strictObject, string } from 'valibot'

const KindEnum = enumType({
'Migration Safety': 'Migration Safety',
Expand All @@ -23,26 +14,26 @@ const SeverityEnum = enumType({
POSITIVE: 'POSITIVE',
})

export const reviewSchema = object({
export const reviewSchema = strictObject({
bodyMarkdown: string(),
issues: array(
object({
strictObject({
kind: KindEnum,
severity: SeverityEnum,
description: string(),
suggestion: string(),
suggestionSnippets: array(
object({
strictObject({
filename: string(),
snippet: string(),
}),
),
}),
),
scores: array(
object({
strictObject({
kind: KindEnum,
value: pipe(number(), minValue(0), maxValue(10)),
value: number(),
Comment on lines -45 to +36
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the minimum property seems to trigger an error. I'll look into it at a later time. 🤔

{"error":{"message":"Invalid schema for response_format 'review': In context=('properties', 'scores', 'items', 'properties', 'value'), 'minimum' is not permitted.","type":"invalid_request_error","param":"response_format","code":null}}

reason: string(),
}),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ assert:
- type: javascript
# Test 1: Check if the snippet has the exact correct file path
value: |
JSON.parse(output).issues.find(issue => issue.kind === "Migration Safety").suggestionSnippets[0].filename === "frontend/packages/db/prisma/migrations/20250328105323_add_branch_name_to_knowledge_suggestion/migration.sql"
!!output.issues.flatMap(issue => issue.suggestionSnippets).find(snippet => snippet.filename === "frontend/packages/db/prisma/migrations/20250328105323_add_branch_name_to_knowledge_suggestion/migration.sql")
- type: javascript
# Test 2: Check if the snippet suggests setting a DEFAULT value for the branchName column
value: |
JSON.parse(output).issues.find(issue => issue.kind === "Migration Safety").suggestionSnippets[0].snippet.includes("ALTER TABLE \"KnowledgeSuggestion\" ADD COLUMN \"branchName\" TEXT NOT NULL DEFAULT '")
!!output.issues.flatMap(issue => issue.suggestionSnippets).find(snippet => snippet.snippet.includes("ALTER TABLE \"KnowledgeSuggestion\" ADD COLUMN \"branchName\" TEXT NOT NULL DEFAULT '"))
- type: javascript
value: JSON.parse(output).scores[0].value >= 1
value: output.scores[0].value >= 1
- type: cost
threshold: 0.008

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ assert:
value: The report evaluates the **risk of data loss**.
- type: is-json
- type: javascript
value: JSON.parse(output).scores[0].value >= 1
value: output.scores[0].value >= 1
- type: cost
threshold: 0.008

Expand Down
10 changes: 7 additions & 3 deletions frontend/packages/prompt-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ async function main() {
{
id: 'openai:gpt-4o-mini',
config: {
responseFormat: {
response_format: {
type: 'json_schema',
schema: reviewJsonSchema,
strict: true,
json_schema: {
name: 'review',
schema: reviewJsonSchema,
strict: true,
},
},
temperature: 0.7,
max_tokens: 16384, // gpt-4o-mini max tokens
},
},
],
Expand Down