Compare commits
3 Commits
c4ee8b68a9
...
7e75d15a27
| Author | SHA1 | Date |
|---|---|---|
|
|
7e75d15a27 | |
|
|
d2a65af57b | |
|
|
56672b38f9 |
|
|
@ -130,6 +130,34 @@ class TranscriptionReportService:
|
|||
self.mongo_results = list(collection.aggregate(pipeline))
|
||||
self.unique_ids = [doc["_id"] for doc in self.mongo_results]
|
||||
|
||||
# TEST
|
||||
# print("======> self.mongo_results: ", self.mongo_results)
|
||||
|
||||
# if rowMongo := next((m for m in self.mongo_results), None):
|
||||
# print("============>", rowMongo["totalCost"])
|
||||
|
||||
# stt = rowMongo.get('usageByType', {}).get('stt', {})
|
||||
|
||||
# if not stt:
|
||||
# stt = rowMongo.get('usageByType', {}).get('input-audio', {})
|
||||
|
||||
# # minutes
|
||||
# usageMinute = round(stt.get('usage', 0) / 1920, 2)
|
||||
|
||||
# # seconds
|
||||
# token_by_second = 1920 / 60
|
||||
# usageSeconds = round(stt.get('usage', 0) / token_by_second)
|
||||
|
||||
|
||||
# print("======> stt_model: ", stt.get('product', 'unknown'))
|
||||
# print("======> stt_provider: ", stt.get('provider', 'unknown'))
|
||||
# print("======> stt_cost: ", rowMongo["totalCost"])
|
||||
# print("======> stt_usage_minute: ", f"{usageMinute:.2f}")
|
||||
# print("======> stt_usageSeconds: ", f"{usageSeconds}")
|
||||
|
||||
# exit(1)
|
||||
# END TEST
|
||||
|
||||
# Pipeline para contagem total
|
||||
count_pipeline = [
|
||||
match_stage,
|
||||
|
|
@ -175,6 +203,7 @@ class TranscriptionReportService:
|
|||
uniqueid, src, dst;"""
|
||||
rows = execute_query(self.company_id, sql)
|
||||
|
||||
|
||||
if hit_report:
|
||||
for row in rows:
|
||||
row["companyId"] = self.company_id
|
||||
|
|
@ -190,11 +219,25 @@ class TranscriptionReportService:
|
|||
row["total_cost_token"] = float(token_input.get('usageCost',0) + token_output.get('usageCost', 0))
|
||||
row["llm_provider"] = token_output.get('provider','unknown')
|
||||
|
||||
tts = rowMongo.get('usageByType', {}).get('stt',{})
|
||||
row["tts_model"] = tts.get('product', 'unknown')
|
||||
row["tts_provider"] = tts.get('provider', 'unknown')
|
||||
row["tts_cost"] = tts.get('usageCost', 0)
|
||||
row["tts_usage"] = tts.get('usage', 0)
|
||||
stt = rowMongo.get('usageByType', {}).get('stt',{})
|
||||
|
||||
if not stt:
|
||||
stt = rowMongo.get('usageByType', {}).get('input-audio',{})
|
||||
|
||||
# seconds
|
||||
token_by_second = 1920 / 60 # Cobrança de token por minuto do modelo gemini flash 2.5 input de audio
|
||||
usageSeconds = round(stt.get('usage', 0) / token_by_second)
|
||||
|
||||
row["stt_model"] = stt.get('product', 'unknown')
|
||||
row["stt_provider"] = stt.get('provider', 'unknown')
|
||||
row["stt_cost"] = rowMongo["totalCost"]
|
||||
row["stt_usage"] = usageSeconds
|
||||
|
||||
else:
|
||||
row["stt_model"] = stt.get('product', 'unknown')
|
||||
row["stt_provider"] = stt.get('provider', 'unknown')
|
||||
row["stt_cost"] = stt.get('usageCost', 0)
|
||||
row["stt_usage"] = stt.get('usage', 0)
|
||||
|
||||
row["total_min"] = f"{(int(row['total_billsec']) / 60):.2f}"
|
||||
|
||||
|
|
@ -266,10 +309,10 @@ class TranscriptionReportService:
|
|||
"total_cost_token": "Preço Final LLM",
|
||||
"llm_provider": "Provider LLM",
|
||||
|
||||
"tts_model": "TTS",
|
||||
"tts_provider": "Provider TTS",
|
||||
"tts_cost": "Preço Final TTS",
|
||||
"tts_usage": "Segundos Transcritos",
|
||||
"stt_model": "STT",
|
||||
"stt_provider": "Provider STT",
|
||||
"stt_cost": "Preço Final STT",
|
||||
"stt_usage": "Segundos Transcritos",
|
||||
|
||||
"client_total_cost": "Custo Cliente",
|
||||
"client_price": "Preço Cliente por Minuto",
|
||||
|
|
|
|||
|
|
@ -60,10 +60,10 @@ interface HitTranscriptionData {
|
|||
total_cost_token: number // Total token(input + output)
|
||||
llm_provider: string // Provider llm
|
||||
|
||||
// tts_model: string // Modelo de trascrição de audio para texto
|
||||
tts_provider: string // Provedor do tts
|
||||
tts_cost: number // Custo total dos minutos do audio em texto
|
||||
tts_usage: number // Tempo total de trascrição do audio em segundos
|
||||
// stt_model: string // Modelo de trascrição de audio para texto
|
||||
stt_provider: string // Provedor do tts
|
||||
stt_cost: number // Custo total dos minutos do audio em texto
|
||||
stt_usage: number // Tempo total de trascrição do audio em segundos
|
||||
|
||||
total_min: number // Minutos de ligação
|
||||
custo_hit: string // Custo HIT
|
||||
|
|
@ -553,16 +553,16 @@ export default function TranscriptionTable() {
|
|||
</TableCell>
|
||||
|
||||
<TableCell>{(item as HitTranscriptionData).llm_provider || "-"}</TableCell>
|
||||
{/* <TableCell>{(item as HitTranscriptionData).tts_model || "-"}</TableCell> */}
|
||||
<TableCell>{(item as HitTranscriptionData).tts_provider || "-"}</TableCell>
|
||||
{/* <TableCell>{(item as HitTranscriptionData).stt_model || "-"}</TableCell> */}
|
||||
<TableCell>{(item as HitTranscriptionData).stt_provider || "-"}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
{(item as HitTranscriptionData)?.tts_cost
|
||||
? `$ ${Number((item as HitTranscriptionData).tts_cost).toFixed(2)}`
|
||||
{(item as HitTranscriptionData)?.stt_cost
|
||||
? `$ ${Number((item as HitTranscriptionData).stt_cost).toFixed(2)}`
|
||||
: "-"}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{(item as HitTranscriptionData).tts_usage || "-"}</TableCell>
|
||||
<TableCell>{(item as HitTranscriptionData).stt_usage || "-"}</TableCell>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Reference in New Issue