37 lines
854 B
Python
37 lines
854 B
Python
import os
|
|
import sys
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
import openai
|
|
from loguru import logger
|
|
|
|
from brain_base import BaseBrain
|
|
from settings.config import settings
|
|
|
|
|
|
|
|
class CloudSTTBrain:
|
|
def __init__(self):
|
|
logger.error("not implemented")
|
|
|
|
|
|
class CloudChatBrain(BaseBrain):
|
|
def __init__(self):
|
|
super().__init__()
|
|
openai.api_key = settings.OPENAI_API_KEY
|
|
|
|
def understand(self):
|
|
## BURADA TRY:EXCEPT BLOCKU GEREKİR
|
|
self.response = openai.ChatCompletion.create(
|
|
model="gpt-3.5-turbo",
|
|
temperature=0.3,
|
|
messages=[
|
|
{"role": "system", "content": self.sys_prompt},
|
|
{"role": "user", "content": self.cmd_prompt}
|
|
])
|
|
self.answer = self.response.choices[0].message.content
|
|
|
|
|
|
|
|
|