Compare commits
3 Commits
c4ee8b68a9
...
7e75d15a27
| Author | SHA1 | Date |
|---|---|---|
|
|
7e75d15a27 | |
|
|
d2a65af57b | |
|
|
56672b38f9 |
|
|
@ -129,6 +129,34 @@ class TranscriptionReportService:
|
||||||
# Executa agregação principal
|
# Executa agregação principal
|
||||||
self.mongo_results = list(collection.aggregate(pipeline))
|
self.mongo_results = list(collection.aggregate(pipeline))
|
||||||
self.unique_ids = [doc["_id"] for doc in self.mongo_results]
|
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
|
# Pipeline para contagem total
|
||||||
count_pipeline = [
|
count_pipeline = [
|
||||||
|
|
@ -173,7 +201,8 @@ class TranscriptionReportService:
|
||||||
uniqueid IN {tuple(self.unique_ids)}
|
uniqueid IN {tuple(self.unique_ids)}
|
||||||
GROUP BY
|
GROUP BY
|
||||||
uniqueid, src, dst;"""
|
uniqueid, src, dst;"""
|
||||||
rows = execute_query(self.company_id, sql)
|
rows = execute_query(self.company_id, sql)
|
||||||
|
|
||||||
|
|
||||||
if hit_report:
|
if hit_report:
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
|
@ -190,11 +219,25 @@ class TranscriptionReportService:
|
||||||
row["total_cost_token"] = float(token_input.get('usageCost',0) + token_output.get('usageCost', 0))
|
row["total_cost_token"] = float(token_input.get('usageCost',0) + token_output.get('usageCost', 0))
|
||||||
row["llm_provider"] = token_output.get('provider','unknown')
|
row["llm_provider"] = token_output.get('provider','unknown')
|
||||||
|
|
||||||
tts = rowMongo.get('usageByType', {}).get('stt',{})
|
stt = rowMongo.get('usageByType', {}).get('stt',{})
|
||||||
row["tts_model"] = tts.get('product', 'unknown')
|
|
||||||
row["tts_provider"] = tts.get('provider', 'unknown')
|
if not stt:
|
||||||
row["tts_cost"] = tts.get('usageCost', 0)
|
stt = rowMongo.get('usageByType', {}).get('input-audio',{})
|
||||||
row["tts_usage"] = tts.get('usage', 0)
|
|
||||||
|
# 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}"
|
row["total_min"] = f"{(int(row['total_billsec']) / 60):.2f}"
|
||||||
|
|
||||||
|
|
@ -266,10 +309,10 @@ class TranscriptionReportService:
|
||||||
"total_cost_token": "Preço Final LLM",
|
"total_cost_token": "Preço Final LLM",
|
||||||
"llm_provider": "Provider LLM",
|
"llm_provider": "Provider LLM",
|
||||||
|
|
||||||
"tts_model": "TTS",
|
"stt_model": "STT",
|
||||||
"tts_provider": "Provider TTS",
|
"stt_provider": "Provider STT",
|
||||||
"tts_cost": "Preço Final TTS",
|
"stt_cost": "Preço Final STT",
|
||||||
"tts_usage": "Segundos Transcritos",
|
"stt_usage": "Segundos Transcritos",
|
||||||
|
|
||||||
"client_total_cost": "Custo Cliente",
|
"client_total_cost": "Custo Cliente",
|
||||||
"client_price": "Preço Cliente por Minuto",
|
"client_price": "Preço Cliente por Minuto",
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,10 @@ interface HitTranscriptionData {
|
||||||
total_cost_token: number // Total token(input + output)
|
total_cost_token: number // Total token(input + output)
|
||||||
llm_provider: string // Provider llm
|
llm_provider: string // Provider llm
|
||||||
|
|
||||||
// tts_model: string // Modelo de trascrição de audio para texto
|
// stt_model: string // Modelo de trascrição de audio para texto
|
||||||
tts_provider: string // Provedor do tts
|
stt_provider: string // Provedor do tts
|
||||||
tts_cost: number // Custo total dos minutos do audio em texto
|
stt_cost: number // Custo total dos minutos do audio em texto
|
||||||
tts_usage: number // Tempo total de trascrição do audio em segundos
|
stt_usage: number // Tempo total de trascrição do audio em segundos
|
||||||
|
|
||||||
total_min: number // Minutos de ligação
|
total_min: number // Minutos de ligação
|
||||||
custo_hit: string // Custo HIT
|
custo_hit: string // Custo HIT
|
||||||
|
|
@ -553,16 +553,16 @@ export default function TranscriptionTable() {
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell>{(item as HitTranscriptionData).llm_provider || "-"}</TableCell>
|
<TableCell>{(item as HitTranscriptionData).llm_provider || "-"}</TableCell>
|
||||||
{/* <TableCell>{(item as HitTranscriptionData).tts_model || "-"}</TableCell> */}
|
{/* <TableCell>{(item as HitTranscriptionData).stt_model || "-"}</TableCell> */}
|
||||||
<TableCell>{(item as HitTranscriptionData).tts_provider || "-"}</TableCell>
|
<TableCell>{(item as HitTranscriptionData).stt_provider || "-"}</TableCell>
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{(item as HitTranscriptionData)?.tts_cost
|
{(item as HitTranscriptionData)?.stt_cost
|
||||||
? `$ ${Number((item as HitTranscriptionData).tts_cost).toFixed(2)}`
|
? `$ ${Number((item as HitTranscriptionData).stt_cost).toFixed(2)}`
|
||||||
: "-"}
|
: "-"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell>{(item as HitTranscriptionData).tts_usage || "-"}</TableCell>
|
<TableCell>{(item as HitTranscriptionData).stt_usage || "-"}</TableCell>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue