Skip to content

Commit

Permalink
1. Fixed bug: 'ThreadWithReturnValue' object has no attribute '_return'.
Browse files Browse the repository at this point in the history
2. Reduced the search context of gpt-4-1106-preview to 16000 tokens
  • Loading branch information
yym68686 committed Nov 14, 2023
1 parent 7275b95 commit 7a742a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chatgpt2api/chatgpt2api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down
2 changes: 2 additions & 0 deletions utils/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7a742a0

Please sign in to comment.