Skip to content

Commit f79d9aa

Browse files
committed
add support for openai base url
1 parent 552b5eb commit f79d9aa

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ positional arguments:
235235
options:
236236
-h, --help show this help message and exit
237237
--openai-api-key key the OpenAI API key can also be set as env variable OPENAI_API_KEY
238+
--openai-base-url key A custom url to use the openAI against a local or custom model, eg ollama
238239
--temperature t temperature (openai setting)
239240
-c CHAT_GPT, --chat-gpt CHAT_GPT
240241
chat GPT model use either the fully qualified model name, or 3.5 (gpt-3.5-turbo-0613), 4 (gpt-4), 4t (gpt-4-1106-preview). Can also be set via env variable OPENAI_API_MODEL

chatblade/chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def build_client(config):
112112
azure_deployment=os.environ.get("OPENAI_API_AZURE_ENGINE"),
113113
)
114114
else:
115-
return openai.OpenAI(api_key=config["openai_api_key"])
115+
return openai.OpenAI(api_key=config["openai_api_key"], base_url=config["openai_base_url"])
116116

117117

118118
def query_chat_gpt(messages, config):

chatblade/parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ def parse(args):
110110
type=str,
111111
help="the OpenAI API key can also be set as env variable OPENAI_API_KEY",
112112
)
113+
parser.add_argument(
114+
"--openai-base-url",
115+
metavar="key",
116+
type=str,
117+
help="A custom url to use the openAI against a local or custom model, eg ollama",
118+
)
113119
parser.add_argument(
114120
"--temperature",
115121
metavar="t",

0 commit comments

Comments
 (0)