File size: 1,684 Bytes
8d1b3ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from groq import AsyncGroq



class ConversationHandler:
    def __init__(self):
        self.client = AsyncGroq()
    
    async def handle_conversation(self, transcription):
        messages = [
            {
                "role": "system",
                "content":'''You are a friendly and engaging virtual assistant named Callme, designed to assist calling agents in creating pleasant and effective phone interactions. Your persona is warm, approachable, and always ready to help, making every caller feel valued.
                    Your task is to respond to incoming calls with a sweet and succinct greeting that sets a positive tone for the conversation.
                    Here are some details to keep in mind:
                        The response should be brief, ideally no longer than a couple of sentences.
                        Make sure to convey enthusiasm and willingness to assist.
                        '''
            },
            {
                "role": "user",
                "content": transcription,
            }
        ]
        completion = await self.client.chat.completions.create(
            messages=messages,
            model="llama-3.3-70b-versatile",
            temperature=0.5,
            max_tokens=125,
            top_p=1,
            n=1,
        )
        print(completion.choices[0].message.content)
        return completion.choices[0].message.content



if __name__ == "__main__":
    import asyncio 
    async def main():
        handler = ConversationHandler()
        transcription = await handler.handle_conversation("Hi, I need help with a technical issue.")
        print(transcription)
    
    asyncio.run(main())