Skip to content

Commit

Permalink
Add support for gpt-3.5-turbo-1106 model. Change the default model fo…
Browse files Browse the repository at this point in the history
…r search to gpt-3.5-turbo-1106. update g4f version to 0.1.8.0
  • Loading branch information
yym68686 committed Nov 7, 2023
1 parent 0a7a865 commit edcd22f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
29 changes: 17 additions & 12 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,29 @@ async def delete_message(update, context, messageid, delay=10):
InlineKeyboardButton("gpt-3.5-turbo-16k", callback_data="gpt-3.5-turbo-16k"),
],
[
InlineKeyboardButton("gpt-3.5-turbo-0301", callback_data="gpt-3.5-turbo-0301"),
],
[
InlineKeyboardButton("gpt-3.5-turbo-0613", callback_data="gpt-3.5-turbo-0613"),
InlineKeyboardButton("gpt-3.5-turbo-1106", callback_data="gpt-3.5-turbo-1106"),
],
# [
# InlineKeyboardButton("gpt-3.5-turbo-0301", callback_data="gpt-3.5-turbo-0301"),
# ],
# [
# InlineKeyboardButton("gpt-3.5-turbo-0613", callback_data="gpt-3.5-turbo-0613"),
# ],
[
InlineKeyboardButton("gpt-4", callback_data="gpt-4"),
InlineKeyboardButton("gpt-4-0314", callback_data="gpt-4-0314"),
],
[
InlineKeyboardButton("gpt-4-32k", callback_data="gpt-4-32k"),
InlineKeyboardButton("gpt-4-32k-0314", callback_data="gpt-4-32k-0314"),
],
[
InlineKeyboardButton("gpt-4-0613", callback_data="gpt-4-0613"),
InlineKeyboardButton("gpt-4-32k-0613", callback_data="gpt-4-32k-0613"),
# InlineKeyboardButton("gpt-4-0314", callback_data="gpt-4-0314"),
],
# [
# InlineKeyboardButton("gpt-4-32k", callback_data="gpt-4-32k"),
# InlineKeyboardButton("gpt-4-32k-0314", callback_data="gpt-4-32k-0314"),
# ],
# [
# InlineKeyboardButton("gpt-4-0613", callback_data="gpt-4-0613"),
# InlineKeyboardButton("gpt-4-32k-0613", callback_data="gpt-4-32k-0613"),
# ],
[
InlineKeyboardButton("claude-2", callback_data="claude-2"),
InlineKeyboardButton("claude-2-web", callback_data="claude-2-web"),
],
[
Expand Down
11 changes: 7 additions & 4 deletions chatgpt2api/chatgpt2api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def get_filtered_keys_from_object(obj: object, *keys: str) -> Set[str]:
"gpt-3.5-turbo-16k",
"gpt-3.5-turbo-0301",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-1106",
"gpt-3.5-turbo-16k-0613",
"gpt-4",
"gpt-4-0314",
Expand All @@ -49,6 +50,7 @@ def get_filtered_keys_from_object(obj: object, *keys: str) -> Set[str]:
"gpt-4-0613",
"gpt-4-32k-0613",
"claude-2-web",
"claude-2",
]


Expand Down Expand Up @@ -84,9 +86,9 @@ def __init__(
else 7000
if "gpt-4" in engine
else 15000
if "gpt-3.5-turbo-16k" in engine
if "gpt-3.5-turbo-16k" in engine or "gpt-3.5-turbo-1106" in engine
else 99000
if "claude-2-web" in engine
if "claude-2-web" in engine or "claude-2" in engine
else 4000
)
self.truncate_limit: int = truncate_limit or (
Expand All @@ -95,9 +97,9 @@ def __init__(
else 6500
if "gpt-4" in engine
else 14500
if "gpt-3.5-turbo-16k" in engine
if "gpt-3.5-turbo-16k" in engine or "gpt-3.5-turbo-1106" in engine
else 98500
if "claude-2-web" in engine
if "claude-2-web" in engine or "claude-2" in engine
else 3400
)
self.temperature: float = temperature
Expand Down Expand Up @@ -178,6 +180,7 @@ def get_token_count(self, convo_id: str = "default") -> int:
)
tiktoken.model.MODEL_TO_ENCODING["gpt-4"] = "cl100k_base"
tiktoken.model.MODEL_TO_ENCODING["claude-2-web"] = "cl100k_base"
tiktoken.model.MODEL_TO_ENCODING["claude-2"] = "cl100k_base"

encoding = tiktoken.encoding_for_model(self.engine)

Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if os.environ.get('GOOGLE_API_KEY', None) == None and os.environ.get('GOOGLE_CSE_ID', None) == None:
USE_GOOGLE = False
temperature = float(os.environ.get('temperature', '0.5'))
GPT_ENGINE = os.environ.get('GPT_ENGINE', 'gpt-3.5-turbo-16k')
GPT_ENGINE = os.environ.get('GPT_ENGINE', 'gpt-3.5-turbo-1106')
# DEFAULT_SEARCH_MODEL = os.environ.get('DEFAULT_SEARCH_MODEL', 'gpt-3.5-turbo-16k')
SEARCH_USE_GPT = (os.environ.get('SEARCH_USE_GPT', "True") == "False") == False
API_URL = os.environ.get('API_URL', 'https://api.openai.com/v1/chat/completions')
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ unstructured[pdf]
duckduckgo-search==3.8.5
langchain==0.0.271
oauth2client==3.0.0
g4f==0.1.7.9
g4f==0.1.8.0
15 changes: 15 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,18 @@

content_list = [item["content"] for item in my_list]
print(content_list)

engine = "gpt-3.5-turbo-1106"
truncate_limit = (
30500
if "gpt-4-32k" in engine
else 6500
if "gpt-4" in engine
else 14500
if "gpt-3.5-turbo-16k" in engine or "gpt-3.5-turbo-1106" in engine
else 98500
if ("claude-2-web" or "claude-2") in engine
else 3400
)

print(truncate_limit)
1 change: 1 addition & 0 deletions test/test_Faucet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ def gptsearch(result, llm):
response = response.content
return response

chainllm = ChatOpenAI(temperature=0.5, openai_api_base="https://openkey.cloud/v1", model_name="gpt-4", openai_api_key="sk-ucUnnmqI9DdtsAXG8OKxOFxD5dnSrU3E3ZQh4PJa1dgQ7KzE")

print(gptsearch("鲁迅和周树人为什么打架", chainllm))

0 comments on commit edcd22f

Please sign in to comment.