Spaces:
Sleeping
Sleeping
Update ssss.py
Browse files
ssss.py
CHANGED
@@ -480,11 +480,10 @@ class Agent:
|
|
480 |
self.log_communication(f"Error cleaning up images directory: {str(e)}", self.name)
|
481 |
|
482 |
def update_scam_csv(self, new_data):
|
483 |
-
"""Update scam123.csv in Hugging Face space"""
|
484 |
# Hugging Face configuration
|
485 |
HF_TOKEN = "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"
|
486 |
-
REPO_ID = "varun324242/J.A.R.V.I.S"
|
487 |
-
PREDICTION_API = "https://varun324242-sssssss.hf.space/predict" # Prediction API endpoint
|
488 |
|
489 |
try:
|
490 |
# Local file paths
|
@@ -494,14 +493,14 @@ class Agent:
|
|
494 |
# Headers for HF API
|
495 |
headers = {
|
496 |
"Authorization": f"Bearer {HF_TOKEN}",
|
497 |
-
"Content-Type": "
|
498 |
}
|
499 |
|
500 |
# First try to get existing data from Hugging Face
|
501 |
try:
|
502 |
-
#
|
503 |
response = requests.get(
|
504 |
-
f"https://huggingface.co/spaces/{REPO_ID}/
|
505 |
headers=headers,
|
506 |
allow_redirects=True
|
507 |
)
|
@@ -551,6 +550,7 @@ class Agent:
|
|
551 |
# Create data directory if it doesn't exist
|
552 |
os.makedirs(os.path.dirname(local_csv_path), exist_ok=True)
|
553 |
|
|
|
554 |
with open(local_csv_path, 'w', encoding='utf-8', newline='') as f:
|
555 |
writer = csv.DictWriter(f, fieldnames=['message'])
|
556 |
writer.writeheader()
|
@@ -571,24 +571,19 @@ class Agent:
|
|
571 |
|
572 |
# Update Hugging Face space using the correct API endpoint
|
573 |
try:
|
574 |
-
#
|
575 |
-
|
576 |
-
|
577 |
-
}
|
578 |
|
579 |
-
#
|
580 |
-
upload_url = f"https://huggingface.co/spaces/{REPO_ID}/
|
581 |
|
582 |
-
#
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
"Content-Type": "text/csv"
|
589 |
-
},
|
590 |
-
data=f.read()
|
591 |
-
)
|
592 |
|
593 |
if response.status_code in [200, 201]:
|
594 |
self.log_communication(
|
|
|
480 |
self.log_communication(f"Error cleaning up images directory: {str(e)}", self.name)
|
481 |
|
482 |
def update_scam_csv(self, new_data):
|
483 |
+
"""Update scam123.csv in Hugging Face J.A.R.V.I.S space"""
|
484 |
# Hugging Face configuration
|
485 |
HF_TOKEN = "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"
|
486 |
+
REPO_ID = "varun324242/J.A.R.V.I.S"
|
|
|
487 |
|
488 |
try:
|
489 |
# Local file paths
|
|
|
493 |
# Headers for HF API
|
494 |
headers = {
|
495 |
"Authorization": f"Bearer {HF_TOKEN}",
|
496 |
+
"Content-Type": "application/octet-stream"
|
497 |
}
|
498 |
|
499 |
# First try to get existing data from Hugging Face
|
500 |
try:
|
501 |
+
# Use the correct URL format for the J.A.R.V.I.S space
|
502 |
response = requests.get(
|
503 |
+
f"https://huggingface.co/spaces/{REPO_ID}/raw/main/data/scam123.csv",
|
504 |
headers=headers,
|
505 |
allow_redirects=True
|
506 |
)
|
|
|
550 |
# Create data directory if it doesn't exist
|
551 |
os.makedirs(os.path.dirname(local_csv_path), exist_ok=True)
|
552 |
|
553 |
+
# Write updated CSV file
|
554 |
with open(local_csv_path, 'w', encoding='utf-8', newline='') as f:
|
555 |
writer = csv.DictWriter(f, fieldnames=['message'])
|
556 |
writer.writeheader()
|
|
|
571 |
|
572 |
# Update Hugging Face space using the correct API endpoint
|
573 |
try:
|
574 |
+
# Read file content
|
575 |
+
with open(local_csv_path, 'rb') as f:
|
576 |
+
file_content = f.read()
|
|
|
577 |
|
578 |
+
# Use the correct API endpoint for the J.A.R.V.I.S space
|
579 |
+
upload_url = f"https://huggingface.co/spaces/{REPO_ID}/blob/main/data/scam123.csv"
|
580 |
|
581 |
+
# Make the request
|
582 |
+
response = requests.put(
|
583 |
+
upload_url,
|
584 |
+
headers=headers,
|
585 |
+
data=file_content
|
586 |
+
)
|
|
|
|
|
|
|
|
|
587 |
|
588 |
if response.status_code in [200, 201]:
|
589 |
self.log_communication(
|