Dede16 commited on
Commit
a9d4bbe
·
1 Parent(s): 36d936c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -4,7 +4,7 @@ from selenium import webdriver
4
  from selenium.webdriver.common.by import By
5
  from selenium.webdriver.common.keys import Keys
6
  from selenium.common.exceptions import WebDriverException
7
- from openai import OpenAI
8
  import time
9
  import re
10
  import replicate
@@ -27,7 +27,6 @@ from huggingface_hub import (
27
  upload_file,
28
  )
29
  logs = []
30
- client = OpenAI()
31
 
32
  def split_article(article_text):
33
  words = article_text.split()
@@ -76,7 +75,7 @@ def clean_scrap(artikel,link, openai_key):
76
  openai.api_key = openai_key
77
  if len(artikel) > 1:
78
  for art in artikel:
79
- response = client.chat.completions.create(
80
  model="gpt-3.5-turbo",
81
  messages=[
82
  {"role": "system", "content": "You are a very professional article editor."},
@@ -90,7 +89,7 @@ def clean_scrap(artikel,link, openai_key):
90
  new_artikel.append(result)
91
  else:
92
  for art in artikel:
93
- response = client.chat.completions.create(
94
  model="gpt-3.5-turbo",
95
  messages=[
96
  {"role": "system", "content": "You are a very professional article editor."},
@@ -105,7 +104,7 @@ def clean_scrap(artikel,link, openai_key):
105
 
106
  new_art = [' '.join(new_artikel)]
107
  for art in new_art:
108
- response = client.chat.completions.create(
109
  model="gpt-3.5-turbo",
110
  messages=[
111
  {"role": "system", "content": "You are a very professional article editor and capable of generating compelling and professional article titles."},
@@ -120,7 +119,7 @@ def clean_scrap(artikel,link, openai_key):
120
 
121
  content = article[0].split("\n")
122
  title = content[0].replace('title:', '').replace("Title:", '').strip()
123
- response = client.chat.completions.create(
124
  model="gpt-3.5-turbo",
125
  messages=[
126
  {"role": "system", "content": "You are a professional translator and rewriter"},
@@ -187,7 +186,7 @@ def artikel_processing(link_scrap,backlink,keyword,openai_key,replicate_key):
187
 
188
  openai.api_key = openai_key
189
  for i in artikel:
190
- response = client.chat.completions.create(
191
  model="gpt-3.5-turbo",
192
  messages=[
193
  {"role": "system", "content": "You are a proficient English to Indonesian language translator machine. You are capable of translating professionally according to the rules of the Indonesian language"},
@@ -202,7 +201,7 @@ def artikel_processing(link_scrap,backlink,keyword,openai_key,replicate_key):
202
  time.sleep(2)
203
 
204
  for i in translated:
205
- response = client.chat.completions.create(
206
  model="gpt-3.5-turbo",
207
  messages=[
208
  {"role": "system", "content": f"""You are a very professional article editor and perform SEO optimization on an article with utmost professionalism. berikut adalah SOP SEO yang harus kamu terapkan
@@ -224,7 +223,7 @@ def artikel_processing(link_scrap,backlink,keyword,openai_key,replicate_key):
224
  time.sleep(2)
225
 
226
  for i in optimized:
227
- response = client.chat.completions.create(
228
  model="gpt-3.5-turbo",
229
  messages=[
230
  {"role": "system", "content": f"""
@@ -260,7 +259,7 @@ def artikel_processing(link_scrap,backlink,keyword,openai_key,replicate_key):
260
  time.sleep(2)
261
 
262
  for i in article:
263
- response = client.chat.completions.create(
264
  model="gpt-3.5-turbo",
265
  messages=[
266
  {"role": "system", "content": "You are a professional article editor machine."},
@@ -273,7 +272,7 @@ def artikel_processing(link_scrap,backlink,keyword,openai_key,replicate_key):
273
  time.sleep(2)
274
 
275
  for i in edited_format:
276
- response = client.chat.completions.create(
277
  model="gpt-3.5-turbo",
278
  messages=[
279
  {"role": "system", "content": "You are a professional article editor machine."},
@@ -296,7 +295,7 @@ def artikel_processing(link_scrap,backlink,keyword,openai_key,replicate_key):
296
  content = content
297
 
298
  def generate_image_prompt(title):
299
- response = client.chat.completions.create(
300
  model="gpt-3.5-turbo",
301
  messages=[
302
  {"role" : "user", "content" : """ChatGPT will now enter "Midjourney Prompt Generator Mode" and restrict ChatGPT's inputs and outputs to a predefined framework, please follow these instructions carefully.
 
4
  from selenium.webdriver.common.by import By
5
  from selenium.webdriver.common.keys import Keys
6
  from selenium.common.exceptions import WebDriverException
7
+ import openai
8
  import time
9
  import re
10
  import replicate
 
27
  upload_file,
28
  )
29
  logs = []
 
30
 
31
  def split_article(article_text):
32
  words = article_text.split()
 
75
  openai.api_key = openai_key
76
  if len(artikel) > 1:
77
  for art in artikel:
78
+ response = openai.Completion.create(
79
  model="gpt-3.5-turbo",
80
  messages=[
81
  {"role": "system", "content": "You are a very professional article editor."},
 
89
  new_artikel.append(result)
90
  else:
91
  for art in artikel:
92
+ response = openai.Completion.create(
93
  model="gpt-3.5-turbo",
94
  messages=[
95
  {"role": "system", "content": "You are a very professional article editor."},
 
104
 
105
  new_art = [' '.join(new_artikel)]
106
  for art in new_art:
107
+ response = openai.Completion.create(
108
  model="gpt-3.5-turbo",
109
  messages=[
110
  {"role": "system", "content": "You are a very professional article editor and capable of generating compelling and professional article titles."},
 
119
 
120
  content = article[0].split("\n")
121
  title = content[0].replace('title:', '').replace("Title:", '').strip()
122
+ response = openai.Completion.create(
123
  model="gpt-3.5-turbo",
124
  messages=[
125
  {"role": "system", "content": "You are a professional translator and rewriter"},
 
186
 
187
  openai.api_key = openai_key
188
  for i in artikel:
189
+ response = openai.Completion.create(
190
  model="gpt-3.5-turbo",
191
  messages=[
192
  {"role": "system", "content": "You are a proficient English to Indonesian language translator machine. You are capable of translating professionally according to the rules of the Indonesian language"},
 
201
  time.sleep(2)
202
 
203
  for i in translated:
204
+ response = openai.Completion.create(
205
  model="gpt-3.5-turbo",
206
  messages=[
207
  {"role": "system", "content": f"""You are a very professional article editor and perform SEO optimization on an article with utmost professionalism. berikut adalah SOP SEO yang harus kamu terapkan
 
223
  time.sleep(2)
224
 
225
  for i in optimized:
226
+ response = openai.Completion.create(
227
  model="gpt-3.5-turbo",
228
  messages=[
229
  {"role": "system", "content": f"""
 
259
  time.sleep(2)
260
 
261
  for i in article:
262
+ response = openai.Completion.create(
263
  model="gpt-3.5-turbo",
264
  messages=[
265
  {"role": "system", "content": "You are a professional article editor machine."},
 
272
  time.sleep(2)
273
 
274
  for i in edited_format:
275
+ response = openai.Completion.create(
276
  model="gpt-3.5-turbo",
277
  messages=[
278
  {"role": "system", "content": "You are a professional article editor machine."},
 
295
  content = content
296
 
297
  def generate_image_prompt(title):
298
+ response = openai.Completion.create(
299
  model="gpt-3.5-turbo",
300
  messages=[
301
  {"role" : "user", "content" : """ChatGPT will now enter "Midjourney Prompt Generator Mode" and restrict ChatGPT's inputs and outputs to a predefined framework, please follow these instructions carefully.