Spaces:
Sleeping
Sleeping
import gradio as gr | |
import re | |
import csv | |
import pandas as pd | |
def process_repo_input(text): | |
if not text: | |
return pd.DataFrame(columns=["repo id", "strength", "weaknesses", "speciality", "relevance rating"]) | |
# Split by newlines and commas, strip whitespace | |
repo_ids = [repo.strip() for repo in re.split(r'[\n,]+', text) if repo.strip()] | |
# Write to CSV | |
csv_filename = "repo_ids.csv" | |
with open(csv_filename, mode="w", newline='', encoding="utf-8") as csvfile: | |
writer = csv.writer(csvfile) | |
writer.writerow(["repo id", "strength", "weaknesses", "speciality", "relevance rating"]) | |
for repo_id in repo_ids: | |
writer.writerow([repo_id, "", "", "", ""]) | |
# Read the CSV into a DataFrame to display | |
df = pd.read_csv(csv_filename) | |
return df | |
demo = gr.Interface( | |
fn=process_repo_input, | |
inputs=gr.Textbox(label="Enter repo IDs (comma or newline separated)", lines=5, placeholder="repo1, repo2\nrepo3"), | |
outputs=gr.Dataframe(headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating"]), | |
title="Repo ID Input", | |
description="Enter repo IDs separated by commas or new lines." | |
) | |
demo.launch() |