From 3a2702e97318397af672a597e9094e5d9955d3db Mon Sep 17 00:00:00 2001 From: Joseph Cheung Date: Thu, 2 Mar 2023 12:14:37 +0800 Subject: [PATCH] o --- searx/webapp.py | 1049 +++++++++++++++++++++++++++++++++++++++++++++- searx/webapp1.py | 36 +- 2 files changed, 1057 insertions(+), 28 deletions(-) diff --git a/searx/webapp.py b/searx/webapp.py index da3936949..9abd1127d 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -785,7 +785,7 @@ def search(): return index_error(output_format, e.message), 400 except Exception as e: # pylint: disable=broad-except logger.exception(e, exc_info=True) - return index_error(output_format, gettext('search error')), 500 + return index_error(output_format, gettext('No item found')), 500 # results results = result_container.get_ordered_results() @@ -812,11 +812,9 @@ def search(): for res in results: if 'url' not in res: continue if 'title' not in res: continue - if request.environ['HTTP_CF_IPCOUNTRY'] == 'CN' and gfw.exists(res['title']): - return index_error(output_format, 'No query'), 400 + if 'content' not in res: continue - if request.environ['HTTP_CF_IPCOUNTRY'] == 'CN' and gfw.exists(res['content']): - return index_error(output_format, 'No query'), 400 + if res['content'] == '': continue new_url = 'https://url'+str(len(url_pair)) @@ -1202,7 +1200,1046 @@ const search_type = "''' + search_type + r'''" const net_search = ''' + net_search_str + r''' diff --git a/searx/webapp1.py b/searx/webapp1.py index 11e7e1f33..9abd1127d 100644 --- a/searx/webapp1.py +++ b/searx/webapp1.py @@ -1389,11 +1389,9 @@ function modal_open(url, num) try{choices=JSON.parse(half+result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';} }catch(e){half+=result} - if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) + if(choices && choices.length>0) { - - chatTemp+=choices[0].text - text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1] + chatTemp+=choices[0].message.content } chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n") document.querySelector("#prompt").innerHTML=""; @@ -1727,11 +1725,10 @@ prev_chat = prev_chat+'
'+document.querySelector("#pro try{choices=JSON.parse(half+result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';} }catch(e){half+=result} - if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) + if(choices && choices.length>0) { - chatTemp+=choices[0].text - text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1] + chatTemp+=choices[0].message.content } chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n") document.querySelector("#prompt").innerHTML=""; @@ -1852,11 +1849,10 @@ prev_chat = prev_chat+'
'+document.querySelector("#pro try{choices=JSON.parse(half+result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';} }catch(e){half+=result} - if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) + if(choices && choices.length>0) { - chatTemp+=choices[0].text - text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1] + chatTemp+=choices[0].message.content } chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n") document.querySelector("#prompt").innerHTML=""; @@ -1944,11 +1940,10 @@ prev_chat = prev_chat+'
'+document.querySelector("#pro try{choices=JSON.parse(half+result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';} }catch(e){half+=result} - if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) + if(choices && choices.length>0) { - chatTemp+=choices[0].text - text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1] + chatTemp+=choices[0].message.content } chatTemp=chatTemp.replaceAll("\n\n","\n").replaceAll("\n\n","\n") document.querySelector("#prompt").innerHTML=""; @@ -2175,10 +2170,9 @@ fetch("https://search.kg/completions", optionsIntro) try{choices=JSON.parse(half+result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';} }catch(e){half+=result} - if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) + if(choices && choices.length>0) { - chatTextRawPlusComment+=choices[0].text - text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1] + chatTextRawPlusComment+=choices[0].message.content } markdownToHtml(beautify(chatTextRawPlusComment), document.getElementById('chat')); @@ -2199,10 +2193,9 @@ fetch("https://search.kg/completions", optionsIntro) try{choices=JSON.parse(half+result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';} }catch(e){half+=result} - if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) + if(choices && choices.length>0) { - chatTextRaw+=choices[0].text - text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1] + chatTextRaw+=choices[0].message.content } markdownToHtml(beautify(chatTextRaw), document.getElementById('chat')); @@ -2233,10 +2226,9 @@ fetch("https://search.kg/completions", optionsIntro) try{choices=JSON.parse(half+result)['choices'];half = '';} catch(e){choices=JSON.parse(result)['choices'];half = '';} }catch(e){half+=result} - if(choices && choices.length>0 && choices[0].logprobs.text_offset[0] > text_offset) + if(choices && choices.length>0) { - chatTextRawIntro+=choices[0].text - text_offset = choices[0].logprobs.text_offset[choices[0].logprobs.text_offset.length - 1] + chatTextRawIntro+=choices[0].message.content } markdownToHtml(beautify(chatTextRawIntro+'\n'), document.getElementById('chat_intro'));