From 731818f84ee7d6623ff2e4fdf70abe5fb78d5023 Mon Sep 17 00:00:00 2001 From: mcnamee98 <101591910+mcnamee98@users.noreply.github.com> Date: Mon, 14 Aug 2023 17:43:10 -0400 Subject: [PATCH 1/9] Sample openai app Sample app fully generated and premade using open ais sample documentation --- .idea/inspectionProfiles/Project_Default.xml | 12 ++++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 ++ .idea/modules.xml | 8 +++ .idea/openai-quickstart-python.iml | 19 ++++++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 67 +++++++++++++++++++ 7 files changed, 122 insertions(+) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/openai-quickstart-python.iml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 000000000..06bb0314d --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..105ce2da2 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..23c2fe0f4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..1191b552d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/openai-quickstart-python.iml b/.idea/openai-quickstart-python.iml new file mode 100644 index 000000000..a4e902427 --- /dev/null +++ b/.idea/openai-quickstart-python.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..94a25f7f4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000..f57a0dd8d --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1692048499691 + + + + + + \ No newline at end of file From b8abc54abcc174cf411a19453c01f18c966e8f5c Mon Sep 17 00:00:00 2001 From: mcnamee98 <101591910+mcnamee98@users.noreply.github.com> Date: Tue, 15 Aug 2023 22:30:31 -0400 Subject: [PATCH 2/9] functioning front end We now have a properly functioning front end interface integrated and embedded with open.ai 0.27.0 --- .idea/workspace.xml | 53 ++++++++++++++++++++++++++++++++++++++++++-- app.py | 32 +++++++++++++++++++++----- templates/index.html | 10 ++++++--- 3 files changed, 84 insertions(+), 11 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f57a0dd8d..624268e89 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,5 +1,8 @@ + + + + + + + + + + + + + + + + @@ -24,8 +46,12 @@ + + + + - + + + + + + + + + @@ -57,11 +103,14 @@ + + + \ No newline at end of file diff --git a/app.py b/app.py index 7b2864137..e45d68edf 100644 --- a/app.py +++ b/app.py @@ -10,13 +10,26 @@ @app.route("/", methods=("GET", "POST")) def index(): if request.method == "POST": - animal = request.form["animal"] - response = openai.Completion.create( - model="text-davinci-003", - prompt=generate_prompt(animal), - temperature=0.6, + + keywords = request.form["keywords"] + audience = request.form["audience"] + length = request.form['length'] + + completion = openai.ChatCompletion.create( + model="gpt-3.5-turbo", + messages=[ + {"role": "system", "content": "You are a helpful writing assistant." + "You will be given a handful of keywords, a target audience, and an article length." + "Please write an article which is Search Engine Optimized."}, + + {"role": "user", "content": "Keywords:" + keywords + + "Target Audience" + audience + + "Article Length" + length} + + ] ) - return redirect(url_for("index", result=response.choices[0].text)) + + return redirect(url_for("index", result=completion.choices[0].message.content)) result = request.args.get("result") return render_template("index.html", result=result) @@ -33,3 +46,10 @@ def generate_prompt(animal): Names:""".format( animal.capitalize() ) + +def gen_article(keywords, audience, length): + return """"You are a helpful writing assistant. You will be given a handful of keywords, + a target audience, and an article length. Please write the article to be Search Engine Optimized." +""".format( + audience.capitalize() + ) diff --git a/templates/index.html b/templates/index.html index 6790d6aaa..a895ad472 100644 --- a/templates/index.html +++ b/templates/index.html @@ -10,10 +10,14 @@ -

Name my pet

+

Write My SEO Optimized Article

- - + + + + + +
{% if result %}
{{ result }}
From 3539133a81cc35d04669376b416e422482f1e259 Mon Sep 17 00:00:00 2001 From: mcnamee98 <101591910+mcnamee98@users.noreply.github.com> Date: Tue, 15 Aug 2023 23:10:35 -0400 Subject: [PATCH 3/9] Dynamic formatting Implementation of dynamic html/css formatting for outputs --- .idea/workspace.xml | 2 +- app.py | 36 ++++++++++++++++++------------------ static/main.css | 8 ++++++++ templates/index.html | 43 +++++++++++++++++++++++++++++++++++-------- 4 files changed, 62 insertions(+), 27 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 624268e89..1973a9765 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -103,7 +103,7 @@