parent
8e2b17e28a
commit
97eccb857e
@ -1,24 +1,29 @@
|
||||
import os
|
||||
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 abc import ABC, abstractmethod
|
||||
from revChatGPT.V1 import Chatbot
|
||||
|
||||
class RevChatGPTModel:
|
||||
def __init__(self, access_token=None, api_key=None, **kwargs):
|
||||
def __init__(self, access_token=None, **kwargs):
|
||||
super().__init__()
|
||||
self.config = kwargs
|
||||
if access_token:
|
||||
self.chatbot = RevChatGPTV1(config={"access_token": access_token})
|
||||
elif api_key:
|
||||
self.chatbot = RevChatGPTV3(api_key=api_key)
|
||||
self.chatbot = Chatbot(config={"access_token": access_token})
|
||||
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:
|
||||
response = ""
|
||||
self.start_time = time.time()
|
||||
prev_text = ""
|
||||
for data in self.chatbot.ask(task):
|
||||
response = data["message"]
|
||||
return response
|
||||
message = data["message"][len(prev_text):]
|
||||
prev_text = data["message"]
|
||||
self.end_time = time.time()
|
||||
return prev_text
|
||||
|
||||
def generate_summary(self, text: str) -> str:
|
||||
# Implement summary generation using RevChatGPT
|
||||
# Implement this method based on your requirements
|
||||
pass
|
||||
|
Loading…
Reference in new issue