Skip to content

Commit 25e44e2

Browse files
committed
doc : add comments to methods in module_llm.py
1 parent aece434 commit 25e44e2

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

mesa_llm/module_llm.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,37 @@
55

66
class ModuleLLM:
77
"""
8-
Currently supports OpenAI, Anthropic, xIA, Huggingface, Ollama, OpenRouter, NovitaAI
8+
A module that provides a simple interface for using LLMs
9+
10+
Note : Currently supports OpenAI, Anthropic, xAI, Huggingface, Ollama, OpenRouter, NovitaAI
911
"""
1012

1113
def __init__(self, api_key: str, model: str):
14+
"""
15+
Initialize the LLM module
16+
17+
Args:
18+
api_key: The API key for the LLM provider
19+
model: The model to use for the LLM
20+
"""
1221
self.api_key = api_key
1322
provider = model.split("/")[0].upper()
1423

1524
os.environ[f"{provider}_API_KEY"] = self.api_key
1625

17-
def generate(self, prompt: str, system_prompt: str = None) -> str:
26+
def generate(self, prompt: str, system_prompt: str | None = None) -> str:
27+
"""
28+
Generate a response from the LLM
29+
"""
1830
if system_prompt:
1931
messages = [
2032
{"role": "system", "content": system_prompt},
21-
{"role": "user", "content": prompt}
33+
{"role": "user", "content": prompt},
2234
]
2335
else:
24-
messages = [
25-
{"role": "user", "content": prompt}
26-
]
27-
28-
response = completion(
29-
model="openai/gpt-4o",
30-
messages=messages
31-
)
36+
messages = [{"role": "user", "content": prompt}]
37+
38+
response = completion(model="openai/gpt-4o", messages=messages)
3239
return response
3340

3441

0 commit comments

Comments
 (0)