fix(ai-orchestrator): restore cyrillic text formatting
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import urllib.request
|
||||
import json
|
||||
import urllib.error
|
||||
|
||||
def fetch_data():
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
'http://92.38.48.166:8080/proxy/auth/auth/login',
|
||||
data=json.dumps({"username": "admin", "password": "admin123"}).encode('utf-8'),
|
||||
headers={'Content-Type': 'application/json'}
|
||||
)
|
||||
login_resp = urllib.request.urlopen(req)
|
||||
token = json.loads(login_resp.read().decode()).get('access_token')
|
||||
|
||||
headers = {'Authorization': f'Bearer {token}'}
|
||||
calls_req = urllib.request.Request(
|
||||
'http://92.38.48.166:8080/proxy/asterisk-bridge/asterisk/events?limit=25',
|
||||
headers=headers
|
||||
)
|
||||
calls_resp = urllib.request.urlopen(calls_req)
|
||||
events = json.loads(calls_resp.read().decode())
|
||||
|
||||
if not events:
|
||||
print("No events found.")
|
||||
return
|
||||
|
||||
for call_id in ["1775500989.2", "1775499861.0"]:
|
||||
ai_req = urllib.request.Request(
|
||||
f'http://92.38.48.166:8080/proxy/asterisk-bridge/asterisk/live-calls/{call_id}/ai-summary',
|
||||
headers=headers
|
||||
)
|
||||
try:
|
||||
ai_resp = urllib.request.urlopen(ai_req)
|
||||
ai_data = json.loads(ai_resp.read().decode())
|
||||
print(f"\n----- AI SUMMARY FOR {call_id} -----")
|
||||
with open(f"e:\\Zhan\\summary_{call_id}.json", "w", encoding="utf-8") as f:
|
||||
json.dump(ai_data, f, ensure_ascii=False, indent=2)
|
||||
print(f"Saved to e:\\Zhan\\summary_{call_id}.json")
|
||||
except urllib.error.HTTPError as e:
|
||||
print(f"Call {call_id} error: {e}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
fetch_data()
|
||||
@@ -706,7 +706,7 @@ def voice_ai_summary_for_call(call_id: str) -> VoiceAISummaryOut | None:
|
||||
session,
|
||||
voice_session_id=voice_session.session_id,
|
||||
speaker="caller",
|
||||
) or "Последняя реплика клиента недоступна."
|
||||
) or "Последняя реплика клиента недоступна."
|
||||
assistant_reply_text = _latest_segment_text(
|
||||
session,
|
||||
voice_session_id=voice_session.session_id,
|
||||
@@ -756,22 +756,22 @@ def voice_ai_summary_for_call(call_id: str) -> VoiceAISummaryOut | None:
|
||||
)
|
||||
unresolved_name = customer_name_status in {"name_not_obtained", "name_followup_required"}
|
||||
recommended_next_step = (
|
||||
"Проверьте контекст звонка и продолжайте разговор вручную."
|
||||
"Проверьте контекст звонка и продолжайте разговор вручную."
|
||||
if is_handoff
|
||||
else "Продолжайте разговор, учитывая уже собранный AI контекст."
|
||||
else "Продолжайте разговор, учитывая уже собранный AI контекст."
|
||||
)
|
||||
if is_handoff and unresolved_name:
|
||||
recommended_next_step = (
|
||||
"Проверьте контекст звонка, продолжайте разговор вручную и уточните имя клиента."
|
||||
"Проверьте контекст звонка, продолжайте разговор вручную и уточните имя клиента."
|
||||
)
|
||||
return VoiceAISummaryOut(
|
||||
call_id=call_id,
|
||||
session_id=ai_session.session_id if ai_session else None,
|
||||
voice_session_id=voice_session.session_id,
|
||||
status_label=(
|
||||
"AI передал звонок оператору"
|
||||
"AI передал звонок оператору"
|
||||
if is_handoff
|
||||
else "AI ответил клиенту"
|
||||
else "AI ответил клиенту"
|
||||
),
|
||||
status_tone="handoff" if is_handoff else "answered",
|
||||
customer_name_status=customer_name_status,
|
||||
@@ -779,7 +779,7 @@ def voice_ai_summary_for_call(call_id: str) -> VoiceAISummaryOut | None:
|
||||
customer_name_source=customer_name_source,
|
||||
voice_start_language=voice_start_language,
|
||||
customer_request_text=customer_request_text,
|
||||
ai_outcome_text=ai_outcome_text or "AI обработал обращение без дополнительной сводки.",
|
||||
ai_outcome_text=ai_outcome_text or "AI обработал обращение без дополнительной сводки.",
|
||||
handoff_reason=handoff_reason,
|
||||
recommended_next_step=recommended_next_step,
|
||||
generated_at=(
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
null
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"call_id": "1775500989.2",
|
||||
"session_id": "ais_a72486f7cc",
|
||||
"voice_session_id": "avs_896c6077bf",
|
||||
"status_label": "AI ответил клиенту",
|
||||
"status_tone": "answered",
|
||||
"customer_name_status": "name_not_obtained",
|
||||
"customer_name_value": null,
|
||||
"customer_name_source": "none",
|
||||
"voice_start_language": "ru",
|
||||
"customer_request_text": "Последняя реплика клиента недоступна.",
|
||||
"ai_outcome_text": "Здравствуйте. Подскажите, пожалуйста, чем помочь.",
|
||||
"handoff_reason": "",
|
||||
"recommended_next_step": "Продолжайте разговор, учитывая уже собранный AI контекст.",
|
||||
"generated_at": "2026-04-06T18:43:55+00:00",
|
||||
"transcript_segments": [
|
||||
{
|
||||
"speaker": "assistant",
|
||||
"text": "Здравствуйте. Подскажите, пожалуйста, чем помочь.",
|
||||
"sequence_no": 1,
|
||||
"source_type": "tts",
|
||||
"created_at": "2026-04-06T18:43:22+00:00",
|
||||
"interrupted": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -280,7 +280,7 @@ def test_returning_human_owned_thread_to_ai_reopens_ai_flow(monkeypatch):
|
||||
"/integrations/telegram/webhook",
|
||||
json={
|
||||
"chat_id": "chat_return_ai",
|
||||
"text": "Первое сообщение",
|
||||
"text": "Первое сообщение",
|
||||
"payload": {"telegram_user_id": "tg_return_ai", "username": "return_ai_user"},
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user