Spaces:
Sleeping
Sleeping
| import os | |
| from langchain_groq import ChatGroq | |
| from dotenv import load_dotenv | |
| # Load environment variables from .env file | |
| load_dotenv() | |
| def get_llm(): | |
| """ | |
| Returns the language model instance (LLM) using ChatGroq API. | |
| The LLM used is Llama 3.3 with a versatile 70 billion parameters model. | |
| Returns: | |
| llm (ChatGroq): An instance of the ChatGroq LLM. | |
| """ | |
| api_key = os.getenv("CHATGROQ_API_KEY") | |
| if not api_key: | |
| raise ValueError("CHATGROQ_API_KEY is not set in the .env file.") | |
| llm = ChatGroq( | |
| model="llama-3.3-70b-versatile", | |
| temperature=0, | |
| max_tokens=1024, | |
| api_key=api_key | |
| ) | |
| return llm | |