neerajkalyank commited on
Commit
5f2ce8c
·
verified ·
1 Parent(s): 3489290

Update groq_llm.py

Browse files
Files changed (1) hide show
  1. groq_llm.py +14 -8
groq_llm.py CHANGED
@@ -1,10 +1,16 @@
1
- from groq import Groq
 
2
 
3
- def get_llm(api_key, streaming=True):
4
- client = Groq(api_key=api_key)
5
-
6
- return client.chat.completions.create(
7
- model="llama-3.1-8b-instant", # 👈 THIS LINE
8
- messages=[...],
9
- stream=streaming
 
 
 
 
 
10
  )
 
1
+ import os
2
+ from langchain_groq import ChatGroq
3
 
4
+ def get_llm(callbacks=None):
5
+ """
6
+ Returns a Groq LLM instance with streaming enabled.
7
+ callbacks: list of LangChain callback handlers (optional)
8
+ """
9
+ return ChatGroq(
10
+ groq_api_key=os.getenv("GROQ_API_KEY"),
11
+ model_name="llama-3.1-8b-instant", # ✅ your chosen model
12
+ temperature=0.1,
13
+ max_tokens=1024,
14
+ streaming=True,
15
+ callbacks=callbacks
16
  )