mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-21 07:34:20 +01:00
refactor: adjust structure
This commit is contained in:
27
src/gpt.py
Normal file
27
src/gpt.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import os
|
||||
|
||||
import openai
|
||||
|
||||
openai.api_key = os.environ['OPENAI_API_KEY']
|
||||
|
||||
def get_response(system_definition, user_query):
|
||||
response = openai.ChatCompletion.create(
|
||||
temperature=0,
|
||||
model="gpt-4",
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": system_definition
|
||||
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content":
|
||||
user_query
|
||||
},
|
||||
|
||||
]
|
||||
)
|
||||
content = response['choices'][0]['message']['content']
|
||||
print(content)
|
||||
return content
|
||||
Reference in New Issue
Block a user