Skip to content

Utils

data_multimodal_conversation_log_context_emotion_detection(task_data, result, logs=None)

Parameters:

Name Type Description Default
task_data TaskData

the task data

required
result dict

the result of the context emotion detection

required
logs dict

the logs of the context emotion detection

None

Returns:

Source code in API/orchestrator/chain/utils.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def data_multimodal_conversation_log_context_emotion_detection(
    task_data: TaskData, result: dict, logs: dict = None
):
    """

    Args:
        task_data (TaskData): the task data
        result (dict): the result of the context emotion detection
        logs (dict): the logs of the context emotion detection

    Returns:

    """
    data_text_id = task_data.parameters.get("data_text_id", None)
    if data_text_id is not None:
        data_text = DataText.objects.filter(id=data_text_id).first()
        if data_text is not None and hasattr(data_text, "multi_modal_conversation"):
            emotion = ContextEmotionDetection(
                multi_modal_conversation=data_text.multi_modal_conversation,
                result=result,
                logs=logs,
            )
            emotion.save()
            logger.info(emotion)

data_multimodal_conversation_log_context_rag(task_data, result, logs=None)

Parameters:

Name Type Description Default
task_data TaskData

the task data

required
result dict

the result of the context rag

required
logs dict

the logs of the context rag

None

Returns:

Source code in API/orchestrator/chain/utils.py
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def data_multimodal_conversation_log_context_rag(
    task_data: TaskData, result: dict, logs: dict = None
):
    """

    Args:
        task_data (TaskData): the task data
        result (dict): the result of the context rag
        logs (dict): the logs of the context rag

    Returns:

    """
    data_text_id = task_data.parameters.get("data_text_id", None)
    if data_text_id is not None:
        data_text = DataText.objects.filter(id=data_text_id).first()
        if data_text is not None and hasattr(data_text, "multi_modal_conversation"):
            rag = ContextRAG(
                multi_modal_conversation=data_text.multi_modal_conversation,
                result=result,
                logs=logs,
            )
            rag.save()
            logger.info(rag)

data_multimodal_conversation_log_res_speech(task_data, speech_file_path)

Parameters:

Name Type Description Default
task_data TaskData

the task data

required
speech_file_path str

the speech file path

required

Returns:

Source code in API/orchestrator/chain/utils.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def data_multimodal_conversation_log_res_speech(
    task_data: TaskData, speech_file_path: str
):
    """

    Args:
        task_data (TaskData): the task data
        speech_file_path (str): the speech file path

    Returns:

    """
    res_speech = ResSpeech.objects.create(text2speech_file=speech_file_path)
    data_text_id = task_data.parameters.get("data_text_id", None)
    if data_text_id is not None:
        data_text = DataText.objects.filter(id=data_text_id).first()
        if data_text is not None and hasattr(data_text, "multi_modal_conversation"):
            data_text.multi_modal_conversation.res_speech = res_speech
            data_text.multi_modal_conversation.save()

data_multimodal_conversation_log_res_text(task_data, text)

Log the ResText to the DataMultiModalConversation

Parameters:

Name Type Description Default
task_data TaskData

The task data

required
text str

The text to log

required
Source code in API/orchestrator/chain/utils.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def data_multimodal_conversation_log_res_text(task_data: TaskData, text: str):
    """
    Log the ResText to the DataMultiModalConversation

    Args:
        task_data (TaskData): The task data
        text (str): The text to log
    """
    res_text = ResText.objects.create(text=text)
    data_text_id = task_data.parameters.get("data_text_id", None)
    if data_text_id is not None:
        data_text = DataText.objects.filter(id=data_text_id).first()
        if data_text is not None and hasattr(data_text, "multi_modal_conversation"):
            data_text.multi_modal_conversation.res_text = res_text
            data_text.multi_modal_conversation.save()