File size: 1,066 Bytes
d0c513b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from groq import Groq

client = Groq(
    api_key="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",
)

def get_physiotherapy_assistant_response(prompt : str):
    try:
        system_message = """You are a helpful physiotherapy assistant, trained to provide useful information about exercises, recovery, and treatments. 
        You can help users with various physical therapy-related queries."""

        if not prompt or len(prompt.strip()) < 5:
            return "Please provide more details about your physiotherapy question. I need more context to assist you effectively."

        chat_completion = client.chat.completions.create(
            messages=[
                {"role": "system", "content": system_message},
                {"role": "user", "content": prompt},
            ],
            model="llama-3.3-70b-versatile",
        )
        assistant_response = chat_completion.choices[0].message.content
        return assistant_response
    except Exception as e:
        return f"An error occurred while processing your request: {str(e)}"