Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions codeflash/api/aiservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
import platform
from functools import lru_cache
from typing import TYPE_CHECKING, Any

import requests
Expand All @@ -26,6 +27,7 @@ def __init__(self) -> None:
self.base_url = self.get_aiservice_base_url()
self.headers = {"Authorization": f"Bearer {get_codeflash_api_key()}", "Connection": "close"}

@lru_cache(maxsize=1)
def get_aiservice_base_url(self) -> str:
if os.environ.get("CODEFLASH_AIS_SERVER", default="prod").lower() == "local":
logger.info("Using local AI Service at http://localhost:8000")
Expand Down Expand Up @@ -197,10 +199,9 @@ def generate_regression_tests(
- Dict[str, str] | None: The generated regression tests and instrumented tests, or None if an error occurred.

"""
assert test_framework in [
"pytest",
"unittest",
], f"Invalid test framework, got {test_framework} but expected 'pytest' or 'unittest'"
assert test_framework in ["pytest", "unittest"], (
f"Invalid test framework, got {test_framework} but expected 'pytest' or 'unittest'"
)
payload = {
"source_code_being_tested": source_code_being_tested,
"function_to_optimize": function_to_optimize,
Expand Down
Loading