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

[Model] add openai compatible API interface #546

Merged
merged 3 commits into from
Feb 20, 2025
Merged

Conversation

Luodian
Copy link
Contributor

@Luodian Luodian commented Feb 19, 2025

Update API usage and add environment configuration

  • Add new OpenAICompatible model class to support more variants models as long as they support openai format API.
  • Update .gitignore to exclude .env and scripts/.

.gitignore:

  • Exclude .env file for security.
  • Ensure no scripts directory is tracked.

lmms_eval/models/gpt4v.py:

  • Refactor API client initialization to use new OpenAI and Azure clients.
  • Update image encoding to handle size limits with resizing logic.
  • Adjust retry logic for API calls, reducing sleep time.

- Adjust API client initialization for OpenAI and Azure.
- Modify image encoding to handle size limits and maintain aspect ratio.
- Add new `OpenAICompatible` model class.
- Introduce retry mechanism for API requests with configurable retries.
- Update `.gitignore` to exclude `.env` and `scripts/`.

.gitignore:
- Exclude `.env` file for security.
- Ensure no scripts directory is tracked.

lmms_eval/models/gpt4v.py:
- Refactor API client initialization to use new OpenAI and Azure clients.
- Update image encoding to handle size limits with resizing logic.
- Adjust retry logic for API calls, reducing sleep time.

lmms_eval/models/openai_compatible.py:
- Create new `OpenAICompatible` model class with similar structure.
- Implement encoding functions for images and videos.
- Integrate environment variable loading and persistent response caching.

miscs/model_dryruns/openai_compatible.sh:
- Add sample script for running the new model.
- Remove unused import for deepcopy in `openai_compatible.py`.
- Add a blank line for better separation of code sections.
- Adjust comment formatting for `max_size_in_mb` for consistency.
- Ensure consistent spacing around comments.

File: `lmms_eval/models/openai_compatible.py`
- Removed `deepcopy` import: cleaned up unnecessary code.
- Added blank line after `load_dotenv`: improved readability.
- Reformatted comment on `max_size_in_mb`: enhanced clarity.
- Removed extra blank line before `Accelerator`: tightened spacing.
@kcz358 kcz358 force-pushed the dev/add_oai_compatibl branch from 1a60a35 to e0aa1c7 Compare February 20, 2025 05:20
@kcz358
Copy link
Collaborator

kcz358 commented Feb 20, 2025

image

@kcz358 kcz358 merged commit 8b68660 into main Feb 20, 2025
2 checks passed
@kcz358 kcz358 deleted the dev/add_oai_compatibl branch February 20, 2025 05:48
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