File size: 997 Bytes
9322f35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from groq import Groq
import os
from text import mytext
from dotenv import load_dotenv
load_dotenv()

class Response:
    def __init__(self):
        self.client = Groq(api_key = os.getenv("GROQ_API"))
    
    def chatbot(self,query:str) -> str:
        try:
            res = self.client.chat.completions.create(
            messages=[
                {"role":"system",
                "content":f"You are a Question answer chatbot. You have to understand the given content based on that provide answer. If don't know tell unable to get details. only give answers do not provide addition text.",
                    "role": "user",
                    "content": f"Content : {mytext}\n\n Question : what is your name",
                }
            ],
            model="llama-3.3-70b-versatile",
        )
            return res.choices[0].message.content
        except Exception as e:
            print(e)




if __name__ == "__main__":
    res = Response().chatbot(query="hi")
    print(res)