返回提交历史
Modified
etc/unittest/config_provider.py
+17
-0
Modified
g4f/Provider/needs_auth/GeminiCLI.py
+3
-1
Modified
g4f/providers/config_provider.py
+1
-1
XFEstudio/gpt4free
feat: Support hyphenated keys in evaluate_condition and update user quota structure
e6b5e4ad
代码差异
3 个文件
+21
-2
@@ -219,6 +219,23 @@ class TestEvaluateCondition(unittest.TestCase):
219
219
evaluate_condition("quota.credits.remaining > 0 or error_count < 3", quota, 2)
220
220
)
221
221
222
def test_quota_dashed_key(self):
223
"""Dot notation must handle hyphenated keys like gemini-3-flash-preview."""
224
quota = {
225
"models": {
226
"gemini-3-flash-preview": {
227
"remaining": 1
228
}
229
}
230
}
231
self.assertTrue(
232
evaluate_condition(
233
"quota.models.gemini-3-flash-preview.remaining > 0 or error_count < 3",
234
quota,
235
0,
236
)
237
)
238
222
239
# --- legacy aliases ---
223
240
224
241
def test_get_quota_balance_alias(self):
@@ -900,7 +900,9 @@ class GeminiCLI(AsyncGeneratorProvider, ProviderModelMixin):
900
900
if cls.auth_manager is None:
901
901
cls.auth_manager = AuthManager(env=os.environ)
902
902
provider = GeminiCLIProvider(env=os.environ, auth_manager=cls.auth_manager)
903
return await provider.retrieve_user_quota()
903
quota = await provider.retrieve_user_quota()
904
quota["models"] = {bucket.get("modelId"): bucket for bucket in quota.get("buckets", [])}
905
return quota
904
906
905
907
@classmethod
906
908
async def create_async_generator(
@@ -188,7 +188,7 @@ _TOKEN_RE = re.compile(
188
188
r"|(?P<int>-?\d+)" # integer literal
189
189
r"|(?P<op>>=|<=|==|!=|>|<)" # comparison operator
190
190
r"|(?P<kw>and|or|not)" # logical keywords
191
r"|(?P<id>[a-zA-Z_][a-zA-Z0-9_.]*)" # identifier
191
r"|(?P<id>[a-zA-Z_][a-zA-Z0-9_.-]*)" # identifier (supports dashed keys)
192
192
r"|(?P<lp>\()" # left paren
193
193
r"|(?P<rp>\))" # right paren
194
194
)