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

Feature/org name of model #49

Merged
merged 7 commits into from
Jul 7, 2024
Merged

Feature/org name of model #49

merged 7 commits into from
Jul 7, 2024

Conversation

dockhardman
Copy link
Owner

  1. OpenAI Client Enhancements:

    • Refactored the OpenaiClients class to improve organization and modularity.
    • Introduced OpenaiModels and OpenaiDepends classes to separate concerns.
    • Implemented methods for adding and removing models dynamically.
    • Added support for stripping organization prefixes from model names.
  2. Model Management:

    • Centralized model definitions for various AI providers (OpenAI, Azure, Anthropic, Google, Groq, Perplexity, Voyage).
    • Implemented a more flexible system for managing supported models across different providers.
    • Improved model initialization and storage mechanisms.
  3. Organization Type Handling:

    • Enhanced organization type detection from model names and API parameters.
    • Implemented org_in_model_name and org_in_supported_models methods for better organization type inference.
  4. Logging and Debugging:

    • Added more comprehensive logging throughout the codebase, especially for organization type detection and client initialization.
    • Implemented display_object function for better object representation in logs.
  5. API Endpoint Improvements:

    • Updated various API endpoints (chat, completions, embeddings, images, moderations) to use the new organization type detection and model management systems.
    • Standardized error handling and response formatting across endpoints.
  6. OpenAPI Examples:

    • Added new OpenAPI examples for various chat completion requests (OpenAI, Google, Perplexity, Groq).
    • Implemented a utility function to_openapi_examples for converting examples to the required format.
  7. Client Initialization:

    • Refactored client initialization process for better modularity and easier maintenance.
    • Implemented separate initialization methods for each AI provider client.
  8. Dependency Injection:

    • Updated dependency injection mechanisms to use the new organization type detection system.
    • Improved error handling and logging in dependency resolution.
  9. Code Structure and Organization:

    • Moved some utility functions and constants to separate files for better code organization.
    • Standardized import statements and removed unused imports.
  10. Type Hinting and Documentation:

    • Improved type hinting throughout the codebase for better static analysis.
    • Added or updated docstrings for key methods and classes.

- Import predefined model lists from `languru.types.models` for Anthropic, Google, Groq, Perplexity, and Voyage
- Replace hardcoded `supported_models` with imported model lists
- Update `GoogleModels` and `GroqModels` classes to include `supported_models` attribute
- Add type ignores to resolve mypy issues in Groq client
- Minor code style improvements and type annotations
- Split client initialization into separate methods for each provider
- Replace static timestamp with dynamic creation time for models
- Improve code organization and readability in OpenaiClients class
- Maintain consistent model creation process across all providers
…class

- Introduce OpenaiModels class for centralized model management
- Refactor OpenaiClients to inherit from OpenaiModels
- Add methods for adding and removing models dynamically
- Enhance error handling in model retrieval
- Update model initialization to use new management methods

This refactoring improves code organization, flexibility, and maintainability
of OpenAI model handling across different providers.
- openai_clients.py:
  - Rename OpenaiClients to inherit from OpenaiModels and new OpenaiDepends class
  - Add methods for stripping org from model name and detecting org type
  - Refactor org_from_model to use new helper methods
  - Move depends_org_type to OpenaiDepends class

- organizations.py:
  - Enhance to_org_type function to handle OrganizationType input

This refactoring improves code organization and adds flexibility
in handling different organization types for OpenAI models.
- Add logging functionality to chat.py
- Improve error handling for organization type
- Enhance model name handling and strip organization prefix
- Add debug logging for organization type, OpenAI client, and model
- Fix typo in model name parsing in openai_clients.py
- Add utility function for human-readable object representation

This commit improves the robustness and debuggability of the chat
completion functionality, making it easier to trace issues and
understand the system's behavior.
- Add logging functionality across all API handlers for better debugging
- Improve error handling for organization types and model selection
- Refactor code to use common utility functions for consistency
- Enhance handling of organization-specific model names
- Affected files: completions.py, embeddings.py, images.py, moderations.py

This update improves the robustness and maintainability of the API handlers
in the languru server.
- Create new 'openapi' example module with chat completion requests
- Refactor chat completion API to use new examples
- Add utility function for OpenAPI example conversion
Copy link

codecov bot commented Jul 7, 2024

Codecov Report

Attention: Patch coverage is 87.16578% with 24 lines in your changes missing coverage. Please review.

Project coverage is 81.65%. Comparing base (e405811) to head (cff6179).

Files Patch % Lines
languru/server/deps/openai_clients.py 78.50% 23 Missing ⚠️
languru/server/utils/common.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
+ Coverage   81.12%   81.65%   +0.53%     
==========================================
  Files          64       65       +1     
  Lines        2215     2339     +124     
==========================================
+ Hits         1797     1910     +113     
- Misses        418      429      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dockhardman dockhardman merged commit e0fd022 into master Jul 7, 2024
3 checks passed
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.

1 participant