Skip to content

Refactor query_model: Replace if-elif chain with function-based dispatch#35

Open
geogod42 wants to merge 1 commit intoSamuelSchmidgall:mainfrom
geogod42:refactor-query-model
Open

Refactor query_model: Replace if-elif chain with function-based dispatch#35
geogod42 wants to merge 1 commit intoSamuelSchmidgall:mainfrom
geogod42:refactor-query-model

Conversation

@geogod42
Copy link

Refactored the query_model function to improve its readability and maintainability. Specifically, it replaces the if-elif chain with a dictionary-based dispatch to separate model-specific handler functions.

Key Changes:

  1. Introduced a model_dispatch dictionary for dynamic function calls based on model_str.
  2. Added separate handler functions for each model (e.g., handle_gpt4o, handle_claude_35_sonnet, etc.).
  3. Preserved all existing features and functionality.
  4. Added comments and docstrings to enhance code clarity.

Note: I don't have tokens to test with every API, but the changes should work as intended.

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