parent
b8a4963807
commit
c657db6f19
@ -1,24 +1,29 @@
|
|||||||
import os
|
import os
|
||||||
import revChatGPT
|
import revChatGPT
|
||||||
from revChatGPT.V1 import Chatbot as RevChatGPTV1
|
from revChatGPT.V1 import Chatbot as RevChatGPTV1, time
|
||||||
from revChatGPT.V3 import Chatbot as RevChatGPTV3
|
from revChatGPT.V3 import Chatbot as RevChatGPTV3
|
||||||
|
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from revChatGPT.V1 import Chatbot
|
||||||
|
|
||||||
class RevChatGPTModel:
|
class RevChatGPTModel:
|
||||||
def __init__(self, access_token=None, api_key=None, **kwargs):
|
def __init__(self, access_token=None, **kwargs):
|
||||||
|
super().__init__()
|
||||||
self.config = kwargs
|
self.config = kwargs
|
||||||
if access_token:
|
if access_token:
|
||||||
self.chatbot = RevChatGPTV1(config={"access_token": access_token})
|
self.chatbot = Chatbot(config={"access_token": access_token})
|
||||||
elif api_key:
|
|
||||||
self.chatbot = RevChatGPTV3(api_key=api_key)
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Either access_token or api_key must be provided.")
|
raise ValueError("access_token must be provided.")
|
||||||
|
|
||||||
def run(self, task: str) -> str:
|
def run(self, task: str) -> str:
|
||||||
response = ""
|
self.start_time = time.time()
|
||||||
|
prev_text = ""
|
||||||
for data in self.chatbot.ask(task):
|
for data in self.chatbot.ask(task):
|
||||||
response = data["message"]
|
message = data["message"][len(prev_text):]
|
||||||
return response
|
prev_text = data["message"]
|
||||||
|
self.end_time = time.time()
|
||||||
|
return prev_text
|
||||||
|
|
||||||
def generate_summary(self, text: str) -> str:
|
def generate_summary(self, text: str) -> str:
|
||||||
# Implement summary generation using RevChatGPT
|
# Implement this method based on your requirements
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in new issue