File size: 1,035 Bytes
975c388
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
"""

Configuration and API Client Initialization

Handles environment variables and API client setup

"""

import os
from dotenv import load_dotenv
from langchain_groq import ChatGroq
from tavily import TavilyClient

# Load environment variables
load_dotenv()


def initialize_clients():
    """Initialize Groq LLM and Tavily API clients"""
    groq_api_key = os.getenv("GROQ_API_KEY")
    tavily_api_key = os.getenv("TAVILY_API_KEY")
    
    if not groq_api_key or not tavily_api_key:
        return None, None, "Missing API keys"
    
    try:
        llm = ChatGroq(
            model="openai/gpt-oss-120b",
            groq_api_key=groq_api_key,
            temperature=0.3
        )
        
        tavily_client = TavilyClient(api_key=tavily_api_key)
        
        return llm, tavily_client, None
    except Exception as e:
        return None, None, str(e)


def get_api_keys():
    """Get API keys from environment"""
    return os.getenv("GROQ_API_KEY"), os.getenv("TAVILY_API_KEY")