Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
update initpy
Browse files Browse the repository at this point in the history
  • Loading branch information
patcher9 committed Mar 16, 2024
1 parent 8ccb598 commit 0915604
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/dokumetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,19 @@ def init(llm, doku_url, api_key, environment="default", application_name="defaul

# pylint: disable=no-else-return, line-too-long
if hasattr(llm, 'moderations') and callable(llm.chat.completions.create) and ('.openai.azure.com/' not in str(llm.base_url)):
print("OpenAI")
if isinstance(llm, OpenAI):
init_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
elif isinstance(llm, AsyncOpenAI):
init_async_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
return
if hasattr(llm, 'moderations') and callable(llm.chat.completions.create) and ('.openai.azure.com/' in str(llm.base_url)):

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
.openai.azure.com/
may be at an arbitrary position in the sanitized URL.
if isinstance(llm, AzureOpenAI):
init_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
init_azure_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
elif isinstance(llm, AsyncAzureOpenAI):
init_async_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
return
elif hasattr(llm, 'generate') and callable(llm.generate):
init_cohere(llm, doku_url, api_key, environment, application_name, skip_resp)
init_async_azure_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
return
elif isinstance(llm, MistralClient):
if isinstance(llm, MistralClient):
init_mistral(llm, doku_url, api_key, environment, application_name, skip_resp)
return
elif isinstance(llm, MistralAsyncClient):
Expand All @@ -78,3 +76,6 @@ def init(llm, doku_url, api_key, environment="default", application_name="defaul
elif isinstance(llm, Anthropic):
init_anthropic(llm, doku_url, api_key, environment, application_name, skip_resp)
return
elif hasattr(llm, 'generate') and callable(llm.generate):
init_cohere(llm, doku_url, api_key, environment, application_name, skip_resp)
return

0 comments on commit 0915604

Please sign in to comment.