diff --git a/crowdin_api/api_resources/ai/enums.py b/crowdin_api/api_resources/ai/enums.py index d9174ec..fcd4d0b 100644 --- a/crowdin_api/api_resources/ai/enums.py +++ b/crowdin_api/api_resources/ai/enums.py @@ -2,8 +2,9 @@ class AIPromptAction(Enum): - ASSIST = "assist" PRE_TRANSLATE = "pre_translate" + ALIGNMENT = "alignment" + QA_CHECK = "qa_check" class AIPromptOperation(Enum): @@ -67,7 +68,6 @@ class AiReportType(Enum): class EditAiSettingsPatchPath(Enum): - ASSIST_ACTION_AI_PROMPT_ID = "/assistActionAiPromptId" EDITOR_SUGGESTION_AI_PROMPT_ID = "/editorSuggestionAiPromptId" SHORTCUTS = "/shortcuts" diff --git a/crowdin_api/api_resources/ai/tests/test_ai_resources.py b/crowdin_api/api_resources/ai/tests/test_ai_resources.py index 83da9a2..0a5fb34 100644 --- a/crowdin_api/api_resources/ai/tests/test_ai_resources.py +++ b/crowdin_api/api_resources/ai/tests/test_ai_resources.py @@ -22,7 +22,9 @@ AiToolFunction, AiToolObject, AiTranslateStringsRequest, + AlignmentActionAiPromptContextResources, CreateAIPromptFineTuningJobRequest, + CustomActionAiPromptContextResources, EditAIPromptPath, GeneralReportSchema, GenerateAiPromptCompletionRequest, @@ -30,6 +32,7 @@ GenerateAiReportRequest, HyperParameters, PreTranslateActionAiPromptContextResources, + QaCheckActionAiPromptContextResources, TrainingOptions, ) from crowdin_api.api_resources.enums import PatchOperation @@ -87,13 +90,13 @@ def test_get_ai_provider_path(self, in_params, path, base_absolut_url): ( { "projectId": 1, - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.ALIGNMENT, "limit": 20, "offset": 2, }, { "projectId": 1, - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.ALIGNMENT, "limit": 20, "offset": 2, }, @@ -121,14 +124,14 @@ def test_list_ai_prompts( ( { "name": "basic", - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.PRE_TRANSLATE, "aiProviderId": 1, "aiModelId": "gpt-3.5-turbo-instruct", "config": {"mode": "advanced", "prompt": "test prompt"}, }, { "name": "basic", - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.PRE_TRANSLATE, "aiProviderId": 1, "aiModelId": "gpt-3.5-turbo-instruct", "config": {"mode": "advanced", "prompt": "test prompt"}, @@ -137,21 +140,79 @@ def test_list_ai_prompts( ( { "name": "basic", - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.PRE_TRANSLATE, "aiProviderId": 1, "aiModelId": "gpt-3.5-turbo-instruct", "isEnabled": False, "enabledProjectIds": [1, 2, 3], - "config": {"mode": "advanced", "prompt": "test prompt"}, + "config": { + "mode": "basic", + "projectContext": True, + "organizationContext": True, + }, }, { "name": "basic", - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.PRE_TRANSLATE, "aiProviderId": 1, "aiModelId": "gpt-3.5-turbo-instruct", "isEnabled": False, "enabledProjectIds": [1, 2, 3], - "config": {"mode": "advanced", "prompt": "test prompt"}, + "config": { + "mode": "basic", + "projectContext": True, + "organizationContext": True, + }, + }, + ), + ( + { + "name": "alignment", + "action": AIPromptAction.ALIGNMENT, + "aiProviderId": 1, + "aiModelId": "gpt-3.5-turbo-instruct", + "config": { + "mode": "basic", + "projectContext": True, + "organizationContext": True, + }, + }, + { + "name": "alignment", + "action": AIPromptAction.ALIGNMENT, + "aiProviderId": 1, + "aiModelId": "gpt-3.5-turbo-instruct", + "config": { + "mode": "basic", + "projectContext": True, + "organizationContext": True, + }, + }, + ), + ( + { + "name": "qa check", + "action": AIPromptAction.QA_CHECK, + "aiProviderId": 1, + "aiModelId": "gpt-3.5-turbo-instruct", + "config": { + "mode": "basic", + "evaluationSteps": ["Check terminology consistency"], + "projectContext": True, + "organizationContext": True, + }, + }, + { + "name": "qa check", + "action": AIPromptAction.QA_CHECK, + "aiProviderId": 1, + "aiModelId": "gpt-3.5-turbo-instruct", + "config": { + "mode": "basic", + "evaluationSteps": ["Check terminology consistency"], + "projectContext": True, + "organizationContext": True, + }, }, ), ), @@ -826,7 +887,8 @@ def test_clone_ai_prompt(self, m_request, base_absolut_url): stringIds=[1, 2, 3], overridePromptValues={ "property1": "string" - } + }, + projectDescription="Mobile app project" ), tools=[ AiToolObject( @@ -850,7 +912,8 @@ def test_clone_ai_prompt(self, m_request, base_absolut_url): "stringIds": [1, 2, 3], "overridePromptValues": { "property1": "string" - } + }, + "projectDescription": "Mobile app project" }, "tools": [ { @@ -867,6 +930,68 @@ def test_clone_ai_prompt(self, m_request, base_absolut_url): "tool_choice": "string" }, ), + ( + GenerateAiPromptCompletionRequest( + resources=AlignmentActionAiPromptContextResources( + projectId=1, + sourceLanguageId="en", + targetLanguageId="uk", + stringIds=[1, 2, 3], + projectDescription="Mobile app project" + ), + ), + { + "resources": { + "projectId": 1, + "sourceLanguageId": "en", + "targetLanguageId": "uk", + "stringIds": [1, 2, 3], + "projectDescription": "Mobile app project" + }, + }, + ), + ( + GenerateAiPromptCompletionRequest( + resources=QaCheckActionAiPromptContextResources( + projectId=1, + sourceLanguageId="en", + targetLanguageId="uk", + stringIds=[1, 2, 3], + projectDescription="Mobile app project" + ), + ), + { + "resources": { + "projectId": 1, + "sourceLanguageId": "en", + "targetLanguageId": "uk", + "stringIds": [1, 2, 3], + "projectDescription": "Mobile app project" + }, + }, + ), + ( + GenerateAiPromptCompletionRequest( + resources=CustomActionAiPromptContextResources( + projectId=1, + sourceLanguageId="en", + targetLanguageId="uk", + stringIds=[1, 2, 3], + customInstruction="Translate using a formal tone", + projectDescription="Mobile app project" + ), + ), + { + "resources": { + "projectId": 1, + "sourceLanguageId": "en", + "targetLanguageId": "uk", + "stringIds": [1, 2, 3], + "customInstruction": "Translate using a formal tone", + "projectDescription": "Mobile app project" + }, + }, + ), ), ) @mock.patch("crowdin_api.requester.APIRequester.request") @@ -1026,11 +1151,6 @@ def test_get_ai_settings(self, m_request, base_absolut_url): ( ( [ - { - "op": PatchOperation.REPLACE.value, - "path": EditAiSettingsPatchPath.ASSIST_ACTION_AI_PROMPT_ID.value, - "value": 1 - }, { "op": PatchOperation.REPLACE.value, "path": EditAiSettingsPatchPath.EDITOR_SUGGESTION_AI_PROMPT_ID.value, @@ -1038,11 +1158,6 @@ def test_get_ai_settings(self, m_request, base_absolut_url): } ], [ - { - "op": "replace", - "path": "/assistActionAiPromptId", - "value": 1 - }, { "op": "replace", "path": "/editorSuggestionAiPromptId", @@ -1474,13 +1589,13 @@ def test_get_ai_provider_path(self, in_params, path, base_absolut_url): ( { "projectId": 1, - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.QA_CHECK, "limit": 20, "offset": 2, }, { "projectId": 1, - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.QA_CHECK, "limit": 20, "offset": 2, }, @@ -1507,14 +1622,14 @@ def test_list_ai_prompts( ( { "name": "basic", - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.PRE_TRANSLATE, "aiProviderId": 1, "aiModelId": "gpt-3.5-turbo-instruct", "config": {"mode": "advanced", "prompt": "test prompt"}, }, { "name": "basic", - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.PRE_TRANSLATE, "aiProviderId": 1, "aiModelId": "gpt-3.5-turbo-instruct", "config": {"mode": "advanced", "prompt": "test prompt"}, @@ -1523,7 +1638,7 @@ def test_list_ai_prompts( ( { "name": "basic", - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.PRE_TRANSLATE, "aiProviderId": 1, "aiModelId": "gpt-3.5-turbo-instruct", "isEnabled": False, @@ -1536,7 +1651,7 @@ def test_list_ai_prompts( }, { "name": "basic", - "action": AIPromptAction.ASSIST, + "action": AIPromptAction.PRE_TRANSLATE, "aiProviderId": 1, "aiModelId": "gpt-3.5-turbo-instruct", "isEnabled": False, @@ -1548,6 +1663,56 @@ def test_list_ai_prompts( }, }, ), + ( + { + "name": "alignment", + "action": AIPromptAction.ALIGNMENT, + "aiProviderId": 1, + "aiModelId": "gpt-3.5-turbo-instruct", + "config": { + "mode": "basic", + "projectContext": True, + "organizationContext": True, + }, + }, + { + "name": "alignment", + "action": AIPromptAction.ALIGNMENT, + "aiProviderId": 1, + "aiModelId": "gpt-3.5-turbo-instruct", + "config": { + "mode": "basic", + "projectContext": True, + "organizationContext": True, + }, + }, + ), + ( + { + "name": "qa check", + "action": AIPromptAction.QA_CHECK, + "aiProviderId": 1, + "aiModelId": "gpt-3.5-turbo-instruct", + "config": { + "mode": "basic", + "evaluationSteps": ["Check terminology consistency"], + "projectContext": True, + "organizationContext": True, + }, + }, + { + "name": "qa check", + "action": AIPromptAction.QA_CHECK, + "aiProviderId": 1, + "aiModelId": "gpt-3.5-turbo-instruct", + "config": { + "mode": "basic", + "evaluationSteps": ["Check terminology consistency"], + "projectContext": True, + "organizationContext": True, + }, + }, + ), ), ) @mock.patch("crowdin_api.requester.APIRequester.request") @@ -2160,7 +2325,8 @@ def test_clone_ai_prompt(self, m_request, base_absolut_url): stringIds=[1, 2, 3], overridePromptValues={ "property1": "string" - } + }, + projectDescription="Mobile app project" ), tools=[ AiToolObject( @@ -2184,7 +2350,8 @@ def test_clone_ai_prompt(self, m_request, base_absolut_url): "stringIds": [1, 2, 3], "overridePromptValues": { "property1": "string" - } + }, + "projectDescription": "Mobile app project" }, "tools": [ { @@ -2201,6 +2368,68 @@ def test_clone_ai_prompt(self, m_request, base_absolut_url): "tool_choice": "string" }, ), + ( + GenerateAiPromptCompletionRequest( + resources=AlignmentActionAiPromptContextResources( + projectId=1, + sourceLanguageId="en", + targetLanguageId="uk", + stringIds=[1, 2, 3], + projectDescription="Mobile app project" + ), + ), + { + "resources": { + "projectId": 1, + "sourceLanguageId": "en", + "targetLanguageId": "uk", + "stringIds": [1, 2, 3], + "projectDescription": "Mobile app project" + }, + }, + ), + ( + GenerateAiPromptCompletionRequest( + resources=QaCheckActionAiPromptContextResources( + projectId=1, + sourceLanguageId="en", + targetLanguageId="uk", + stringIds=[1, 2, 3], + projectDescription="Mobile app project" + ), + ), + { + "resources": { + "projectId": 1, + "sourceLanguageId": "en", + "targetLanguageId": "uk", + "stringIds": [1, 2, 3], + "projectDescription": "Mobile app project" + }, + }, + ), + ( + GenerateAiPromptCompletionRequest( + resources=CustomActionAiPromptContextResources( + projectId=1, + sourceLanguageId="en", + targetLanguageId="uk", + stringIds=[1, 2, 3], + customInstruction="Translate using a formal tone", + projectDescription="Mobile app project" + ), + ), + { + "resources": { + "projectId": 1, + "sourceLanguageId": "en", + "targetLanguageId": "uk", + "stringIds": [1, 2, 3], + "customInstruction": "Translate using a formal tone", + "projectDescription": "Mobile app project" + }, + }, + ), ), ) @mock.patch("crowdin_api.requester.APIRequester.request") @@ -2350,11 +2579,6 @@ def test_get_ai_settings(self, m_request, base_absolut_url): ( ( [ - { - "op": PatchOperation.REPLACE.value, - "path": EditAiSettingsPatchPath.ASSIST_ACTION_AI_PROMPT_ID.value, - "value": 1 - }, { "op": PatchOperation.REPLACE.value, "path": EditAiSettingsPatchPath.EDITOR_SUGGESTION_AI_PROMPT_ID.value, @@ -2362,11 +2586,6 @@ def test_get_ai_settings(self, m_request, base_absolut_url): } ], [ - { - "op": "replace", - "path": "/assistActionAiPromptId", - "value": 1 - }, { "op": "replace", "path": "/editorSuggestionAiPromptId", diff --git a/crowdin_api/api_resources/ai/types.py b/crowdin_api/api_resources/ai/types.py index 513c04e..9f8c4c9 100644 --- a/crowdin_api/api_resources/ai/types.py +++ b/crowdin_api/api_resources/ai/types.py @@ -30,22 +30,32 @@ class BasicModePreTranslateActionCondfig(TypedDict): fileContent: Optional[bool] fileContext: Optional[bool] screenshots: Optional[bool] + # Deprecated: use `projectContext` instead. publicProjectDescription: Optional[bool] + projectContext: Optional[bool] + organizationContext: Optional[bool] -class BasicModeAssistActionCondfig(TypedDict): +class BasicModeAlignmentActionConfig(TypedDict): mode: str - companyDescription: Optional[bool] - projectDescription: Optional[bool] - audienceDescription: Optional[bool] - otherLanguageTranslation: Optional[OtherLanguageTranslation] + customPlaceholders: Optional[Iterable[str]] + # Deprecated: use `projectContext` instead. + publicProjectDescription: Optional[bool] + projectContext: Optional[bool] + organizationContext: Optional[bool] + + +class BasicModeQaCheckActionConfig(TypedDict): + mode: str + evaluationSteps: Iterable[str] glossaryTerms: Optional[bool] tmSuggestions: Optional[bool] fileContext: Optional[bool] screenshots: Optional[bool] + # Deprecated: use `projectContext` instead. publicProjectDescription: Optional[bool] - siblingsStrings: Optional[bool] - filteredStrings: Optional[bool] + projectContext: Optional[bool] + organizationContext: Optional[bool] class AdvancedModeConfig(TypedDict): @@ -70,7 +80,8 @@ class AddAIPromptRequestScheme(TypedDict): enabledProjectIds: Optional[Iterable[int]] config: Union[ BasicModePreTranslateActionCondfig, - BasicModeAssistActionCondfig, + BasicModeAlignmentActionConfig, + BasicModeQaCheckActionConfig, AdvancedModeConfig, ExternalMode, ] @@ -235,15 +246,16 @@ class PreTranslateActionAiPromptContextResources(AiPromptContextResources): targetLanguageId: Optional[str] stringIds: Optional[Iterable[int]] overridePromptValues: Optional[Dict[str, str]] + projectDescription: Optional[str] -class AssistActionAiPromptContextResources(AiPromptContextResources): +class AlignmentActionAiPromptContextResources(AiPromptContextResources): projectId: int sourceLanguageId: Optional[str] targetLanguageId: Optional[str] stringIds: Optional[Iterable[int]] - filteredStringIds: Optional[Iterable[int]] overridePromptValues: Optional[Dict[str, str]] + projectDescription: Optional[str] class QaCheckActionAiPromptContextResources(AiPromptContextResources): @@ -252,6 +264,7 @@ class QaCheckActionAiPromptContextResources(AiPromptContextResources): targetLanguageId: Optional[str] stringIds: Optional[Iterable[int]] overridePromptValues: Optional[Dict[str, str]] + projectDescription: Optional[str] class CustomActionAiPromptContextResources(AiPromptContextResources): @@ -261,6 +274,7 @@ class CustomActionAiPromptContextResources(AiPromptContextResources): stringIds: Optional[Iterable[int]] overridePromptValues: Optional[Dict[str, str]] customInstruction: Optional[str] + projectDescription: Optional[str] class GenerateAiPromptCompletionRequest(TypedDict):