@@ -10,32 +10,30 @@ class ModuleLLM:
1010 Note : Currently supports OpenAI, Anthropic, xAI, Huggingface, Ollama, OpenRouter, NovitaAI
1111 """
1212
13- def __init__ (self , api_key : str , model : str ):
13+ def __init__ (self , api_key : str , model : str , system_prompt : str | None = None ):
1414 """
1515 Initialize the LLM module
1616
1717 Args:
1818 api_key: The API key for the LLM provider
19- model: The model to use for the LLM
19+ model: The model to use for the LLM in the format of {provider}/{model}
20+ system_prompt: The system prompt to use for the LLM
2021 """
2122 self .api_key = api_key
22- provider = model .split ("/" )[0 ].upper ()
23-
23+ self .model = model
24+ self .system_prompt = system_prompt
25+ provider = self .model .split ("/" )[0 ].upper ()
2426 os .environ [f"{ provider } _API_KEY" ] = self .api_key
2527
26- def generate (self , prompt : str , system_prompt : str | None = None ) -> str :
27- """
28- Generate a response from the LLM
29- """
30- if system_prompt :
28+ def generate (self , prompt : str ) -> str :
29+ if self .system_prompt :
3130 messages = [
32- {"role" : "system" , "content" : system_prompt },
31+ {"role" : "system" , "content" : self . system_prompt },
3332 {"role" : "user" , "content" : prompt },
3433 ]
3534 else :
3635 messages = [{"role" : "user" , "content" : prompt }]
37-
38- response = completion (model = "openai/gpt-4o" , messages = messages )
36+ response = completion (model = self .model , messages = messages )
3937 return response
4038
4139
0 commit comments