File size: 1,100 Bytes
41971b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pixeltable as pxt


# Pixeltable rejects @pxt.udf defined in the __main__ script or nested inside
# functions; HF Spaces runs `python app.py`, so UDFs live in this module.
@pxt.udf
def generate_insights(transcription: str) -> list[dict]:
    system_msg = 'You are an AI assistant that analyzes call transcriptions. Analyze the following call transcription and provide insights on: 1. Main topics discussed 2. Action items 3. Sentiment analysis 4. Key questions asked'
    user_msg = f'Transcription: "{transcription}"'
    return [
        {'role': 'system', 'content': system_msg},
        {'role': 'user', 'content': user_msg},
    ]


@pxt.udf
def create_chatbot_prompt(context: str, question: str) -> list[dict]:
    system_message = "You are an AI assistant that answers questions about a call based on the provided context. If the answer cannot be found in the context, say that you don't know."
    user_message = f'Context:\n{context}\n\nQuestion: {question}'
    return [
        {'role': 'system', 'content': system_message},
        {'role': 'user', 'content': user_message},
    ]