XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

fix: Update reasoning statuses in ThinkingProcessor tests

- Modified `TestThinkingProcessor` unit tests in `thinking.py` to update expected results for reasoning statuses: - Changed `"Finished"` status to `""` in `test_thinking_end`, `test_thinking_start_and_end`, and `test_chunk_with_text_after_think`. feat: Add model aliases to HuggingFaceMedia provider - Imported `model_aliases` from `.models` in `HuggingFaceMedia.py`. - Added `model_aliases` attribute to `HuggingFaceMedia` provider class. feat: Add timeout argument to CLI API parser - Introduced `--timeout` argument in `get_api_parser()` in `cli.py` with default value of `600` seconds. - Passed `timeout` argument to `run_api_args()` function. ```

f5bd41c5
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

3 个文件 +8 -4
Modified etc/unittest/thinking.py +3 -3
@@ -31,7 +31,7 @@ class TestThinkingProcessor(unittest.TestCase):
31 31 def test_thinking_end(self):
32 32 start_time = time.time()
33 33 chunk = "token</think> content after"
34 expected_result = [Reasoning("token"), Reasoning(status="Finished", is_thinking="</think>"), " content after"]
34 expected_result = [Reasoning("token"), Reasoning(status="", is_thinking="</think>"), " content after"]
35 35 actual_time, actual_result = ThinkingProcessor.process_thinking_chunk(chunk, start_time)
36 36 self.assertEqual(actual_time, 0)
37 37 self.assertEqualReasoning(actual_result[0], expected_result[0])
@@ -41,7 +41,7 @@ class TestThinkingProcessor(unittest.TestCase):
41 41 def test_thinking_start_and_end(self):
42 42 start_time = time.time()
43 43 chunk = "<think>token</think> content after"
44 expected_result = [Reasoning(status="🤔 Is thinking...", is_thinking="<think>"), Reasoning("token"), Reasoning(status="Finished", is_thinking="</think>"), " content after"]
44 expected_result = [Reasoning(status="🤔 Is thinking...", is_thinking="<think>"), Reasoning("token"), Reasoning(status="", is_thinking="</think>"), " content after"]
45 45 actual_time, actual_result = ThinkingProcessor.process_thinking_chunk(chunk, start_time)
46 46 self.assertEqual(actual_time, 0)
47 47 self.assertEqualReasoning(actual_result[0], expected_result[0])
@@ -60,7 +60,7 @@ class TestThinkingProcessor(unittest.TestCase):
60 60 def test_chunk_with_text_after_think(self):
61 61 chunk = "Start <think>Middle</think>End"
62 62 expected_time = 0
63 expected_result = ["Start ", Reasoning(status="🤔 Is thinking...", is_thinking="<think>"), Reasoning("Middle"), Reasoning(status="Finished", is_thinking="</think>"), "End"]
63 expected_result = ["Start ", Reasoning(status="🤔 Is thinking...", is_thinking="<think>"), Reasoning("Middle"), Reasoning(status="", is_thinking="</think>"), "End"]
64 64 actual_time, actual_result = ThinkingProcessor.process_thinking_chunk(chunk)
65 65 self.assertEqual(actual_time, expected_time)
66 66 for i in range(1, len(expected_result)):
Modified g4f/Provider/needs_auth/hf/HuggingFaceMedia.py +3 -0
@@ -14,6 +14,7 @@ from ....providers.response import ProviderInfo, ImageResponse, VideoResponse, R
14 14 from ....image.copy_images import save_response_media
15 15 from ....image import use_aspect_ratio
16 16 from .... import debug
17 from .models import model_aliases
17 18
18 19 class HuggingFaceMedia(AsyncGeneratorProvider, ProviderModelMixin):
19 20 label = "HuggingFace"
@@ -22,6 +23,8 @@ class HuggingFaceMedia(AsyncGeneratorProvider, ProviderModelMixin):
22 23 working = True
23 24 needs_auth = True
24 25
26 model_aliases = model_aliases
27
25 28 tasks = ["text-to-image", "text-to-video"]
26 29 provider_mapping: dict[str, dict] = {}
27 30 task_mapping: dict[str, str] = {}
Modified g4f/cli.py +2 -1
@@ -29,7 +29,7 @@ def get_api_parser():
29 29 default=[], help="List of browsers to access or retrieve cookies from. (incompatible with --reload and --workers)")
30 30 api_parser.add_argument("--reload", action="store_true", help="Enable reloading.")
31 31 api_parser.add_argument("--demo", action="store_true", help="Enable demo mode.")
32
32 api_parser.add_argument("--timeout", type=int, default=600, help="Default timeout for requests in seconds. (incompatible with --reload and --workers)")
33 33 api_parser.add_argument("--ssl-keyfile", type=str, default=None, help="Path to SSL key file for HTTPS.")
34 34 api_parser.add_argument("--ssl-certfile", type=str, default=None, help="Path to SSL certificate file for HTTPS.")
35 35 api_parser.add_argument("--log-config", type=str, default=None, help="Custom log config.")
@@ -64,6 +64,7 @@ def run_api_args(args):
64 64 model=args.model,
65 65 gui=args.gui,
66 66 demo=args.demo,
67 timeout=args.timeout,
67 68 )
68 69 if args.cookie_browsers:
69 70 g4f.cookies.browsers = [g4f.cookies[browser] for browser in args.cookie_browsers]