mirror of
https://github.com/SkalaraAI/management-llm.git
synced 2025-04-09 15:00:19 -04:00
29 lines
1007 B
Python
29 lines
1007 B
Python
import os
|
|
|
|
import openai
|
|
from flask import Flask, redirect, render_template, request, url_for
|
|
|
|
app = Flask(__name__)
|
|
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
@app.route("/", methods=("GET", "POST"))
|
|
def index():
|
|
if request.method == "POST":
|
|
task_form = request.form["task_form"]
|
|
response = openai.Completion.create(model="text-davinci-003",
|
|
prompt = generate_prompt(task_form),
|
|
temperature=0,
|
|
max_tokens=2048)
|
|
return redirect(url_for("index", result=response.choices[0].text))
|
|
|
|
result = request.args.get("result")
|
|
return render_template("index.html", result=result)
|
|
|
|
|
|
def generate_prompt(task_form):
|
|
base_text = "You are a software manager at the company Alphabet. Q: Format a message that specifically delegates the parts of the following task to your team of engineers."
|
|
|
|
|
|
return base_text + "TASK: " + task_form
|