Open onuratakan opened 6 months ago
None
)[!TIP] I can email you when I complete this pull request if you set up your email here!
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
upsonic_on_prem/utils/ai/ai.py
Modify upsonic_on_prem/utils/ai/ai.py with contents:
• At the beginning of the `AI_` class, define a dictionary named `model_usage_counter` to track the number of calls for each model. Initialize this dictionary with keys for each model (`"gemma-2b"`, `"gpt-3.5-turbo"`, `"gpt-4"`) and set their values to 0.
• In each model invocation method (`completion`, `gemmma`, `gpt`), increment the counter for the respective model in the `model_usage_counter` dictionary right before the model is called.
• After incrementing the counter, check if the count for the model is a multiple of 10. If it is, use the `debug` function from `upsonic_on_prem/utils/logs.py` to log a message indicating the model's name and how many times it has been called. The message should follow the format: `"Model [model_name] has been called [count] times."`
• Ensure that the `debug` function is properly imported from `upsonic_on_prem/utils/logs.py` if not already imported.
• This modification ensures that each time a model is called, its usage count is incremented and logged every 10 calls, fulfilling the issue's requirements without introducing unnecessary complexity.
Working on it...
💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.
This is an automated message generated by Sweep AI.
None
)[!TIP] I can email you next time I complete a pull request if you set up your email here!
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
upsonic_on_prem/utils/ai/ai.py
✓ https://github.com/Upsonic/On-Prem/commit/0ff6bccf7f6d63811f8f3f2cd008d7127713c17e Edit
Modify upsonic_on_prem/utils/ai/ai.py with contents:
• At the beginning of the `AI_` class definition, introduce a new class variable `model_call_counter` initialized as an empty dictionary. This dictionary will map model names to their respective call counts.
• In the `completion`, `gemmma`, and `gpt` methods, add logic to increment the call count for the specified model in `model_call_counter`. Use the model name as the key. If the model is not yet in the dictionary, initialize its count at 1.
• After incrementing the call count, check if the count is divisible by 10 (using the modulo operator `%`). If so, use the `debug` function (already imported from `upsonic_on_prem/utils`) to log a message indicating the model has been called 10 times. The message should include the model name and the current count.
• Example debug log message format: `debug(f"Model {model_name} has been called {count} times.")`
• Ensure that the counter increment and logging logic are correctly placed within each method to accurately reflect model usage.
--- +++ @@ -123,6 +123,10 @@ def completion(self, input_text, model): result = None + self.model_call_counter[model] = self.model_call_counter.get(model, 0) + 1 + call_count = self.model_call_counter[model] + if call_count % 10 == 0: + debug(f"Model {model} has been called {call_count} times.") if model == "gemma-2b": result = self.gemmma(input_text) elif model == "gpt-3.5-turbo": @@ -361,4 +365,6 @@ + model_call_counter = {} + AI = AI_()
upsonic_on_prem/utils/ai/ai.py
✓ Edit
Check upsonic_on_prem/utils/ai/ai.py with contents:
Ran GitHub Actions for 0ff6bccf7f6d63811f8f3f2cd008d7127713c17e:
I have finished reviewing the code for completeness. I did not find errors for sweep/make_a_counter_system_to_ai_calls_in_ups
.
💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.
This is an automated message generated by Sweep AI.
I want to track which models are using in what frequency. Make a counter and create debug log in every 10 call.
Checklist
- [X] Modify `upsonic_on_prem/utils/ai/ai.py` ✓ https://github.com/Upsonic/On-Prem/commit/0ff6bccf7f6d63811f8f3f2cd008d7127713c17e [Edit](https://github.com/Upsonic/On-Prem/edit/sweep/make_a_counter_system_to_ai_calls_in_ups/upsonic_on_prem/utils/ai/ai.py) - [X] Running GitHub Actions for `upsonic_on_prem/utils/ai/ai.py` ✓ [Edit](https://github.com/Upsonic/On-Prem/edit/sweep/make_a_counter_system_to_ai_calls_in_ups/upsonic_on_prem/utils/ai/ai.py)