This code errors:
from replit.ai.modelfarm import ChatModel, ChatSession, ChatMessage, ChatModelResponse
chatSessions = {}
chatModel: ChatModel = ChatModel('chat-bison')
def newChatSession(UserData: dict):
nChatSession: ChatSession = ChatSession(
context=f"You are an AI chatbot that speaks with {UserData['DisplayName']} (@{UserData['UserName']} on YouTube), You need to make sure you follow YouTube's terms of service and not speak about anything that breaks it. But basically, You are a normal AI chatbot.",
examples=[],
messages=[]
)
chatSessions[UserData['UserID']] = nChatSession
def chat(message: str, UserData: dict):
nChatMsg = ChatMessage(
author=f"{UserData['DisplayName']} (@{UserData['UserName']})",
content=message
)
chatSessions[UserData['UserID']].messages.append(nChatMsg)
response = chatModel.chat([chatSessions[UserData['UserID']]], max_output_tokens=50)
return response
exampleUserData = {
"DisplayName": "Matan",
"UserName": "abdfuhfhfffv123",
"UserID": 923
}
newChatSession(exampleUserData)
while True:
askMessage = input("What are you going to ask me? ")
response = chat(askMessage, exampleUserData)
print(response)
error:
Traceback (most recent call last):
File "main.py", line 30, in <module>
response = chat(askMessage, exampleUserData)
File "main.py", line 20, in chat
response = chatModel.chat([chatSessions[UserData['UserID']]], max_output_tokens=50)
File "/home/runner/Untitled-AI-Project/venv/lib/python3.10/site-packages/replit/ai/modelfarm/chat_model.py", line 53, in chat
self._check_response(response)
File "/home/runner/Untitled-AI-Project/venv/lib/python3.10/site-packages/replit/ai/modelfarm/model.py", line 57, in _check_response
raise InvalidResponseException(rjson["detail"])
Library: replit-ai (Replit Docs)