-
Notifications
You must be signed in to change notification settings - Fork 118
Feature: mimic the qualifire integration in python sdk #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ignorant05
wants to merge
14
commits into
qualifire-dev:main
Choose a base branch
from
ignorant05:feature/Add-qualifire-integration-in-the-typescript-SDK
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
12e2fbf
Feature: mimic the quatifier integration in python sdk
ignorant05 1cc20ab
Fix: resolved errors and warnings as suggested
ignorant05 800f931
Fix: minor errors and warnings
ignorant05 eb9b8cc
Fix: minor errors and warnings
ignorant05 c17f366
Fix: removed mispelled file quatifier.ts
ignorant05 37d8152
Fix: minor/potential errors
ignorant05 d9d3273
Fix: some potential issues as the cursor bot suggested
ignorant05 c3223ee
Merge branch 'main' into feature/Add-qualifire-integration-in-the-typβ¦
drorIvry 673b0c3
Skip rogue sanity on fork PRs (#116)
yuval-qf db079ce
FIRE-812 | Rogue-TUI | MCP Support (#115)
yuval-qf db44d1d
Fix: update path
ignorant05 701181b
Fix: wrong path
ignorant05 fe4c1ff
Resoved conflicts
ignorant05 edc73fe
Rmoved duplicates
ignorant05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { EvaluationResult, ReportSummaryRequest, StructuredSummary } from "./types"; | ||
|
|
||
| interface QualifireReportPayload { | ||
| job_id: string; | ||
| evaluations: EvaluationResult; | ||
| structured: StructuredSummary | null; | ||
| deep_test: boolean; | ||
| start_time: string; | ||
| judge_model: string | null; | ||
| } | ||
|
|
||
| export interface QualifireClientOptions { | ||
| logger?: (message: string) => void; | ||
| } | ||
|
|
||
| export class QualifireClient { | ||
| private static convertWithStructuredSummary( | ||
| evaluationResults: EvaluationResult, | ||
| request: ReportSummaryRequest | ||
| ): QualifireReportPayload { | ||
| return { | ||
| job_id: request.job_id, | ||
| evaluations: evaluationResults, | ||
| structured: request.structuredSummary || null, | ||
| deep_test: request.deepTest ?? false, | ||
| start_time: request.startTime ?? new Date().toISOString(), | ||
| judge_model: request.judgeModel || null, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Reports evaluation summary to Qualifire. | ||
| * | ||
| * @param evaluationResults - The evaluation results to report | ||
| * @param request - Configuration including Qualifire URL, API key, and metadata | ||
| * @throws {Error} If the API request fails or returns a non-2xx status | ||
| * @returns A promise that resolves when the report is successfully submitted | ||
| */ | ||
| public static async reportSummaryToQualifire( | ||
| evaluationResults: EvaluationResult, | ||
| request: ReportSummaryRequest, | ||
| options?: QualifireClientOptions | ||
| ): Promise<void> { | ||
| options?.logger?.("Reporting summary to Qualifire"); | ||
|
|
||
| const apiKey = request.qualifireApiKey; | ||
| const baseUrl = request.qualifireUrl ?? "https://api.qualifire.com"; | ||
| const endpoint = `${baseUrl}/api/evaluation/evaluate`; | ||
|
|
||
| if (!apiKey) { | ||
| throw new Error("qualifireApiKey is required but was undefined"); | ||
| } | ||
|
|
||
| if (!baseUrl || baseUrl === "undefined") { | ||
| throw new Error("Invalid qualifireUrl provided"); | ||
| } | ||
|
|
||
| const apiEvaluationResult = this.convertWithStructuredSummary( | ||
| evaluationResults, | ||
| request | ||
| ); | ||
|
|
||
| const controller = new AbortController(); | ||
| const timeoutId = setTimeout(() => controller.abort(), 30000); | ||
|
|
||
| try { | ||
| const response = await fetch(endpoint, { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| "X-Qualifire-API-Key": apiKey, | ||
| }, | ||
| body: JSON.stringify(apiEvaluationResult), | ||
| signal: controller.signal | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| const errText = await response.text(); | ||
| throw new Error( | ||
| `Qualifire report failed: ${response.status} ${response.statusText} - ${errText}` | ||
| ); | ||
| } | ||
| clearTimeout(timeoutId); | ||
| } catch (error) { | ||
| clearTimeout(timeoutId); | ||
| if (error instanceof Error && error.name === 'AbortError') { | ||
| throw new Error('Qualifire report timed out after 30 seconds'); | ||
| } | ||
| throw error; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type mismatch:
deep_testandstart_timeshould be nullable.The
QualifireReportPayloadinterface definesdeep_test: booleanandstart_time: stringas required fields. However, the source fields inReportSummaryRequestare optional (deepTest?: boolean,startTime?: string). This creates a type mismatch whereundefinedvalues can be assigned to non-nullable fields in the payload, violating the type contract and potentially causing API errors.Apply this diff to make the fields nullable:
interface QualifireReportPayload { job_id: string; evaluations: EvaluationResult; structured: StructuredSummary | null; - deep_test: boolean; - start_time: string; + deep_test: boolean | null; + start_time: string | null; judge_model: string | null; }Then update the mapping in
convertWithStructuredSummary:return { job_id: request.job_id, evaluations: evaluationResults, structured: request.structuredSummary || null, - deep_test: request.deepTest, - start_time: request.startTime, + deep_test: request.deepTest ?? null, + start_time: request.startTime ?? null, judge_model: request.judgeModel || null, };π€ Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ignorant05 I think this comment is correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.