Spaces:
Running
Running
Update src/aibom_generator/generator.py
Browse files
src/aibom_generator/generator.py
CHANGED
@@ -96,6 +96,7 @@ class AIBOMGenerator:
|
|
96 |
"pipeline_tag": model_info.pipeline_tag if hasattr(model_info, "pipeline_tag") else None,
|
97 |
"downloads": model_info.downloads if hasattr(model_info, "downloads") else 0,
|
98 |
"last_modified": model_info.lastModified if hasattr(model_info, "lastModified") else None,
|
|
|
99 |
})
|
100 |
|
101 |
if model_card and model_card.data:
|
@@ -112,7 +113,6 @@ class AIBOMGenerator:
|
|
112 |
if hasattr(model_card.data, "eval_results") and model_card.data.eval_results:
|
113 |
metadata["eval_results"] = model_card.data.eval_results
|
114 |
|
115 |
-
# AI-specific fields (manually added or inferred)
|
116 |
metadata["ai:type"] = "Transformer"
|
117 |
metadata["ai:task"] = metadata.get("pipeline_tag", "Text Generation")
|
118 |
metadata["ai:framework"] = "PyTorch" if "transformers" in metadata.get("library_name", "") else "Unknown"
|
@@ -129,7 +129,7 @@ class AIBOMGenerator:
|
|
129 |
return {k: v for k, v in metadata.items() if v is not None}
|
130 |
|
131 |
def _extract_unstructured_metadata(self, model_card: ModelCard) -> Dict[str, Any]:
|
132 |
-
return {}
|
133 |
|
134 |
def _create_metadata_section(self, model_id: str, metadata: Dict[str, Any]) -> Dict[str, Any]:
|
135 |
timestamp = datetime.datetime.utcnow().isoformat() + "Z"
|
@@ -183,8 +183,8 @@ class AIBOMGenerator:
|
|
183 |
if "description" in metadata:
|
184 |
component["description"] = metadata["description"]
|
185 |
|
186 |
-
if "
|
187 |
-
component["version"] = metadata["
|
188 |
|
189 |
if "license" in metadata:
|
190 |
component["licenses"] = [{"license": {"id": metadata["license"]}}]
|
|
|
96 |
"pipeline_tag": model_info.pipeline_tag if hasattr(model_info, "pipeline_tag") else None,
|
97 |
"downloads": model_info.downloads if hasattr(model_info, "downloads") else 0,
|
98 |
"last_modified": model_info.lastModified if hasattr(model_info, "lastModified") else None,
|
99 |
+
"commit": model_info.sha[:7] if hasattr(model_info, "sha") and model_info.sha else None,
|
100 |
})
|
101 |
|
102 |
if model_card and model_card.data:
|
|
|
113 |
if hasattr(model_card.data, "eval_results") and model_card.data.eval_results:
|
114 |
metadata["eval_results"] = model_card.data.eval_results
|
115 |
|
|
|
116 |
metadata["ai:type"] = "Transformer"
|
117 |
metadata["ai:task"] = metadata.get("pipeline_tag", "Text Generation")
|
118 |
metadata["ai:framework"] = "PyTorch" if "transformers" in metadata.get("library_name", "") else "Unknown"
|
|
|
129 |
return {k: v for k, v in metadata.items() if v is not None}
|
130 |
|
131 |
def _extract_unstructured_metadata(self, model_card: ModelCard) -> Dict[str, Any]:
|
132 |
+
return {}
|
133 |
|
134 |
def _create_metadata_section(self, model_id: str, metadata: Dict[str, Any]) -> Dict[str, Any]:
|
135 |
timestamp = datetime.datetime.utcnow().isoformat() + "Z"
|
|
|
183 |
if "description" in metadata:
|
184 |
component["description"] = metadata["description"]
|
185 |
|
186 |
+
if "commit" in metadata:
|
187 |
+
component["version"] = metadata["commit"]
|
188 |
|
189 |
if "license" in metadata:
|
190 |
component["licenses"] = [{"license": {"id": metadata["license"]}}]
|