Skip to content

Commit

Permalink
fix: replace openai dummy endpoint by dummy strings to avoid lychee f…
Browse files Browse the repository at this point in the history
…ail (#1784)
  • Loading branch information
BlueGrizzliBear committed Oct 2, 2024
1 parent 084a6b1 commit 81ebe2f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/sdk/tutorials/llm_project_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ model_response = kili.llm.create_model(
model={
"credentials": {
"api_key": "<YOUR_OPEN_AI_API_KEY>",
"endpoint": "https://api.openai.com/v1/",
"endpoint": "<your_desired_open_ai_endpoint>",
},
"name": "My Model",
"type": "OPEN_AI_SDK",
Expand Down
2 changes: 1 addition & 1 deletion recipes/llm_project_setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
" model={\n",
" \"credentials\": {\n",
" \"api_key\": \"<YOUR_OPEN_AI_API_KEY>\",\n",
" \"endpoint\": \"https://api.openai.com/v1/\",\n",
" \"endpoint\": \"<your_desired_open_ai_endpoint>\",\n",
" },\n",
" \"name\": \"My Model\",\n",
" \"type\": \"OPEN_AI_SDK\",\n",
Expand Down
2 changes: 1 addition & 1 deletion src/kili/llm/presentation/client/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def create_model(self, organization_id: str, model: dict) -> ModelDict:
... "type": "OPEN_AI_SDK",
... "credentials": {
... "api_key": "your_open_ai_api_key",
... "endpoint": "https://api.openai.com/v1/"
... "endpoint": "your_open_ai_endpoint"
... }
... }
>>> kili.llm.create_model(organization_id="your_organization_id", model=model_data)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/test_e2e_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_create_and_manage_project_and_model_resources(kili: Kili):
project_id = project["id"]

model_data = {
"credentials": {"api_key": "***", "endpoint": "https://api.openai.com"},
"credentials": {"api_key": "***", "endpoint": "your_open_ai_endpoint"},
"name": MODEL_NAME,
"type": "OPEN_AI_SDK",
}
Expand Down
42 changes: 19 additions & 23 deletions tests/unit/llm/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@


def test_map_create_model_input_with_openai_sdk_credentials():
credentials = OpenAISDKCredentials(api_key="api_key", endpoint="https://api.openai.com/v1/")
credentials = OpenAISDKCredentials(api_key="api_key", endpoint="your_open_ai_endpoint")
input_data = ModelToCreateInput(
name="Test Model",
type=ModelType.OPEN_AI_SDK,
Expand All @@ -71,7 +71,7 @@ def test_map_create_model_input_with_openai_sdk_credentials():
expected_output = {
"credentials": {
"apiKey": "api_key",
"endpoint": "https://api.openai.com/v1/",
"endpoint": "your_open_ai_endpoint",
},
"name": "Test Model",
"type": ModelType.OPEN_AI_SDK.value,
Expand All @@ -86,7 +86,7 @@ def test_map_create_model_input_with_azure_openai_credentials():
credentials = AzureOpenAICredentials(
api_key="api_key",
deployment_id="deployment_id",
endpoint="https://azure-openai-endpoint.com",
endpoint="your_azure_open_ai_endpoint",
)
input_data = ModelToCreateInput(
name="Test Azure Model",
Expand All @@ -98,7 +98,7 @@ def test_map_create_model_input_with_azure_openai_credentials():
"credentials": {
"apiKey": "api_key",
"deploymentId": "deployment_id",
"endpoint": "https://azure-openai-endpoint.com",
"endpoint": "your_azure_open_ai_endpoint",
},
"name": "Test Azure Model",
"type": ModelType.AZURE_OPEN_AI.value,
Expand All @@ -118,14 +118,12 @@ def test_map_update_model_input_update_name_only():


def test_map_update_model_input_update_openai_sdk_credentials():
credentials = OpenAISDKCredentials(
api_key="new_api_key", endpoint="https://new-openai-endpoint.com"
)
credentials = OpenAISDKCredentials(api_key="new_api_key", endpoint="your_new_open_ai_endpoint")
input_data = ModelToUpdateInput(credentials=credentials)
expected_output = {
"credentials": {
"apiKey": "new_api_key",
"endpoint": "https://new-openai-endpoint.com",
"endpoint": "your_new_open_ai_endpoint",
}
}

Expand All @@ -137,14 +135,14 @@ def test_map_update_model_input_update_azure_openai_credentials():
credentials = AzureOpenAICredentials(
api_key="new_api_key",
deployment_id="new_deployment_id",
endpoint="https://new-azure-openai-endpoint.com",
endpoint="your_new_azure_open_ai_endpoint",
)
input_data = ModelToUpdateInput(credentials=credentials)
expected_output = {
"credentials": {
"apiKey": "new_api_key",
"deploymentId": "new_deployment_id",
"endpoint": "https://new-azure-openai-endpoint.com",
"endpoint": "your_new_azure_open_ai_endpoint",
}
}

Expand All @@ -153,15 +151,13 @@ def test_map_update_model_input_update_azure_openai_credentials():


def test_map_update_model_input_update_name_and_openai_sdk_credentials():
credentials = OpenAISDKCredentials(
api_key="new_api_key", endpoint="https://new-openai-endpoint.com"
)
credentials = OpenAISDKCredentials(api_key="new_api_key", endpoint="your_new_open_ai_endpoint")
input_data = ModelToUpdateInput(name="Updated Model Name", credentials=credentials)
expected_output = {
"name": "Updated Model Name",
"credentials": {
"apiKey": "new_api_key",
"endpoint": "https://new-openai-endpoint.com",
"endpoint": "your_new_open_ai_endpoint",
},
}

Expand All @@ -173,15 +169,15 @@ def test_map_update_model_input_update_name_and_azure_openai_credentials():
credentials = AzureOpenAICredentials(
api_key="new_api_key",
deployment_id="new_deployment_id",
endpoint="https://new-azure-openai-endpoint.com",
endpoint="your_new_azure_open_ai_endpoint",
)
input_data = ModelToUpdateInput(name="Updated Model Name", credentials=credentials)
expected_output = {
"name": "Updated Model Name",
"credentials": {
"apiKey": "new_api_key",
"deploymentId": "new_deployment_id",
"endpoint": "https://new-azure-openai-endpoint.com",
"endpoint": "your_new_azure_open_ai_endpoint",
},
}

Expand Down Expand Up @@ -229,7 +225,7 @@ def test_create_model_open_ai_sdk(mocker):
"type": "OPEN_AI_SDK",
"credentials": {
"api_key": "***",
"endpoint": "https://api.openai.com",
"endpoint": "your_open_ai_endpoint",
},
},
)
Expand All @@ -249,7 +245,7 @@ def test_create_model_azure_openai(mocker):
"type": "AZURE_OPEN_AI",
"credentials": {
"api_key": "***",
"endpoint": "https://api.openai.com",
"endpoint": "your_open_ai_endpoint",
"deployment_id": "deployment_id",
},
},
Expand All @@ -268,7 +264,7 @@ def test_create_invalid_model(mocker):
model={
"name": "New Model",
"type": "Wrong type",
"credentials": {"api_key": "***", "endpoint": "https://api.openai.com"},
"credentials": {"api_key": "***", "endpoint": "your_open_ai_endpoint"},
},
)

Expand All @@ -285,7 +281,7 @@ def test_update_model_open_ai_sdk(mocker):
"name": "Updated Model",
"credentials": {
"api_key": "***",
"endpoint": "https://api.openai.com",
"endpoint": "your_open_ai_endpoint",
},
},
)
Expand All @@ -305,7 +301,7 @@ def test_update_model_azure_open_ai(mocker):
"name": "Updated Model",
"credentials": {
"api_key": "***",
"endpoint": "https://api.openai.com",
"endpoint": "your_open_ai_endpoint",
"deployment_id": "deployment_id",
},
},
Expand All @@ -324,7 +320,7 @@ def test_update_invalid_model(mocker):
model={
"name": "New Model",
"type": "Wrong type",
"credentials": {"api_key": "***", "endpoint": "https://api.openai.com"},
"credentials": {"api_key": "***", "endpoint": "your_open_ai_endpoint"},
},
)

Expand All @@ -340,7 +336,7 @@ def test_update_non_existing_model(mocker):
model={
"name": "New Model",
"type": "Wrong type",
"credentials": {"api_key": "***", "endpoint": "https://api.openai.com"},
"credentials": {"api_key": "***", "endpoint": "your_open_ai_endpoint"},
},
)

Expand Down

0 comments on commit 81ebe2f

Please sign in to comment.