Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	联网搜索问题
Browse files
    	
        crazy_functions/crazy_functions_test.py
    CHANGED
    
    | 
         @@ -12,7 +12,7 @@ def validate_path(): 
     | 
|
| 12 | 
         
             
                sys.path.append(root_dir_assume)
         
     | 
| 13 | 
         | 
| 14 | 
         
             
            validate_path() # validate path so you can run from base directory
         
     | 
| 15 | 
         
            -
             
     | 
| 16 | 
         
             
            from toolbox import get_conf, ChatBotWithCookies
         
     | 
| 17 | 
         
             
            proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, CHATBOT_HEIGHT, LAYOUT, API_KEY = \
         
     | 
| 18 | 
         
             
                get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT', 'LAYOUT', 'API_KEY')
         
     | 
| 
         @@ -81,9 +81,15 @@ def test_下载arxiv论文并翻译摘要(): 
     | 
|
| 81 | 
         | 
| 82 | 
         
             
            def test_联网回答问题():
         
     | 
| 83 | 
         
             
                from crazy_functions.联网的ChatGPT import 连接网络回答问题
         
     | 
| 84 | 
         
            -
                txt = "“我们称之为高效”是什么梗?"
         
     | 
| 85 | 
         
            -
                 
     | 
| 86 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 87 | 
         | 
| 88 | 
         
             
            # test_解析一个Python项目()
         
     | 
| 89 | 
         
             
            # test_Latex英文润色()
         
     | 
| 
         | 
|
| 12 | 
         
             
                sys.path.append(root_dir_assume)
         
     | 
| 13 | 
         | 
| 14 | 
         
             
            validate_path() # validate path so you can run from base directory
         
     | 
| 15 | 
         
            +
            from colorful import *
         
     | 
| 16 | 
         
             
            from toolbox import get_conf, ChatBotWithCookies
         
     | 
| 17 | 
         
             
            proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, CHATBOT_HEIGHT, LAYOUT, API_KEY = \
         
     | 
| 18 | 
         
             
                get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT', 'LAYOUT', 'API_KEY')
         
     | 
| 
         | 
|
| 81 | 
         | 
| 82 | 
         
             
            def test_联网回答问题():
         
     | 
| 83 | 
         
             
                from crazy_functions.联网的ChatGPT import 连接网络回答问题
         
     | 
| 84 | 
         
            +
                # txt = "“我们称之为高效”是什么梗?"               #   
         
     | 
| 85 | 
         
            +
                # txt = "为什么说枪毙P社玩家没有一个冤枉的?"       #  
         
     | 
| 86 | 
         
            +
                # txt = "谁是应急食品?"                          #  '根据以上搜索结果可以得知,应急食品是“原神”游戏中的角色派蒙的外号。'
         
     | 
| 87 | 
         
            +
                # txt = "道路千万条,安全第一条。后面两句是?"      #  '行车不规范,亲人两行泪。'
         
     | 
| 88 | 
         
            +
                # txt = "特朗普为什么被捕了?"                    #  特朗普涉嫌向一名色情片女星付“封口费”,因此被刑事起诉,随后前往纽约市出庭受审。在不同的搜索结果中,可能会有不同的具体描述和表述方式。
         
     | 
| 89 | 
         
            +
                # txt = "丁仪砸了水滴之后发生了什么?"             # 丁仪用地质锤砸烂了水滴,这个行为让三体智子和其他观众们感到震惊和不解。在第1份搜索结果中,作者吐槽了一个脑洞——丁仪的破解方法是通过修炼、悟道和掌握一种新的“道”,称为“丁仪化身宇宙之道,可以轻易出现在宇宙的任何一个地方,.............
         
     | 
| 90 | 
         
            +
                txt = "What is in the canister?"                # 根据搜索结果并没有找到与 Rainbow Six Siege 游戏中 Smoke 的 Canister 中装有何种物质相关的官方信息。
         
     | 
| 91 | 
         
            +
                for cookies, cb, hist, msg in 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): print(cb)
         
     | 
| 92 | 
         
            +
                for i, it in enumerate(cb): print亮蓝(it[0]); print亮黄(it[1])
         
     | 
| 93 | 
         | 
| 94 | 
         
             
            # test_解析一个Python项目()
         
     | 
| 95 | 
         
             
            # test_Latex英文润色()
         
     | 
    	
        crazy_functions/联网的ChatGPT.py
    CHANGED
    
    | 
         @@ -70,14 +70,14 @@ def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, s 
     | 
|
| 70 | 
         
             
                history = []
         
     | 
| 71 | 
         | 
| 72 | 
         
             
                # ------------- < 第2步:依次访问网页 > -------------
         
     | 
| 73 | 
         
            -
                max_search_result =  
     | 
| 74 | 
         
             
                for index, url in enumerate(urls[:max_search_result]):
         
     | 
| 75 | 
         
             
                    res = scrape_text(url['link'], proxies)
         
     | 
| 76 | 
         
            -
                    history.extend([f"第{index} 
     | 
| 77 | 
         
            -
                    chatbot.append([f"第{index} 
     | 
| 78 | 
         
             
                    yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
         
     | 
| 79 | 
         | 
| 80 | 
         
            -
                # ------------- < 第3 
     | 
| 81 | 
         
             
                i_say = f"从以上搜索结果中抽取信息,然后回答问题:{txt}"
         
     | 
| 82 | 
         
             
                i_say, history = input_clipping(inputs=i_say, history=history, max_token_limit=model_info[llm_kwargs['llm_model']]['max_token']//2)
         
     | 
| 83 | 
         
             
                gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
         
     | 
| 
         | 
|
| 70 | 
         
             
                history = []
         
     | 
| 71 | 
         | 
| 72 | 
         
             
                # ------------- < 第2步:依次访问网页 > -------------
         
     | 
| 73 | 
         
            +
                max_search_result = 4   # 最多收纳多少个网页的结果
         
     | 
| 74 | 
         
             
                for index, url in enumerate(urls[:max_search_result]):
         
     | 
| 75 | 
         
             
                    res = scrape_text(url['link'], proxies)
         
     | 
| 76 | 
         
            +
                    history.extend([f"第{index}份搜索结果:", res])
         
     | 
| 77 | 
         
            +
                    chatbot.append([f"第{index}份搜索结果:", res[:500]])
         
     | 
| 78 | 
         
             
                    yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
         
     | 
| 79 | 
         | 
| 80 | 
         
            +
                # ------------- < 第3步:ChatGPT综合 > -------------
         
     | 
| 81 | 
         
             
                i_say = f"从以上搜索结果中抽取信息,然后回答问题:{txt}"
         
     | 
| 82 | 
         
             
                i_say, history = input_clipping(inputs=i_say, history=history, max_token_limit=model_info[llm_kwargs['llm_model']]['max_token']//2)
         
     | 
| 83 | 
         
             
                gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
         
     |