mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-20 07:04:20 +01:00
👩🔬 refactor: rename repo
This commit is contained in:
23
dev_gpt/options/generate/static_files/microservice/apis.py
Normal file
23
dev_gpt/options/generate/static_files/microservice/apis.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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']
|
||||
Reference in New Issue
Block a user