-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support azure openai service (#62)
- Loading branch information
Showing
8 changed files
with
58 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import openai | ||
from bot.chatgpt import ChatGPTBot | ||
from config import conf | ||
|
||
|
||
class AzureChatGPTBot(ChatGPTBot): | ||
def __init__(self): | ||
super().__init__() | ||
openai.api_type = "azure" | ||
openai.api_version = "2023-06-01-preview" | ||
self.args["deployment_id"] = conf().get("azure_deployment_id") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from common.context import Context | ||
from config import conf | ||
from common.singleton import singleton | ||
from common.reply import Reply | ||
|
||
|
||
@singleton | ||
class Bot: | ||
def __init__(self): | ||
use_azure_chatgpt = conf().get("use_azure_chatgpt", False) | ||
if use_azure_chatgpt: | ||
from bot.azure_chatgpt import AzureChatGPTBot | ||
|
||
self.bot = AzureChatGPTBot() | ||
else: | ||
from bot.chatgpt import ChatGPTBot | ||
|
||
self.bot = ChatGPTBot() | ||
|
||
def reply(self, context: Context) -> Reply: | ||
return self.bot.reply(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters