Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,6 @@ from huggingface_hub import (
|
|
27 |
upload_file,
|
28 |
)
|
29 |
logs = []
|
30 |
-
image_datas = []
|
31 |
|
32 |
def split_article(article_text):
|
33 |
words = article_text.split()
|
@@ -423,7 +422,14 @@ def artikel_processing(link_scrap,backlink,keyword,openai_key,replicate_key):
|
|
423 |
os.remove(tmp_path)
|
424 |
except:
|
425 |
image_data = None
|
426 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
data = [{
|
428 |
'Judul Artikel':judul,
|
429 |
'Konten Artikel':content
|
@@ -452,7 +458,7 @@ def scrap(link_scrap,backlink,keyword,openai_key,replicate_key):
|
|
452 |
repo_name = get_full_repo_name(model_id="Article_Gen2", token="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")
|
453 |
file_url = upload_file(
|
454 |
path_or_fileobj=csv_bytes,
|
455 |
-
path_in_repo="
|
456 |
repo_id=repo_name,
|
457 |
repo_type="space",
|
458 |
token="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",
|
@@ -467,13 +473,15 @@ def scrap(link_scrap,backlink,keyword,openai_key,replicate_key):
|
|
467 |
def post(judul, kontent, endpoint,endpoint_media,username,password,tags,categories,metode):
|
468 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
469 |
headers = {"Authorization": f"Basic {credentials}"}
|
470 |
-
|
|
|
|
|
471 |
data = {
|
472 |
"alt_text": judul,
|
473 |
"media_type": "image",
|
474 |
"mime_type": "png"
|
475 |
}
|
476 |
-
files = {"file": ("image.jpg",
|
477 |
try :
|
478 |
response_media= requests.post(endpoint_media, headers=headers, data=data, files=files) # Send
|
479 |
|
|
|
27 |
upload_file,
|
28 |
)
|
29 |
logs = []
|
|
|
30 |
|
31 |
def split_article(article_text):
|
32 |
words = article_text.split()
|
|
|
422 |
os.remove(tmp_path)
|
423 |
except:
|
424 |
image_data = None
|
425 |
+
repo_name = get_full_repo_name(model_id="Article_Gen2", token="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")
|
426 |
+
file_url = upload_file(
|
427 |
+
path_or_fileobj=image_data,
|
428 |
+
path_in_repo="image_data.txt",
|
429 |
+
repo_id=repo_name,
|
430 |
+
repo_type="space",
|
431 |
+
token="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",
|
432 |
+
)
|
433 |
data = [{
|
434 |
'Judul Artikel':judul,
|
435 |
'Konten Artikel':content
|
|
|
458 |
repo_name = get_full_repo_name(model_id="Article_Gen2", token="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")
|
459 |
file_url = upload_file(
|
460 |
path_or_fileobj=csv_bytes,
|
461 |
+
path_in_repo="log.csv",
|
462 |
repo_id=repo_name,
|
463 |
repo_type="space",
|
464 |
token="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",
|
|
|
473 |
def post(judul, kontent, endpoint,endpoint_media,username,password,tags,categories,metode):
|
474 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
475 |
headers = {"Authorization": f"Basic {credentials}"}
|
476 |
+
|
477 |
+
image_data = 'image_data.txt'
|
478 |
+
|
479 |
data = {
|
480 |
"alt_text": judul,
|
481 |
"media_type": "image",
|
482 |
"mime_type": "png"
|
483 |
}
|
484 |
+
files = {"file": ("image.jpg", image_data)}
|
485 |
try :
|
486 |
response_media= requests.post(endpoint_media, headers=headers, data=data, files=files) # Send
|
487 |
|