mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-20 07:04:20 +01:00
24 lines
556 B
Python
24 lines
556 B
Python
import os
|
|
import openai
|
|
|
|
|
|
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
class GPT_3_5_Turbo:
|
|
def __init__(self, system: str = ''):
|
|
self.system = system
|
|
|
|
def __call__(self, prompt: str) -> str:
|
|
response = openai.ChatCompletion.create(
|
|
model="gpt-3.5-turbo",
|
|
messages=[{
|
|
"role": 'system',
|
|
"content": self.system
|
|
}, {
|
|
"role": 'user',
|
|
"content": prompt
|
|
}]
|
|
)
|
|
return response.choices[0]['message']['content']
|