Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -97,7 +97,7 @@ def get_azure_response(messages, api_key, azure_api_base):
|
|
97 |
return response['choices'][0]['message']['content']
|
98 |
|
99 |
def cek_url(url):
|
100 |
-
with open("
|
101 |
scraped_urls = set(url.strip() for url in file.readlines())
|
102 |
|
103 |
if url in scraped_urls:
|
@@ -215,7 +215,7 @@ def scrap_artikel(source_type,source,models,api_key,azure_api_base,keyword):
|
|
215 |
wd = webdriver.Chrome(options=options)
|
216 |
|
217 |
|
218 |
-
if source_type == "
|
219 |
artikel =[]
|
220 |
link = scrap_portal(source)
|
221 |
for url in link:
|
@@ -484,21 +484,6 @@ def artikel_processing(source_type,source,backlink,keyword,models,api_key,azure_
|
|
484 |
base64_string = base64.b64decode(base64_string)
|
485 |
image_data= base64_string
|
486 |
os.remove(tmp_path)
|
487 |
-
|
488 |
-
# output_image_io = io.BytesIO()
|
489 |
-
# image.save(output_image_io, format='PNG')
|
490 |
-
# output_image_io.seek(0)
|
491 |
-
|
492 |
-
# # Upload gambar ke repo Hugging Face
|
493 |
-
# repo_name = get_full_repo_name(model_id="Article_Gen3", token="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")
|
494 |
-
# file_url = upload_file(
|
495 |
-
# path_or_fileobj=output_image_io.read(),
|
496 |
-
# path_in_repo="output_image.png",
|
497 |
-
# repo_id=repo_name,
|
498 |
-
# repo_type="space",
|
499 |
-
# token="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",
|
500 |
-
# )
|
501 |
-
|
502 |
except:
|
503 |
image = Image.open('botika_logo.jpeg')
|
504 |
image = image.crop((3,0,1645,1024))
|
@@ -690,19 +675,20 @@ with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_g
|
|
690 |
""")
|
691 |
with gr.Row():
|
692 |
with gr.Column():
|
693 |
-
source_type = gr.Radio(["
|
694 |
-
source = gr.Textbox(placeholder="Masukkan Source Berupa Link/
|
695 |
backlink = gr.Textbox(placeholder="Masukkan Backlink Yang Akan Diterapkan", label="Backlink")
|
696 |
-
keyword = gr.Textbox(placeholder="Masukkan
|
697 |
versi = gr.Radio(["openai", "azure"], label="Request Schema", info="Pilih Skema Untuk Request ke ChatGPT ")
|
698 |
api_key = gr.Textbox(placeholder="Masukkan Api Key", type="password",label="API Key")
|
699 |
link_azure = gr.Textbox(placeholder="Khusus Untuk Skema Request Menggunakan Azure",type="password", label="Azure Endpoint (Opsional)")
|
700 |
replicate_token = gr.Textbox(placeholder="Masukkan Token Replicate", type="password",label="Replicate Key")
|
701 |
button_scrap = gr.Button("Scrap Article")
|
702 |
output = gr.HTML("")
|
|
|
|
|
703 |
img = gr.Image(label="Content Media")
|
704 |
button_scrap.click(fn=scrap, inputs=[source_type,source,backlink,keyword,versi,api_key,link_azure,replicate_token], outputs= [output,img])
|
705 |
-
view_outputs = gr.Button("View Article")
|
706 |
with gr.Tab("Raw Article"):
|
707 |
title = gr.Textbox("", label="Title", interactive=True)
|
708 |
content = gr.Textbox("", label="Content", interactive=True)
|
|
|
97 |
return response['choices'][0]['message']['content']
|
98 |
|
99 |
def cek_url(url):
|
100 |
+
with open("log_activity.txt", 'r') as file:
|
101 |
scraped_urls = set(url.strip() for url in file.readlines())
|
102 |
|
103 |
if url in scraped_urls:
|
|
|
215 |
wd = webdriver.Chrome(options=options)
|
216 |
|
217 |
|
218 |
+
if source_type == "keyword":
|
219 |
artikel =[]
|
220 |
link = scrap_portal(source)
|
221 |
for url in link:
|
|
|
484 |
base64_string = base64.b64decode(base64_string)
|
485 |
image_data= base64_string
|
486 |
os.remove(tmp_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
except:
|
488 |
image = Image.open('botika_logo.jpeg')
|
489 |
image = image.crop((3,0,1645,1024))
|
|
|
675 |
""")
|
676 |
with gr.Row():
|
677 |
with gr.Column():
|
678 |
+
source_type = gr.Radio(["link", "keyword"], label="Source", info="Pilih Jenis Source")
|
679 |
+
source = gr.Textbox(placeholder="Masukkan Source Berupa Link/Keyword Artikel Yang Akan Discrap", show_label=False)
|
680 |
backlink = gr.Textbox(placeholder="Masukkan Backlink Yang Akan Diterapkan", label="Backlink")
|
681 |
+
keyword = gr.Textbox(placeholder="Masukkan Fokus Keyphrase Yang Akan Diterapkan", label="Focus Keyphrase")
|
682 |
versi = gr.Radio(["openai", "azure"], label="Request Schema", info="Pilih Skema Untuk Request ke ChatGPT ")
|
683 |
api_key = gr.Textbox(placeholder="Masukkan Api Key", type="password",label="API Key")
|
684 |
link_azure = gr.Textbox(placeholder="Khusus Untuk Skema Request Menggunakan Azure",type="password", label="Azure Endpoint (Opsional)")
|
685 |
replicate_token = gr.Textbox(placeholder="Masukkan Token Replicate", type="password",label="Replicate Key")
|
686 |
button_scrap = gr.Button("Scrap Article")
|
687 |
output = gr.HTML("")
|
688 |
+
with gr.Column():
|
689 |
+
view_outputs = gr.Button("View Article")
|
690 |
img = gr.Image(label="Content Media")
|
691 |
button_scrap.click(fn=scrap, inputs=[source_type,source,backlink,keyword,versi,api_key,link_azure,replicate_token], outputs= [output,img])
|
|
|
692 |
with gr.Tab("Raw Article"):
|
693 |
title = gr.Textbox("", label="Title", interactive=True)
|
694 |
content = gr.Textbox("", label="Content", interactive=True)
|