mirror of
https://github.com/NovaOSS/LingoSynth.git
synced 2024-11-25 22:53:57 +01:00
28 lines
612 B
Python
28 lines
612 B
Python
import os
|
|
import openai
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
import prompts
|
|
|
|
load_dotenv()
|
|
|
|
if os.getenv('OPENAI_API_BASE'):
|
|
openai.api_base = os.getenv('OPENAI_API_BASE')
|
|
openai.api_key = os.getenv('OPENAI_API_KEY')
|
|
|
|
MODEL = os.getenv('OPENAI_CHAT_MODEL') or 'gpt-3.5-turbo'
|
|
|
|
def generate(messages: str):
|
|
"""Generates a new message based on the given messages."""
|
|
|
|
return openai.ChatCompletion.create(
|
|
model=MODEL,
|
|
messages=messages,
|
|
temperature=0.9
|
|
).choices[0].message.content
|
|
|
|
if __name__ == '__main__':
|
|
print(prompts.MESSAGES)
|
|
# print(generate(prompts.MESSAGES))
|