asdfasdfqrqwer's picture
Update to pixeltable 0.7.8 / gradio 5.49: UDFs to udfs.py, model_kwargs, pinned deps, python 3.11
41971b5
Raw History Blame Contribute Delete
1.1 kB
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},
]