Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,22 @@ import os
|
|
| 3 |
from datasets import load_dataset
|
| 4 |
import pandas as pd
|
| 5 |
import matplotlib.pyplot as plt
|
|
|
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
ds = load_dataset("CohereForAI/mmlu-translations-results", split="train", token=HF_TOKEN)
|
| 10 |
|
| 11 |
df = ds.to_pandas()
|
|
@@ -40,14 +53,14 @@ st.pyplot(fig)
|
|
| 40 |
user_ids = df['responses'].apply(lambda x: x['is_edit_required']).explode().apply(lambda x: x['user_id'])
|
| 41 |
user_id_counts = user_ids.value_counts()
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
# Convert the user ID counts to a DataFrame for display in the table
|
| 44 |
user_id_counts_df = user_id_counts.reset_index()
|
| 45 |
-
user_id_counts_df.columns = ['
|
| 46 |
|
| 47 |
-
# Display the table of
|
| 48 |
st.table(user_id_counts_df)
|
| 49 |
|
| 50 |
-
st.dataframe(df)
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 3 |
from datasets import load_dataset
|
| 4 |
import pandas as pd
|
| 5 |
import matplotlib.pyplot as plt
|
| 6 |
+
import argilla as rg
|
| 7 |
|
| 8 |
+
|
| 9 |
+
ARGILLA_API_URL = os.environ.get("ARGILLA_API_URL")
|
| 10 |
+
ARGILLA_API_KEY = os.environ.get("ARGILLA_API_KEY")
|
| 11 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 12 |
|
| 13 |
+
client = rg.Argilla(
|
| 14 |
+
api_url=ARGILLA_API_URL,
|
| 15 |
+
api_key=ARGILLA_API_KEY
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
workspace = client.workspaces('cohere')
|
| 19 |
+
|
| 20 |
+
users_map = {str(user.id):user.username for user in list(workspace.users)}
|
| 21 |
+
|
| 22 |
ds = load_dataset("CohereForAI/mmlu-translations-results", split="train", token=HF_TOKEN)
|
| 23 |
|
| 24 |
df = ds.to_pandas()
|
|
|
|
| 53 |
user_ids = df['responses'].apply(lambda x: x['is_edit_required']).explode().apply(lambda x: x['user_id'])
|
| 54 |
user_id_counts = user_ids.value_counts()
|
| 55 |
|
| 56 |
+
# Map user IDs to usernames
|
| 57 |
+
user_id_counts.index = user_id_counts.index.map(users_map)
|
| 58 |
+
|
| 59 |
# Convert the user ID counts to a DataFrame for display in the table
|
| 60 |
user_id_counts_df = user_id_counts.reset_index()
|
| 61 |
+
user_id_counts_df.columns = ['Username', 'Count']
|
| 62 |
|
| 63 |
+
# Display the table of username counts in the Streamlit app
|
| 64 |
st.table(user_id_counts_df)
|
| 65 |
|
| 66 |
+
st.dataframe(df)
|
|
|
|
|
|
|
|
|