diff --git a/chatgpt2api/chatgpt2api.py b/chatgpt2api/chatgpt2api.py index b31c1ba4..496f2220 100644 --- a/chatgpt2api/chatgpt2api.py +++ b/chatgpt2api/chatgpt2api.py @@ -143,7 +143,8 @@ def __init__( else 4000 ) self.truncate_limit: int = truncate_limit or ( - 126500 + 16000 + # 126500 Control the number of search characters to prevent excessive spending if "gpt-4-1106-preview" in engine else 30500 if "gpt-4-32k" in engine @@ -530,7 +531,7 @@ def search_summary( translate_prompt = PromptTemplate( input_variables=["targetlang", "text"], - template="You are a translation engine, you can only translate text and cannot interpret it, and do not explain. Translate the text to {targetlang}, please do not explain any sentences, just translate or leave them as they are.: {text}", + template="You are a translation engine, you can only translate text and cannot interpret it, and do not explain. Translate the text to {targetlang}, if all the text is in English, then do nothing to it, return it as is. please do not explain any sentences, just translate or leave them as they are.: {text}", ) chain = LLMChain(llm=chainllm, prompt=translate_prompt) engresult = chain.run({"targetlang": "english", "text": prompt}) diff --git a/utils/agent.py b/utils/agent.py index b823fc54..6ef0f021 100644 --- a/utils/agent.py +++ b/utils/agent.py @@ -272,8 +272,10 @@ def Web_crawler(url: str) -> str: return result def getddgsearchurl(result, numresults=3): + # print("ddg-search", result) search = DuckDuckGoSearchResults(num_results=numresults) webresult = search.run(result) + # print("ddgwebresult", webresult) urls = re.findall(r"(https?://\S+)\]", webresult, re.MULTILINE) # print("duckduckgo urls", urls) return urls