forked from box/mojito
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AI translation functionality (#147)
* DB updates * Initial GPT translate flow compiling * Fix package names * Added unit test for AITranslationTextUnitFilterService * Fix test failures * Add @ConditionalOnProperty to AITranslateJob to get tests running * Updated filter configuration to handle different config across repositories * Null Handling * Fix return type for prompt query lookup * Added implementation to extract translation from json key response * Cleaned up default prompt handling, added unit tests * Add metric to record time taken for text unit to be machine translated * Parse language from BCP-47 tag correctly * Remove unused join * No AI translation if current variant exists for locale * Code review updates * Update log and add metric * Added AI translation handling for virtual text units * Updating code readability * Tests passing * Only translate supplied locales, added support for optional placeholder templating * Further review updates * Update AITranslateJob to a Quartz Cron job, other code review updates * Add cron setup * Added unit test for batch processing failure logic * Update configuration to use ConfigProperties and added repository level config for re-using source on lang match * Added CLI support for isJsonResponse boolean for ai prompts * Added jsonResponseKey to ai prompt table and added findLocalesWithVariantByTmTextUnitId query * Fix test failures * Update exception handling logic for batch processing * Added error logging * Added parellization, updated database inserts to be done in batches of server side inserts * Fix log condition * Remove dead code, fix docs * Doc fix
- Loading branch information
Showing
39 changed files
with
2,749 additions
and
127 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
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
7 changes: 6 additions & 1 deletion
7
webapp/src/main/java/com/box/l10n/mojito/entity/PromptType.java
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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
package com.box.l10n.mojito.entity; | ||
|
||
public enum PromptType { | ||
SOURCE_STRING_CHECKER; | ||
SOURCE_STRING_CHECKER, | ||
TRANSLATION; | ||
|
||
public String toString() { | ||
return name(); | ||
} | ||
} |
50 changes: 0 additions & 50 deletions
50
webapp/src/main/java/com/box/l10n/mojito/entity/RepositoryAIPrompt.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
webapp/src/main/java/com/box/l10n/mojito/entity/RepositoryLocaleAIPrompt.java
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,66 @@ | ||
package com.box.l10n.mojito.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import jakarta.persistence.UniqueConstraint; | ||
|
||
@Entity | ||
@Table( | ||
name = "repository_locale_ai_prompt", | ||
uniqueConstraints = { | ||
@UniqueConstraint( | ||
name = "UK__REPOSITORY_LOCALE_AI_PROMPT__REPO_ID__LOCALE_ID__AI_PROMPT", | ||
columnNames = {"repository_id", "locale_id", "ai_prompt_id"}) | ||
}) | ||
public class RepositoryLocaleAIPrompt extends BaseEntity { | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "repository_id", nullable = false) | ||
private Repository repository; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "locale_id", nullable = true) | ||
private Locale locale; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "ai_prompt_id", nullable = false) | ||
private AIPrompt aiPrompt; | ||
|
||
@Column(name = "disabled") | ||
private boolean disabled; | ||
|
||
public AIPrompt getAiPrompt() { | ||
return aiPrompt; | ||
} | ||
|
||
public void setAiPrompt(AIPrompt aiPrompt) { | ||
this.aiPrompt = aiPrompt; | ||
} | ||
|
||
public Repository getRepository() { | ||
return repository; | ||
} | ||
|
||
public void setRepository(Repository repository) { | ||
this.repository = repository; | ||
} | ||
|
||
public Locale getLocale() { | ||
return locale; | ||
} | ||
|
||
public void setLocale(Locale locale) { | ||
this.locale = locale; | ||
} | ||
|
||
public boolean isDisabled() { | ||
return disabled; | ||
} | ||
|
||
public void setDisabled(boolean disabled) { | ||
this.disabled = disabled; | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
webapp/src/main/java/com/box/l10n/mojito/entity/TmTextUnitPendingMT.java
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,33 @@ | ||
package com.box.l10n.mojito.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
import java.time.ZonedDateTime; | ||
|
||
@Entity | ||
@Table(name = "tm_text_unit_pending_mt") | ||
public class TmTextUnitPendingMT extends BaseEntity { | ||
|
||
@Column(name = "tm_text_unit_id") | ||
private Long tmTextUnitId; | ||
|
||
@Column(name = "created_date") | ||
private ZonedDateTime createdDate; | ||
|
||
public ZonedDateTime getCreatedDate() { | ||
return createdDate; | ||
} | ||
|
||
public void setCreatedDate(ZonedDateTime createdDate) { | ||
this.createdDate = createdDate; | ||
} | ||
|
||
public Long getTmTextUnitId() { | ||
return tmTextUnitId; | ||
} | ||
|
||
public void setTmTextUnitId(Long tmTextUnitId) { | ||
this.tmTextUnitId = tmTextUnitId; | ||
} | ||
} |
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
Oops, something went wrong.