Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/natural/debug.py
2023-09-03 16:50:12 +08:00

20 lines
540 B
Python

import sys
from pathlib import Path
import openai
from config import Config
file = Path(__file__).resolve()
parent, root = file.parent, file.parents[2]
sys.path.append(str(root))
# Load your API key from an environment variable or secret management service
openai.api_key = Config('openai_api_key')
model = Config('nl2c_model')
while True:
i = input('>> ')
response = openai.Completion.create(
model=model, prompt=f'{i}\n\n###\n\n', temperature=0, max_tokens=256, stop=['\n'])
print(response['choices'][0]['text'])