Skip to content

Pass better string ID to LLM Prompt for XLIFF and Gettext - #4383

Merged
flodolo merged 2 commits into
mozilla:mainfrom
flodolo:issue4381_llm_ios
Aug 10, 2026
Merged

flodolo merged 2 commits into
mozilla:mainfrom
flodolo:issue4381_llm_ios

Conversation

@flodolo

@flodolo flodolo commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Fixes #4381

@flodolo
flodolo requested a review from mathjazz August 10, 2026 11:21
@flodolo

flodolo commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

I thought about putting this on the entity model, but this code is only used by the LLM prompt, so ended up adding it to the OpenAI existing code. In case, we'd need a clear name (entity_key() might be too generic).

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left a couple of comments.

Comment thread pontoon/machinery/openai_service.py Outdated
)


def get_llm_string_id(entity: Entity) -> str | None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this file is service-specific, shall we move this function outside of it, e.g. utils.py?

Comment thread pontoon/machinery/openai_service.py Outdated
# the section part.
if section_key and key[: len(section_key)] == section_key:
key = key[len(section_key) :]
if entity.resource.format == Resource.Format.GETTEXT:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we skip the ID when it equals entity.string, regardless of format? It's also the case for at least some XCODE/XLIFF files.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, didn't think of those.

@flodolo
flodolo requested a review from mathjazz August 10, 2026 15:06
@flodolo
flodolo merged commit 85a6b25 into mozilla:main Aug 10, 2026
7 checks passed
@flodolo
flodolo deleted the issue4381_llm_ios branch August 10, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLM prompt: string ID passed for iOS projects is not relevant

2 participants