-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AAP-36732: ModelPipelines: Configuration improvements: Remove env vars
- Loading branch information
Showing
34 changed files
with
482 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Example `ANSIBLE_AI_MODEL_MESH_CONFIG` configuration | ||
|
||
Pay close attention to the formatting of the blocks. | ||
|
||
Each ends with `}},` otherwise conversion of the multi-line setting to a `str` can fail. | ||
|
||
```text | ||
ANSIBLE_AI_MODEL_MESH_CONFIG="{ | ||
"ModelPipelineCompletions": { | ||
"provider": "ollama", | ||
"config": { | ||
"inference_url": "http://host.containers.internal:11434", | ||
"model_id": "mistral:instruct"}}, | ||
"ModelPipelineContentMatch": { | ||
"provider": "ollama", | ||
"config": { | ||
"inference_url": "http://host.containers.internal:11434", | ||
"model_id": "mistral:instruct"}}, | ||
"ModelPipelinePlaybookGeneration": { | ||
"provider": "ollama", | ||
"config": { | ||
"inference_url": "http://host.containers.internal:11434", | ||
"model_id": "mistral:instruct"}}, | ||
"ModelPipelineRoleGeneration": { | ||
"provider": "ollama", | ||
"config": { | ||
"inference_url": "http://host.containers.internal:11434", | ||
"model_id": "mistral:instruct"}}, | ||
"ModelPipelinePlaybookExplanation": { | ||
"provider": "ollama", | ||
"config": { | ||
"inference_url": "http://host.containers.internal:11434", | ||
"model_id": "mistral:instruct"}}, | ||
"ModelPipelineChatBot": { | ||
"provider": "http", | ||
"config": { | ||
"inference_url": "http://localhost:8000", | ||
"model_id": "granite3-8b"}} | ||
}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
|
||
import requests | ||
from django.apps import apps | ||
from django.conf import settings | ||
from django.contrib.auth import get_user_model | ||
from django.test import modify_settings, override_settings | ||
from django.urls import reverse | ||
|
@@ -1018,7 +1017,7 @@ def test_full_payload(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n name: apache2"], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -1040,7 +1039,7 @@ def test_multi_task_prompt_commercial(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [ | ||
"- name: Install Apache\n ansible.builtin.apt:\n name: apache2\n state: latest\n- name: start Apache\n ansible.builtin.service:\n name: apache2\n state: started\n enabled: yes\n" # noqa: E501 | ||
], | ||
|
@@ -1088,7 +1087,7 @@ def test_multi_task_prompt_commercial_with_pii(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [ | ||
" - name: Install Apache\n ansible.builtin.apt:\n name: apache2\n state: latest\n - name: say hello [email protected]\n ansible.builtin.debug:\n msg: Hello there [email protected]\n" # noqa: E501 | ||
], | ||
|
@@ -1127,7 +1126,7 @@ def test_rate_limit(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n name: apache2"], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -1151,7 +1150,7 @@ def test_missing_prompt(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n name: apache2"], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -1172,7 +1171,7 @@ def test_authentication_error(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n name: apache2"], | ||
} | ||
# self.client.force_authenticate(user=self.user) | ||
|
@@ -1201,7 +1200,7 @@ def test_completions_preprocessing_error(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n name: apache2"], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -1227,7 +1226,7 @@ def test_completions_preprocessing_error_without_name_prompt(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n name: apache2"], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -1251,7 +1250,7 @@ def test_full_payload_without_ARI(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n name: apache2"], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -1276,7 +1275,7 @@ def test_full_payload_with_recommendation_with_broken_last_line(self): | |
} | ||
# quotation in the last line is not closed, but the truncate function can handle this. | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [ | ||
' ansible.builtin.apt:\n name: apache2\n register: "test' | ||
], | ||
|
@@ -1303,7 +1302,7 @@ def test_completions_postprocessing_error_for_invalid_yaml(self): | |
} | ||
# this prediction has indentation problem with the prompt above | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n garbage name: apache2"], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -1375,7 +1374,7 @@ def test_full_payload_without_ansible_lint_with_commercial_user(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [" ansible.builtin.apt:\n name: apache2"], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -1558,7 +1557,7 @@ def test_completions_pii_clean_up(self): | |
"suggestionId": str(uuid.uuid4()), | ||
} | ||
response_data = { | ||
"model_id": settings.ANSIBLE_AI_MODEL_MESH_MODEL_ID, | ||
"model_id": "a-model-id", | ||
"predictions": [""], | ||
} | ||
self.client.force_authenticate(user=self.user) | ||
|
@@ -4044,9 +4043,7 @@ def json(self): | |
json_response["response"] = input | ||
return MockResponse(json_response, status_code) | ||
|
||
@override_settings(CHATBOT_URL="http://localhost:8080") | ||
@override_settings(CHATBOT_DEFAULT_PROVIDER="wisdom") | ||
@override_settings(CHATBOT_DEFAULT_MODEL="granite-8b") | ||
@mock.patch( | ||
"requests.post", | ||
side_effect=mocked_requests_post, | ||
|
@@ -4058,7 +4055,6 @@ def query_with_no_error(self, payload, mock_post): | |
"requests.post", | ||
side_effect=mocked_requests_post, | ||
) | ||
@override_settings(CHATBOT_URL="") | ||
def query_without_chat_config(self, payload, mock_post): | ||
return self.client.post(reverse("chat"), payload, format="json") | ||
|
||
|
@@ -4178,7 +4174,11 @@ def test_operational_telemetry(self): | |
patch.object( | ||
apps.get_app_config("ai"), | ||
"get_model_pipeline", | ||
Mock(return_value=HttpChatBotPipeline(mock_pipeline_config("http"))), | ||
Mock( | ||
return_value=HttpChatBotPipeline( | ||
mock_pipeline_config("http", model_id="granite-8b") | ||
) | ||
), | ||
), | ||
self.assertLogs(logger="root", level="DEBUG") as log, | ||
): | ||
|
@@ -4285,7 +4285,11 @@ def test_operational_telemetry_with_system_prompt_override(self): | |
patch.object( | ||
apps.get_app_config("ai"), | ||
"get_model_pipeline", | ||
Mock(return_value=HttpChatBotPipeline(mock_pipeline_config("http"))), | ||
Mock( | ||
return_value=HttpChatBotPipeline( | ||
mock_pipeline_config("http", model_id="granite-8b") | ||
) | ||
), | ||
), | ||
self.assertLogs(logger="root", level="DEBUG") as log, | ||
): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.