midrees2806 commited on
Commit
d772609
·
verified ·
1 Parent(s): e3fae22

Update pdf_bot.py

Browse files
Files changed (1) hide show
  1. pdf_bot.py +9 -3
pdf_bot.py CHANGED
@@ -15,14 +15,20 @@ groq_api_key = os.getenv("GROQ_API_KEY")
15
 
16
  # ✅ Custom wrapper
17
  class ChatGroq(BaseChatModel):
 
 
 
 
18
  def __init__(self, model="llama3-8b-8192", temperature=0.3, api_key=None):
19
- self.client = Groq(api_key=api_key)
20
  self.model = model
21
  self.temperature = temperature
 
 
22
 
23
  def _generate(self, messages, stop=None):
24
  prompt = [{"role": "user", "content": self._get_message_text(messages)}]
25
- response = self.client.chat.completions.create(
26
  model=self.model,
27
  messages=prompt,
28
  temperature=self.temperature,
@@ -37,7 +43,7 @@ class ChatGroq(BaseChatModel):
37
  return messages.content
38
 
39
  @property
40
- def _llm_type(self):
41
  return "chat-groq"
42
 
43
  # ✅ Function to return a QA chain
 
15
 
16
  # ✅ Custom wrapper
17
  class ChatGroq(BaseChatModel):
18
+ model: str = "llama3-8b-8192"
19
+ temperature: float = 0.3
20
+ groq_api_key: str = None
21
+
22
  def __init__(self, model="llama3-8b-8192", temperature=0.3, api_key=None):
23
+ super().__init__()
24
  self.model = model
25
  self.temperature = temperature
26
+ self.groq_api_key = api_key
27
+ self._client = Groq(api_key=api_key) # ✅ use _client instead of client
28
 
29
  def _generate(self, messages, stop=None):
30
  prompt = [{"role": "user", "content": self._get_message_text(messages)}]
31
+ response = self._client.chat.completions.create(
32
  model=self.model,
33
  messages=prompt,
34
  temperature=self.temperature,
 
43
  return messages.content
44
 
45
  @property
46
+ def _llm_type(self) -> str:
47
  return "chat-groq"
48
 
49
  # ✅ Function to return a QA chain