-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove webview js api, Add unittest for provider has model, Use cooki… (
#2470) * Remove webview js api, Add unittest for provider has model, Use cookies dir for cache
- Loading branch information
Showing
18 changed files
with
63 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import unittest | ||
from typing import Type | ||
import asyncio | ||
|
||
from g4f.models import __models__ | ||
from g4f.providers.base_provider import BaseProvider, ProviderModelMixin | ||
from g4f.models import Model | ||
|
||
class TestProviderHasModel(unittest.IsolatedAsyncioTestCase): | ||
cache: dict = {} | ||
|
||
async def test_provider_has_model(self): | ||
for model, providers in __models__.values(): | ||
for provider in providers: | ||
if issubclass(provider, ProviderModelMixin): | ||
if model.name not in provider.model_aliases: | ||
await asyncio.wait_for(self.provider_has_model(provider, model), 10) | ||
|
||
async def provider_has_model(self, provider: Type[BaseProvider], model: Model): | ||
if provider.__name__ not in self.cache: | ||
self.cache[provider.__name__] = provider.get_models() | ||
if self.cache[provider.__name__]: | ||
self.assertIn(model.name, self.cache[provider.__name__], provider.__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.