mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-04 10:52:17 +02:00
Implement cost calculator for Tuber (#471)
* Adding cost calculation in tuner for BYOK * fix * implement cost calculator for Tuner * Update api/services/integrations/tuner/completion.py Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * feat: expose render_options in node spec * Update api/services/integrations/registry.py Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: mohamed salem <259547077+mohamedsalem-bot@users.noreply.github.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
This commit is contained in:
parent
97803b8121
commit
65d46bc313
16 changed files with 479 additions and 188 deletions
|
|
@ -11,6 +11,7 @@ from api.services.integrations.base import IntegrationCompletionContext
|
|||
|
||||
from .client import TunerDeliveryConfig, post_call
|
||||
from .collector import TUNER_RECORDING_PLACEHOLDER
|
||||
from .cost import compute_call_cost_cents
|
||||
from .node import TunerNodeData
|
||||
|
||||
|
||||
|
|
@ -55,6 +56,14 @@ async def run_completion(
|
|||
payload = copy.deepcopy(payload_snapshot)
|
||||
payload["recording_url"] = recording_url
|
||||
|
||||
call_cost = compute_call_cost_cents(
|
||||
tuner_data,
|
||||
context.workflow_run.usage_info,
|
||||
transcript_segments=payload.get("transcript_with_tool_calls"),
|
||||
)
|
||||
if call_cost is not None:
|
||||
payload["call_cost"] = call_cost
|
||||
|
||||
try:
|
||||
config = TunerDeliveryConfig(
|
||||
base_url=TUNER_BASE_URL,
|
||||
|
|
@ -67,6 +76,7 @@ async def run_completion(
|
|||
**delivery,
|
||||
"workspace_id": tuner_data.tuner_workspace_id,
|
||||
"agent_id": tuner_data.tuner_agent_id,
|
||||
**({"call_cost": call_cost} if call_cost is not None else {}),
|
||||
"exported_at": datetime.now(UTC).isoformat(),
|
||||
}
|
||||
except Exception as exc:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue