-
Notifications
You must be signed in to change notification settings - Fork 151
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
base: main
Are you sure you want to change the base?
Changes from all commits
12e2fbf
1cc20ab
800f931
eb9b8cc
c17f366
37d8152
d9d3273
c3223ee
673b0c3
db079ce
db44d1d
701181b
fe4c1ff
edc73fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, | ||
| }; | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * 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> { | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| options?.logger?.("Reporting summary to Qualifire"); | ||
|
|
||
| const apiKey = request.qualifireApiKey; | ||
| const baseUrl = request.qualifireUrl ?? "https://api.qualifire.com"; | ||
| const endpoint = `${baseUrl}/llm/summary`; | ||
|
|
||
| if (!apiKey) { | ||
| throw new Error("qualifireApiKey is required but was undefined"); | ||
| } | ||
|
|
||
| if (!baseUrl || baseUrl === "undefined") { | ||
| throw new Error("Invalid qualifireUrl provided"); | ||
| } | ||
|
Comment on lines
46
to
56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§© Analysis chainDesign mismatch with PR objective: route via Rogue server, not direct Qualifire. This class posts directly to Qualifire ( Would you run the script below to locate the server summary endpoint and confirm the expected header so we can align the client? π Script executed: #!/bin/bash
set -euo pipefail
echo "== Find Rogue summary endpoint and Qualifire service usage =="
fd -a llm.py rogue/server | xargs -I{} rg -n -C3 -e 'router\.(post|get|put)\(' -e 'summary' {}
rg -n -C3 'qualifire' rogue/server || true
rg -n -C3 'X-Qualifire' rogue/server || trueLength of output: 8186 π Script executed: #!/bin/bash
set -euo pipefail
echo "== Check SDK qualifire client implementation =="
fd -a "qualifire.ts|qualifier.ts" packages/sdk/src
echo ""
echo "== Find request models for server /summary endpoint =="
rg -n -A10 "class SummaryGenerationRequest|SummaryGenerationRequest =" rogue/server --type py
echo ""
echo "== Check what auth/headers are expected by Rogue /summary endpoint =="
rg -n -B5 -A15 "@router.post\(\s*\"/summary\"" rogue/server --type pyLength of output: 152 π Script executed: #!/bin/bash
set -euo pipefail
echo "== SDK qualifire.ts current implementation =="
cat /home/jailuser/git/packages/sdk/src/qualifire.ts
echo ""
echo "== Rogue server request models =="
fd -a "models.py|schemas.py|types.py" rogue/server/api rogue/server/schemas 2>/dev/null | head -5 | xargs -I{} sh -c 'echo "=== {} ===" && head -100 {}'
echo ""
echo "== Search for SummaryGenerationRequest in all Python files =="
rg -n "SummaryGenerationRequest" rogue/server --type py -B2 -A5Length of output: 3865 π Script executed: #!/bin/bash
set -euo pipefail
echo "== Find SummaryGenerationRequest definition =="
rg -n "class SummaryGenerationRequest|SummaryGenerationRequest\s*=" rogue/server -A15 --type py
echo ""
echo "== Check import source for SummaryGenerationRequest =="
rg -n "from.*import.*SummaryGenerationRequest" rogue/server --type pyLength of output: 46 π Script executed: #!/bin/bash
set -euo pipefail
echo "== Search for Summary in rogue module structure =="
fd -a ".py$" rogue/server | xargs rg -l "SummaryGenerationRequest" | head -10
echo ""
echo "== Find all python files in rogue/server/api =="
fd -a ".py$" rogue/server/api
echo ""
echo "== Check rogue/server/schemas or similar =="
fd -a "schema|model" rogue/server --type dLength of output: 463 π Script executed: #!/bin/bash
set -euo pipefail
echo "== List models directory =="
fd -a ".py$" rogue/server/models
echo ""
echo "== Search for SummaryGenerationRequest in models =="
rg -n "SummaryGenerationRequest" rogue/server/models -A10
echo ""
echo "== Check rogue/server/api/__init__.py for exports =="
cat rogue/server/api/__init__.pyLength of output: 184 π Script executed: #!/bin/bash
set -euo pipefail
echo "== Check models/__init__.py =="
cat rogue/server/models/__init__.py
echo ""
echo "== Check models/api_format.py =="
head -150 rogue/server/models/api_format.py
echo ""
echo "== Broader search for SummaryGenerationRequest =="
rg -n "SummaryGenerationRequest" rogue/ -A5 | head -50Length of output: 2608 π Script executed: #!/bin/bash
set -euo pipefail
echo "== Check llm.py imports (first 30 lines) =="
head -30 rogue/server/api/llm.py
echo ""
echo "== Search for SummaryGenerationRequest definition anywhere in repo =="
rg -n "class SummaryGenerationRequest|SummaryGenerationRequest.*=" --type pyLength of output: 1043 Design mismatch confirmed: SDK posts directly to Qualifire instead of routing through Rogue server. The SDK calls π€ Prompt for AI Agents |
||
|
|
||
| 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; | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
1
to
92
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§© Analysis chainVerify duplicate implementation has been removed. Past reviews flagged a duplicate Run the following script to verify: π Script executed: #!/bin/bash
# Check if quatifier.ts still exists and search for any references to it
# Search for quatifier.ts file
echo "=== Checking for quatifier.ts file ==="
fd -e ts quatifier
# Search for imports from quatifier module
echo "=== Checking for imports from quatifier module ==="
rg -n --type=ts "from ['\"].*quatifier['\"]"
# Search for any references to quatifier in the codebase
echo "=== Checking for any references to 'quatifier' ==="
rg -n --type=ts "quatifier"Length of output: 249 Remove duplicated π€ Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ignorant05 please fix this one
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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.