Spaces:
Sleeping
Sleeping
Update llm_initialization.py
Browse files- llm_initialization.py +12 -3
llm_initialization.py
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
|
|
| 1 |
from langchain_groq import ChatGroq
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def get_llm():
|
| 4 |
"""
|
| 5 |
Returns the language model instance (LLM) using ChatGroq API.
|
| 6 |
-
The LLM used is Llama 3.
|
| 7 |
|
| 8 |
Returns:
|
| 9 |
llm (ChatGroq): An instance of the ChatGroq LLM.
|
| 10 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
llm = ChatGroq(
|
| 12 |
model="llama-3.3-70b-versatile",
|
| 13 |
temperature=0,
|
| 14 |
max_tokens=1024,
|
| 15 |
-
api_key=
|
| 16 |
)
|
| 17 |
-
return llm
|
|
|
|
| 1 |
+
import os
|
| 2 |
from langchain_groq import ChatGroq
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
# Load environment variables from .env file
|
| 6 |
+
load_dotenv()
|
| 7 |
|
| 8 |
def get_llm():
|
| 9 |
"""
|
| 10 |
Returns the language model instance (LLM) using ChatGroq API.
|
| 11 |
+
The LLM used is Llama 3.3 with a versatile 70 billion parameters model.
|
| 12 |
|
| 13 |
Returns:
|
| 14 |
llm (ChatGroq): An instance of the ChatGroq LLM.
|
| 15 |
"""
|
| 16 |
+
api_key = os.getenv("CHATGROQ_API_KEY")
|
| 17 |
+
if not api_key:
|
| 18 |
+
raise ValueError("CHATGROQ_API_KEY is not set in the .env file.")
|
| 19 |
+
|
| 20 |
llm = ChatGroq(
|
| 21 |
model="llama-3.3-70b-versatile",
|
| 22 |
temperature=0,
|
| 23 |
max_tokens=1024,
|
| 24 |
+
api_key=api_key
|
| 25 |
)
|
| 26 |
+
return llm
|