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

XFEstudio/gpt4free

Support options like max_depth in downloads.json Add created buckets automatic to messages Don't add images to scrape result without title

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

代码差异

4 个文件 +35 -16
Modified g4f/gui/client/static/img/site.webmanifest +3 -1
@@ -21,7 +21,9 @@
21 21 "method": "GET",
22 22 "enctype": "application/x-www-form-urlencoded",
23 23 "params": {
24 "title": "prompt"
24 "title": "title",
25 "text": "prompt",
26 "url": "url"
25 27 }
26 28 }
27 29 }
Modified g4f/gui/client/static/js/chat.v1.js +22 -8
@@ -792,7 +792,7 @@ function is_stopped() {
792 792 const ask_gpt = async (message_id, message_index = -1, regenerate = false, provider = null, model = null, action = null) => {
793 793 if (!model && !provider) {
794 794 model = get_selected_model()?.value || null;
795 provider = providerSelect.options[providerSelect.selectedIndex].value;
795 provider = providerSelect.options[providerSelect.selectedIndex]?.value;
796 796 }
797 797 let conversation = await get_conversation(window.conversation_id);
798 798 if (!conversation) {
@@ -1815,8 +1815,14 @@ async function on_load() {
1815 1815 let chat_url = new URL(window.location.href)
1816 1816 let chat_params = new URLSearchParams(chat_url.search);
1817 1817 if (chat_params.get("prompt")) {
1818 messageInput.value = chat_params.get("prompt");
1819 await handle_ask();
1818 messageInput.value = chat_params.title
1819 + chat_params.title ? "\n\n\n" : ""
1820 + chat_params.prompt
1821 + chat_params.prompt && chat_params.url ? "\n\n\n" : ""
1822 + chat_params.url;
1823 messageInput.style.height = messageInput.scrollHeight + "px";
1824 messageInput.focus();
1825 //await handle_ask();
1820 1826 } else {
1821 1827 say_hello()
1822 1828 }
@@ -1871,7 +1877,6 @@ async function on_api() {
1871 1877 setTimeout(()=>prompt_lock=false, 3000);
1872 1878 await handle_ask();
1873 1879 } else {
1874 messageInput.style.removeProperty("height");
1875 1880 messageInput.style.height = messageInput.scrollHeight + "px";
1876 1881 }
1877 1882 });
@@ -1970,7 +1975,11 @@ async function on_api() {
1970 1975 provider_options[provider.name] = option;
1971 1976 }
1972 1977 });
1978 }
1979 if (appStorage.getItem("provider")) {
1973 1980 await load_provider_models(appStorage.getItem("provider"))
1981 } else {
1982 providerSelect.selectedIndex = 0;
1974 1983 }
1975 1984 for (let [name, [label, login_url, childs]] of Object.entries(login_urls)) {
1976 1985 if (!login_url && !is_demo) {
@@ -1990,7 +1999,7 @@ async function on_api() {
1990 1999 }
1991 2000
1992 2001 register_settings_storage();
1993 await load_settings_storage()
2002 await load_settings_storage();
1994 2003 Object.entries(provider_options).forEach(
1995 2004 ([provider_name, option]) => load_provider_option(option.querySelector("input"), provider_name)
1996 2005 );
@@ -2156,9 +2165,14 @@ async function upload_files(fileInput) {
2156 2165 }
2157 2166 appStorage.setItem(`bucket:${bucket_id}`, data.size);
2158 2167 inputCount.innerText = "Files are loaded successfully";
2159 messageInput.value += (messageInput.value ? "\n" : "") + JSON.stringify({bucket_id: bucket_id}) + "\n";
2160 paperclip.classList.remove("blink");
2161 fileInput.value = "";
2168 if (!messageInput.value) {
2169 messageInput.value = JSON.stringify({bucket_id: bucket_id});
2170 handle_ask(false);
2171 } else {
2172 messageInput.value += (messageInput.value ? "\n" : "") + JSON.stringify({bucket_id: bucket_id}) + "\n";
2173 paperclip.classList.remove("blink");
2174 fileInput.value = "";
2175 }
2162 2176 }
2163 2177 };
2164 2178 eventSource.onerror = (event) => {
Modified g4f/tools/files.py +9 -6
@@ -481,18 +481,21 @@ def get_downloads_urls(bucket_dir: Path, delete_files: bool = False) -> Iterator
481 481 if isinstance(data, list):
482 482 for item in data:
483 483 if "url" in item:
484 yield item["url"]
484 yield {"urls": [item.pop("url")], **item}
485 elif "urls" in item:
486 yield item
485 487
486 488 def read_and_download_urls(bucket_dir: Path, event_stream: bool = False) -> Iterator[str]:
487 489 urls = get_downloads_urls(bucket_dir)
488 490 if urls:
489 491 count = 0
490 492 with open(os.path.join(bucket_dir, FILE_LIST), 'a') as f:
491 for filename in to_sync_generator(download_urls(bucket_dir, urls)):
492 f.write(f"{filename}\n")
493 if event_stream:
494 count += 1
495 yield f'data: {json.dumps({"action": "download", "count": count})}\n\n'
493 for url in urls:
494 for filename in to_sync_generator(download_urls(bucket_dir, **url)):
495 f.write(f"{filename}\n")
496 if event_stream:
497 count += 1
498 yield f'data: {json.dumps({"action": "download", "count": count})}\n\n'
496 499
497 500 async def async_read_and_download_urls(bucket_dir: Path, event_stream: bool = False) -> AsyncIterator[str]:
498 501 urls = get_downloads_urls(bucket_dir)
Modified g4f/tools/web_search.py +1 -1
@@ -96,7 +96,7 @@ def scrape_text(html: str, max_words: int = None, add_source=True, count_images:
96 96 if count_images > 0:
97 97 image = paragraph.select_one(image_select)
98 98 if image:
99 title = paragraph.get("title") or paragraph.text
99 title = str(paragraph.get("title", paragraph.text))
100 100 if title:
101 101 yield f"!{format_link(image['src'], title)}\n"
102 102 if max_words is not None: