diff --git a/chatgpt2api/chatgpt2api.py b/chatgpt2api/chatgpt2api.py index e467f3a3..af701181 100644 --- a/chatgpt2api/chatgpt2api.py +++ b/chatgpt2api/chatgpt2api.py @@ -98,7 +98,7 @@ def __init__( if "gpt-3.5-turbo-16k" in engine else 98500 if "claude-2-web" in engine - else 3500 + else 3400 ) self.temperature: float = temperature self.top_p: float = top_p @@ -520,11 +520,11 @@ def search_summary( encode_text = encoding.encode(useful_source_text) encode_fact_text = encoding.encode(fact_text) - if len(encode_text) > self.max_tokens: - encode_text = encode_text[:self.max_tokens-len(encode_fact_text)] + if len(encode_text) > self.truncate_limit: + encode_text = encode_text[:self.truncate_limit-len(encode_fact_text)] useful_source_text = encoding.decode(encode_text) encode_text = encoding.encode(useful_source_text) - tokens_len = len(encode_text) + search_tokens_len = len(encode_text) print("web search", useful_source_text, end="\n\n") print(url_set_list) @@ -532,8 +532,10 @@ def search_summary( if config.USE_GOOGLE: print("google search keyword", keyword) print(f"搜索用时:{run_time}秒") - print("tokens_len", tokens_len) + print("search tokens len", search_tokens_len) useful_source_text = useful_source_text + "\n\n" + fact_text + text_len = len(encoding.encode(useful_source_text)) + print("text len", text_len) summary_prompt = PromptTemplate( input_variables=["web_summary", "question"], template=( diff --git a/requirements.txt b/requirements.txt index 8406a89f..7cc7e499 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,4 +16,4 @@ unstructured[pdf] duckduckgo-search==3.8.5 langchain==0.0.271 oauth2client==3.0.0 -g4f==0.1.7.7 \ No newline at end of file +g4f==0.1.7.9 \ No newline at end of file