-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Flexprice integration #96
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
3879a8d
4615451
5475861
fb86bd2
ed83afe
be29d97
5856eee
69e802f
248452f
212075c
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,17 +1,18 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Evaluator routes.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from fastapi import APIRouter, Depends, HTTPException, status, Query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, status, Query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from fastapi.responses import JSONResponse, Response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from sqlalchemy.orm import Session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from sqlalchemy import and_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from uuid import UUID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from uuid import UUID, uuid4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import random | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from typing import List | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from pydantic import BaseModel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from loguru import logger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from app.database import get_db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from app.dependencies import get_organization_id, get_workspace_id, get_api_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from app.services.billing.flexprice_service import record_evaluator_run_requested | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from app.models.database import Evaluator, Agent, Persona, Scenario, EvaluatorResult, EvaluatorResultStatus, VoiceBundle, Metric | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from app.models.schemas import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EvaluatorCreate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -548,6 +549,7 @@ def delete_evaluator( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @router.post("/run", response_model=RunEvaluatorsResponse, status_code=200) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def run_evaluators( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request: RunEvaluatorsRequest, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| background_tasks: BackgroundTasks, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| organization_id: UUID = Depends(get_organization_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workspace_id: UUID = Depends(get_workspace_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| db: Session = Depends(get_db), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -649,7 +651,15 @@ def run_evaluators( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not task_ids: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise HTTPException(status_code=500, detail="Failed to create any tasks") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| background_tasks.add_task( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| record_evaluator_run_requested, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| organization_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uuid4(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workspace_id=workspace_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| quantity=len(request.evaluator_ids), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+655
to
+661
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. The dispatch loop catches per-evaluator queue failures and continues, but this event bills
Suggested change
Comment on lines
+655
to
+661
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return RunEvaluatorsResponse( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task_ids=task_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| evaluator_results=evaluator_results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
task_idsis non-empty. This line then records the full requested count, so Flexprice bills evaluators that were never queued and can never produce results. Use the count of successfully queued tasks for this event.