Spaces:
Sleeping
Sleeping
Commit
·
e22ec09
1
Parent(s):
8359520
update: user can provide call type
Browse files
app.py
CHANGED
@@ -410,7 +410,25 @@ def chat(
|
|
410 |
"additionalProperties": False,
|
411 |
},
|
412 |
},
|
413 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
]
|
415 |
|
416 |
try:
|
@@ -424,7 +442,7 @@ def chat(
|
|
424 |
Transcript:\n{transcript_processor.get_transcript()}
|
425 |
If a user asks timestamps for a specific topic, find the start time and end time of that specific topic and return answer in the format:
|
426 |
If the user provides a link to the agenda, use the correct_speaker_name_with_url function to correct the speaker names based on the agenda.
|
427 |
-
|
428 |
Answer format:
|
429 |
Topic: Heading [Timestamp: start_time - end_time]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{start_time_in_sec}}&et={{end_time_in_sec}}"').
|
430 |
|
@@ -454,34 +472,46 @@ In the URL, make sure that after RSID there is ? and then rest of the fields are
|
|
454 |
messages.append(response)
|
455 |
|
456 |
if response.tool_calls:
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
|
|
472 |
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
|
480 |
-
|
481 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
else:
|
483 |
-
return "No
|
484 |
-
|
485 |
return response.content
|
486 |
|
487 |
except Exception as e:
|
|
|
410 |
"additionalProperties": False,
|
411 |
},
|
412 |
},
|
413 |
+
},
|
414 |
+
{
|
415 |
+
"type": "function",
|
416 |
+
"function": {
|
417 |
+
"name": "correct_call_type",
|
418 |
+
"description": "If the user tells you the correct call type, you have to apologize and call this function with correct call type.",
|
419 |
+
"parameters": {
|
420 |
+
"type": "object",
|
421 |
+
"properties": {
|
422 |
+
"call_type": {
|
423 |
+
"type": "string",
|
424 |
+
"description": "The correct call type. If street interview, call type is 'si'.",
|
425 |
+
},
|
426 |
+
},
|
427 |
+
"required": ["call_type"],
|
428 |
+
"additionalProperties": False,
|
429 |
+
},
|
430 |
+
},
|
431 |
+
},
|
432 |
]
|
433 |
|
434 |
try:
|
|
|
442 |
Transcript:\n{transcript_processor.get_transcript()}
|
443 |
If a user asks timestamps for a specific topic, find the start time and end time of that specific topic and return answer in the format:
|
444 |
If the user provides a link to the agenda, use the correct_speaker_name_with_url function to correct the speaker names based on the agenda.
|
445 |
+
If the user provides the correct call type, use the correct_call_type function to correct the call type. Call Type for street interviews is 'si'.
|
446 |
Answer format:
|
447 |
Topic: Heading [Timestamp: start_time - end_time]({link_start}://{{origin}}/collab/{{cid}}/{{rsid}}?st={{start_time_in_sec}}&et={{end_time_in_sec}}"').
|
448 |
|
|
|
472 |
messages.append(response)
|
473 |
|
474 |
if response.tool_calls:
|
475 |
+
if response.tool_calls[0].function.name == "correct_speaker_name_with_url":
|
476 |
+
args = eval(response.tool_calls[0].function.arguments)
|
477 |
+
url = args.get("url", None)
|
478 |
+
if url:
|
479 |
+
transcript_processor.correct_speaker_mapping_with_agenda(url)
|
480 |
+
corrected_speaker_mapping = transcript_processor.speaker_mapping
|
481 |
+
function_call_result_message = {
|
482 |
+
"role": "tool",
|
483 |
+
"content": json.dumps(
|
484 |
+
{
|
485 |
+
"speaker_mapping": f"Corrected Speaker Mapping is: {corrected_speaker_mapping}\n, All speakers should be addressed via this mapping. The next message should be comparing old speaker names (do not use spk_0, spk_1, use the old names) and corrected speaker names.",
|
486 |
+
}
|
487 |
+
),
|
488 |
+
"name": response.tool_calls[0].function.name,
|
489 |
+
"tool_call_id": response.tool_calls[0].id,
|
490 |
+
}
|
491 |
|
492 |
+
# messages.append(response.choices[0]["message"])
|
493 |
+
messages.append(function_call_result_message)
|
494 |
+
completion_payload = {"model": "gpt-4o-mini", "messages": messages}
|
495 |
+
# print("messages", messages[3])
|
496 |
+
response = client.chat.completions.create(**completion_payload)
|
497 |
+
# print("no error here")
|
498 |
|
499 |
+
return response.choices[0].message.content
|
500 |
|
501 |
+
else:
|
502 |
+
return "No URL provided for correcting speaker names."
|
503 |
+
elif response.tool_calls[0].function.name == "correct_call_type":
|
504 |
+
args = eval(response.tool_calls[0].function.arguments)
|
505 |
+
call_type = args.get("call_type", None)
|
506 |
+
if call_type:
|
507 |
+
analysis = get_initial_analysis(
|
508 |
+
transcript_processor, call_type, rsid, origin, call_type
|
509 |
+
)
|
510 |
+
return analysis
|
511 |
+
else:
|
512 |
+
return "No call type provided for correction."
|
513 |
else:
|
514 |
+
return "No tool for this request"
|
|
|
515 |
return response.content
|
516 |
|
517 |
except Exception as e:
|