mirror of
https://github.com/father-bot/chatgpt_telegram_bot.git
synced 2026-06-13 03:54:57 +03:00
Add OpenAI API Base to config
This commit is contained in:
@@ -14,6 +14,7 @@ config_env = dotenv.dotenv_values(config_dir / "config.env")
|
||||
# config parameters
|
||||
telegram_token = config_yaml["telegram_token"]
|
||||
openai_api_key = config_yaml["openai_api_key"]
|
||||
openai_api_base = config_yaml.get("openai_api_base", None)
|
||||
allowed_telegram_usernames = config_yaml["allowed_telegram_usernames"]
|
||||
new_dialog_timeout = config_yaml["new_dialog_timeout"]
|
||||
enable_message_streaming = config_yaml.get("enable_message_streaming", True)
|
||||
|
||||
+6
-1
@@ -2,7 +2,12 @@ import config
|
||||
|
||||
import tiktoken
|
||||
import openai
|
||||
|
||||
|
||||
# setup openai
|
||||
openai.api_key = config.openai_api_key
|
||||
if config.openai_api_base is not None:
|
||||
openai.api_base = config.openai_api_base
|
||||
|
||||
|
||||
OPENAI_COMPLETION_OPTIONS = {
|
||||
@@ -151,7 +156,7 @@ class ChatGPT:
|
||||
tokens_per_name = -1 # if there's a name, the role is omitted
|
||||
elif model == "gpt-3.5-turbo":
|
||||
tokens_per_message = 4
|
||||
tokens_per_name = -1
|
||||
tokens_per_name = -1
|
||||
elif model == "gpt-4":
|
||||
tokens_per_message = 3
|
||||
tokens_per_name = 1
|
||||
|
||||
Reference in New Issue
Block a user