doc: 添加注释;完善格式

This commit is contained in:
Rock Chin 2023-03-02 16:41:03 +08:00
parent fd25d61b56
commit 623f094e5b

View File

@ -17,6 +17,7 @@ IMAGE_MODELS = {
}
class Model():
can_chat = False
@ -46,7 +47,9 @@ class Model():
def get_response(self):
return self.ret
class ChatCompletionModel(Model):
"""ChatCompletion接口实现"""
def __init__(self, model_name, user_name):
request_fun = openai.ChatCompletion.create
self.can_chat = True
@ -60,7 +63,9 @@ class ChatCompletionModel(Model):
def get_content(self):
return self.message
class CompletionModel(Model):
"""Completion接口实现"""
def __init__(self, model_name, user_name):
request_fun = openai.Completion.create
super().__init__(model_name, user_name, request_fun)
@ -83,6 +88,7 @@ class CompletionModel(Model):
def get_text(self):
return self.message
def OpenaiModel(model_name:str, user_name='user'):
if model_name in CHAT_COMPLETION_MODELS:
model = ChatCompletionModel(model_name, user_name)