File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 304304 },
305305 "togetherai" : {"Meta-Llama-3.1-70B-Instruct-Turbo" : 128000 },
306306 "xai" : {
307-  "grok-1" : 8192 
307+  "grok-1" : 8192 ,
308+  "grok-3" : 128000 ,
309+  "grok-3-mini" : 128000 ,
308310 },
309311}
Original file line number Diff line number Diff line change 11""" 
22xAI Grok Module 
33""" 
4- from  langchain_groq  import  ChatGroq   as   LangchainChatGroq 
4+ from  langchain_openai  import  ChatOpenAI 
55
6- class  XAI (LangchainChatGroq ):
6+ 
7+ class  XAI (ChatOpenAI ):
78 """ 
8-  Wrapper  for the ChatGroq  class from langchain_groq, for use with xAI models.  
9-  Handles API key mapping from generic 'api_key' to 'groq_api_key' and  
10-  maps 'model' to 'model_name' . 
9+  A wrapper  for the ChatOpenAI  class (xAI uses an OpenAI-compatible API) that  
10+  provides default configuration and could be extended with additional methods  
11+  if needed . 
1112
1213 Args: 
1314 llm_config (dict): Configuration parameters for the language model. 
1415 """ 
1516
1617 def  __init__ (self , ** llm_config ):
17-  if  "api_key"  in  llm_config  and  "groq_api_key"  not  in   llm_config :
18-  llm_config ["groq_api_key" ] =  llm_config .pop ("api_key" )
19-  
20-  if  "model"  in  llm_config  and  "model_name"  not  in   llm_config :
21-  llm_config ["model_name" ] =  llm_config .pop ("model" )
18+  if  "api_key"  in  llm_config :
19+  llm_config ["openai_api_key" ] =  llm_config .pop ("api_key" )
20+  llm_config ["openai_api_base" ] =  "https://api.x.ai/v1" 
2221
2322 super ().__init__ (** llm_config ) 
                                 You can’t perform that action at this time. 
               
                  
0 commit comments