Skip to content

Commit a27ba0c

Browse files
committed
Refactor LLM class to streamline API key and base URL handling
1 parent c300605 commit a27ba0c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

policy_gen/llm/llm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
class LLM:
88
def __init__(self, prompt_list: list[Prompt]):
9-
self.model = "Deepseek-V3.2"
10-
self._api_key = (
11-
os.getenv("DEEPSEEK_API_KEY") if load_dotenv(dotenv_path=".env") else None
12-
)
139
self.prompt_list = prompt_list
1410
self.history: list[dict[str, str | dict]] = []
1511

1612
def generate(self) -> list[dict[str, str | dict]]:
1713
client = OpenAI(
18-
api_key=self._api_key,
19-
base_url="https://api.deepseek.com",
14+
api_key=os.getenv("DEEPSEEK_API_KEY")
15+
if load_dotenv(dotenv_path=".env")
16+
else None,
17+
base_url=os.getenv("DEEPSEEK_API_BASE_URL")
18+
if load_dotenv(dotenv_path=".env")
19+
else None,
2020
)
2121
for prompt in self.prompt_list:
2222
response = client.chat.completions.create(

0 commit comments

Comments
 (0)