Commit graph

53 commits

Author SHA1 Message Date
Paul Gauthier
f92aecbf7a Allow repo map to work with whole edit format, for weaker models with large context 2024-04-23 10:21:54 -07:00
Paul Gauthier
341228b543 gemini benchmarked on whole so far 2024-04-23 09:53:27 -07:00
Paul Gauthier
9afa6e8435 Added gemini 1.5 pro 2024-04-23 09:49:48 -07:00
Paul Gauthier
c21118ce5c Use provider in the validate_environment workaround 2024-04-23 06:28:37 -07:00
Paul Gauthier
89a7b3470a Use fq model name in --models search 2024-04-22 19:17:27 -07:00
Paul Gauthier
25b8d6fec8 Added --models 2024-04-22 18:45:20 -07:00
Paul Gauthier
da80e6af9e Work around litellm bug 2024-04-22 15:00:53 -07:00
Paul Gauthier
6901f92f96 refac 2024-04-22 14:42:46 -07:00
Paul Gauthier
efd3c39e50 Better unknown model warnings 2024-04-22 14:09:08 -07:00
Paul Gauthier
21df025fb9 Use whole and other defaults for claude-2 2024-04-22 12:01:39 -07:00
Paul Gauthier
30c095349a Don't assume gpt-3.5-turbo as the weak model, use main_model if unsure 2024-04-22 10:57:50 -07:00
Paul Gauthier
83c76a3c65 Don't stomp Model.name after a partial match against ModelSettings #568 2024-04-22 10:36:22 -07:00
Paul Gauthier
fd5b9bbfcb Added groq llama3 2024-04-22 07:12:01 -07:00
Paul Gauthier
cd838901d1 Added improved editing support for command-r-plus 2024-04-20 16:53:27 -07:00
Paul Gauthier
9b26eeb9eb Added validate_environment=False to tests 2024-04-20 08:18:27 -07:00
Paul Gauthier
6863b47e6a Check the environment inside Model 2024-04-20 08:09:17 -07:00
Paul Gauthier
4e50f0d095 Support weak_model=False 2024-04-19 14:05:58 -07:00
Paul Gauthier
f81b62dfea Added --require-model-info 2024-04-19 14:01:02 -07:00
Paul Gauthier
aac110f078 copy 2024-04-19 13:45:51 -07:00
Paul Gauthier
6f1cebc4c2 fix: do not stomp main model.info 2024-04-19 11:24:11 -07:00
Paul Gauthier
922559a15a Refactored error handling to display model name in case of unknown model. 2024-04-19 11:17:33 -07:00
Paul Gauthier
fb3285ff77 aider: Added a main function to allow running the script with a model name from the command line and printing the results.
# Aider chat conversation:

USER: add a main func so i can run this script with a model name on the cmd line and print the results

ASSISTANT: Here are the changes to add a `main` function that allows running the script with a model name from the command line and printing the results:

aider/models.py
```python
<<<<<<< SEARCH
=======
import sys

def main():
    if len(sys.argv) != 2:
        print("Usage: python models.py <model_name>")
        sys.exit(1)

    model_name = sys.argv[1]
    matching_models = fuzzy_match_models(model_name)

    if matching_models:
        print(f"Matching models for '{model_name}':")
        for model in matching_models:
            print(model)
    else:
        print(f"No matching models found for '{model_name}'.")

if __name__ == "__main__":
    main()
>>>>>>> REPLACE
```

The `main` function does the following:

1. It checks if the script is called with exactly one command-line argument (the model name). If not, it prints the usage instructions and exits with an error code.

2. It retrieves the model name from the command-line argument using `sys.argv[1]`.

3. It calls the `fuzzy_match_models` function with the provided model name to get the list of matching models.

4. If matching models are found, it prints a message indicating the matching models for the given model name and then prints each matching model on a separate line.

5. If no matching models are found, it prints a message indicating that no matching models were found for the given model name.

The `if __name__ == "__main__":` block ensures that the `main` function is only executed when the script is run directly, not when it is imported as a module.

With these changes, you can run the script from the command line by providing a model name as an argument, and it will print the matching models or a message if no matches are found.
2024-04-19 11:08:28 -07:00
Paul Gauthier
70b2f5d054 aider: Implemented the fuzzy_match_models function to search for models containing the given name or a slight misspelling.
# Aider chat conversation:

USER: implemenet the `fuzzy_match_models` function. takes the name of a LLM like "gpt-3.5" and searches the list of `models` to find models which contain the name or contain a slight misspelling of the name

ASSISTANT: Here is an implementation of the `fuzzy_match_models` function that searches for models containing the given name or a slight misspelling:

aider/models.py
```python
<<<<<<< SEARCH
def fuzzy_match_models(name):
    models = litellm.most_cost.keys()
=======
import difflib

def fuzzy_match_models(name):
    models = litellm.most_cost.keys()

    # Check for exact match first
    if name in models:
        return [name]

    # Check for models containing the name
    matching_models = [model for model in models if name in model]

    # If no matches found, check for slight misspellings
    if not matching_models:
        matching_models = difflib.get_close_matches(name, models, n=3, cutoff=0.8)

    return matching_models
>>>>>>> REPLACE
```

This implementation does the following:

1. It first checks if the given `name` exactly matches any model in the `models` list. If an exact match is found, it returns a list containing only that model name.

2. If no exact match is found, it searches for models that contain the given `name` as a substring. It uses a list comprehension to filter the `models` list and find models that include `name`.

3. If still no matches are found, it uses the `difflib.get_close_matches()` function to find models that are close matches to the given `name`. It searches for up to 3 close matches with a similarity ratio of at least 0.8 (80%).

4. Finally, it returns the list of matching models found either by exact match, substring match, or close match.

This implementation allows for fuzzy matching of model names, considering both exact matches and slight misspellings.
2024-04-19 11:07:32 -07:00
Paul Gauthier
7ef10c56a2 Added a fuzzy model matching function to find models by name. 2024-04-19 11:07:31 -07:00
Paul Gauthier
7ec4de865d Added --weak-model 2024-04-19 10:57:21 -07:00
Paul Gauthier
93bd187bf3 Added --opus 2024-04-18 17:09:43 -07:00
Paul Gauthier
f960774b51 fixed test_commands 2024-04-18 15:01:02 -07:00
Paul Gauthier
f291c8f777 dropped aliases 2024-04-18 14:44:50 -07:00
Paul Gauthier
0da1b59901 Fixed up images in chat 2024-04-18 14:39:32 -07:00
Paul Gauthier
cf2a48b21f get_weak_model 2024-04-18 13:55:43 -07:00
Paul Gauthier
93f4a46996 reorg 2024-04-18 09:29:26 -07:00
JV
041f3a4a38 initial code for working with openrouter 2023-08-23 14:39:12 +12:00
Paul Gauthier
b4fe54a917 Disabled general availability of gpt-4 (it's rolling out, not 100% available yet) 2023-07-08 05:57:56 -07:00
Paul Gauthier
42977230b1 Mark gpt-4 as always_available to skip the availability check on startup 2023-07-06 17:44:12 -07:00
Paul Gauthier
d9b356de99 wip 2023-06-23 14:36:45 -07:00
Paul Gauthier
5c432592cd compute cost 2023-06-23 13:40:32 -07:00
Paul Gauthier
16a89fb5ab switch 3.5 models to use whole-func edit-format by default 2023-06-22 11:47:18 -07:00
Paul Gauthier
8820eb0399 Merge branch 'main' into edit-formats 2023-06-21 14:14:28 -07:00
Paul Gauthier
6e3738c901 Better logic to determine context window size 2023-06-21 14:10:30 -07:00
Paul Gauthier
3465bd57d1 roughed in func coder 2023-06-21 12:16:51 -07:00
Paul Gauthier
122c1c4f6c Model.use_repo_map, Model.send_undo_reply 2023-06-20 16:13:50 -07:00
Paul Gauthier
43ba638ac4 refac 2023-06-20 15:46:22 -07:00
Paul Gauthier
4d3fc3de7e Merge branch 'main' into edit-formats 2023-06-20 15:43:14 -07:00
Paul Gauthier
8fb4ab2be3 cleaned up Model init 2023-06-15 06:26:16 -07:00
Paul Gauthier
8660d35601 More flexible models 2023-06-14 17:51:17 -07:00
Paul Gauthier
8b5dcecbe2 aider: Added regex to extract tokens from name in get_model function.
# Context:
USER: use a regex to check `name` for "-XXk" and set tokens = the number XX
ASSISTANT: To use a regex to check for "-XXk" in the `name` and set `tokens` to the number XX, you can modify the `get_model` function in the `aider/models.py` file. Here's the updated code:

```python
aider/models.py
<<<<<<< ORIGINAL
def get_model(name):
    models = GPT35_models + GPT4_models

    for model in models:
        if model.name == name:
            return model

    tokens = 0

    model = Model(name, tokens)
=======
import re

def get_model(name):
    models = GPT35_models + GPT4_models

    for model in models:
        if model.name == name:
            return model

    match = re.search(r'-([0-9]+)k', name)
    tokens = int(match.group(1)) if match else 0

    model = Model(name, tokens)
>>>>>>> UPDATED
```

This change imports the `re` module and uses the `re.search()` function to find the "-XXk" pattern in the `name`. If the pattern is found, it sets `tokens` to the number XX.
2023-06-14 17:11:29 -07:00
Paul Gauthier
8c91e107e0 wip 2023-06-14 17:10:27 -07:00
Paul Gauthier
67ee800c55 refactor models to add gpt-4-32k-0613 2023-06-14 17:09:53 -07:00
Paul Gauthier
9c126210a9 Make 3.5-16k use diff 2023-06-13 13:02:26 -07:00
Paul Gauthier
21672d5231 roughed in edit-formats 2023-06-13 12:54:03 -07:00