Hello all,
created the fine tune model using the custom data and getting the desired results by selecting specific fine tune model from playground and by setting required parameters. Now I need to use that model for creating completions for CHATBOT. For that I am to create python flask API to which I will provide prompt from chatbot and then it will call my python flask API and it will return the specific answers likewise playground
Here is the code what I am actually trying
from dotenv import load_dotenv
from random import choice
from flask import Flask, request
# import os
import openai
import os
load_dotenv()
app = Flask(name)
#openai.api_key = os.getenv(“OPENAI_API_KEY”)
openai.api_key = “sk-*******************************************************”
openai.api_key = os.getenv(“OPENAI_API_KEY”)
@app.route(“/get_prompts”,methods = [“POST”,“GET”])
def get_prompts():
data = request.json[‘prompt’]
# a = data[‘prompt’]
if request.method == “POST”:
response = openai.Completion.create(
model=“davinci:ft-siksdbnfn”,
prompt=data,
max_tokens=50,
temperature=1,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=[" END"]
)
print(response[‘choices’][0][‘text’])
return response[‘choices’][0][‘text’]
app = Flask(name)
if name == ‘main’:
app.run(debug=True,port=5000)
Please reply ,
Thanks in advance