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

XFEstudio/gpt4free

Update video provider

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

代码差异

1 个文件 +17 -11
Modified g4f/Provider/needs_auth/Video.py +17 -11
@@ -49,16 +49,17 @@ class RequestConfig:
49 49 return VideoResponse(found_urls, prompt)
50 50
51 51 class Video(AsyncGeneratorProvider, ProviderModelMixin):
52 urls = [
53 "https://sora.chatgpt.com/explore",
54 #"https://aistudio.google.com/generate-video"
55 ]
52 urls = {
53 "sora": "https://sora.chatgpt.com/explore",
54 #"veo": "https://aistudio.google.com/generate-video"
55 }
56 56 api_url = f"{PUBLIC_URL}/backend-api/v2/create?provider=Video&cache=true&prompt="
57 57 drive_url = "https://www.googleapis.com/drive/v3/"
58 58
59 59 active_by_default = True
60 60 default_model = "sora"
61 video_models = [default_model]
61 models = list(urls.keys())
62 video_models = models
62 63
63 64 needs_auth = True
64 65 working = True
@@ -76,6 +77,10 @@ class Video(AsyncGeneratorProvider, ProviderModelMixin):
76 77 aspect_ratio: str = None,
77 78 **kwargs
78 79 ) -> AsyncResult:
80 if not model:
81 model = cls.default_model
82 if model not in cls.video_models:
83 raise ValueError(f"Model '{model}' is not supported by {cls.__name__}. Supported models: {cls.models}")
79 84 yield ProviderInfo(**cls.get_dict(), model="sora")
80 85 prompt = format_media_prompt(messages, prompt)
81 86 if not prompt:
@@ -106,7 +111,7 @@ class Video(AsyncGeneratorProvider, ProviderModelMixin):
106 111 raise MissingRequirementsError("Video provider requires a browser to be installed.")
107 112 try:
108 113 yield ContinueResponse("Timeout waiting for Video URL")
109 cls.page = await browser.get(random.choice(cls.urls))
114 cls.page = await browser.get(cls.urls[model])
110 115 except Exception as e:
111 116 debug.error(f"Error opening page:", e)
112 117 response = await RequestConfig.get_response(prompt)
@@ -152,11 +157,12 @@ class Video(AsyncGeneratorProvider, ProviderModelMixin):
152 157 textarea = await page.select("textarea", 180)
153 158 await textarea.send_keys(prompt)
154 159 yield Reasoning(label=f"Sending prompt", token=prompt)
155 # try:
156 # button = await page.select('button[type="submit"]', 5)
157 # if button:
158 # await button.click()
159 # finally:
160 try:
161 button = await page.select('button[type="submit"]', 5)
162 if button:
163 await button.click()
164 except Exception as e:
165 debug.error(f"Error clicking submit button:", e)
160 166 try:
161 167 button = await page.find("Create")
162 168 if button: