Skip to content

Commit 890875f

Browse files
authored
Change default any-llm-platform URL (#633)
## Description Change default any-llm-platform URL ## PR Type 💅 Refactor Signed-off-by: Dimitris Poulopoulos <[email protected]>
1 parent be394d8 commit 890875f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/any_llm/providers/platform/utils.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
from any_llm.types.completion import ChatCompletion
2121

2222

23-
ANY_LLM_PLATFORM_URL = os.getenv("ANY_LLM_PLATFORM_URL", "http://localhost:8000/api/v1")
23+
API_V1_STR = "/api/v1"
24+
ANY_LLM_PLATFORM_URL = os.getenv("ANY_LLM_PLATFORM_URL", "https://platform-api.any-llm.ai")
25+
ANY_LLM_PLATFORM_API_URL = f"{ANY_LLM_PLATFORM_URL}{API_V1_STR}"
2426

2527

2628
def _parse_any_llm_key(any_api_key: str) -> tuple[str, str, str]:
@@ -178,15 +180,15 @@ def get_provider_key(any_llm_key: str, provider: type[AnyLLM]) -> str:
178180
public_key = _extract_public_key(private_key)
179181

180182
# Create and solve a new challenge to prove ownership of the private key without sharing it.
181-
challenge_data = _create_challenge(public_key, ANY_LLM_PLATFORM_URL)
183+
challenge_data = _create_challenge(public_key, ANY_LLM_PLATFORM_API_URL)
182184
solved_challenge = _solve_challenge(challenge_data["encrypted_challenge"], private_key)
183185

184186
# Fetch and decrypt the provider key
185187
provider_key_data = _fetch_provider_key(
186188
provider=provider.PROVIDER_NAME,
187189
public_key=public_key,
188190
solved_challenge=solved_challenge,
189-
any_api_url=ANY_LLM_PLATFORM_URL,
191+
any_api_url=ANY_LLM_PLATFORM_API_URL,
190192
)
191193
return _decrypt_provider_key(provider_key_data["encrypted_key"], private_key)
192194

@@ -212,17 +214,20 @@ async def post_completion_usage_event(
212214
public_key = _extract_public_key(private_key)
213215

214216
# Create and solve a new challenge to prove ownership of the private key without sharing it.
215-
challenge_data = _create_challenge(public_key, ANY_LLM_PLATFORM_URL)
217+
challenge_data = _create_challenge(public_key, ANY_LLM_PLATFORM_API_URL)
216218
solved_challenge = _solve_challenge(challenge_data["encrypted_challenge"], private_key)
217219

218220
# Fetch the provider key info
219221
provider_key_data = _fetch_provider_key(
220-
provider=provider, public_key=public_key, solved_challenge=solved_challenge, any_api_url=ANY_LLM_PLATFORM_URL
222+
provider=provider,
223+
public_key=public_key,
224+
solved_challenge=solved_challenge,
225+
any_api_url=ANY_LLM_PLATFORM_API_URL,
221226
)
222227
provider_key_id = provider_key_data.get("id")
223228

224229
# Create and solve a new challenge to prove ownership of the project
225-
challenge_data = _create_challenge(public_key, ANY_LLM_PLATFORM_URL)
230+
challenge_data = _create_challenge(public_key, ANY_LLM_PLATFORM_API_URL)
226231
solved_challenge = _solve_challenge(challenge_data["encrypted_challenge"], private_key)
227232

228233
# Send usage event data
@@ -244,7 +249,7 @@ async def post_completion_usage_event(
244249
}
245250

246251
response = await client.post(
247-
f"{ANY_LLM_PLATFORM_URL}/usage-events/",
252+
f"{ANY_LLM_PLATFORM_API_URL}/usage-events/",
248253
json=payload,
249254
headers={"encryption-key": public_key, "AnyLLM-Challenge-Response": str(solved_challenge)},
250255
)

0 commit comments

Comments
 (0)