Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use langcodes to match to_lang to chat_sample name #873

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SamuelWN
Copy link
Contributor

@SamuelWN SamuelWN commented Mar 7, 2025

Change chat_sample handling:

  • Add function get_chat_sample(to_lang) to return chat_sample for requested language
  • Use langcodes to match to_lang to the closest available sample languages
    • Currently implemented with a narrow margin (max_distance=5)
      • e.g. both (en-US vs en-GB) and (pt-BR vs pt-PT) have a score langcodes distance of 5
  • Cache chat_sample[to_lang] match as variable (only need to do langcodes matching once)

Provides additional flexibility & resilience for handling chat_sample language IDs (a user-provided value) .

Additional changes:

  • Consolidate _LANGUAGE_CODE_MAP into GPTConfig
  • Cleaned up unused imports
  • chatgpt.py - Added English comments below Chinese comments

SamuelWN and others added 5 commits March 3, 2025 14:11
Change `chat_sample` handling:
- Add function `get_chat_sample(to_lang)` to return chat_sample for requested language
- Use `langcodes` to match `to_lang` to the closest available sample languages (within narrow margin)
  * `max_difference = 5` = `en-US` vs `en-GB` or `pt-BR` vs `pt-PT`
- Cache `chat_sample[to_lang]` match as variable (only need to do `langcodes` matching once)
Merge `ollama` --> `custom_openai` migration
@popcion
Copy link
Contributor

popcion commented Mar 8, 2025

conflict again i guess, with next pr, but just a little bit
I see your changes, and I have also changed the other newly added CHS comments, apart from the ones you modified, to bilingual comments in CHS and ENG.

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.

2 participants