Spaces:
Build error
Build error
File size: 8,201 Bytes
d3a1e32 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | """
Hermès AI Toolkit - Hugging Face Space
Advanced AI tools for the Hermès Agent system
"""
import gradio as gr
import json
from typing import List, Dict, Any
# Tool definitions for Hermès agent integration
TOOLS = {
"text_generation": {
"name": "Text Generation",
"description": "Generate text using HF Inference API",
"icon": "✍️",
"endpoint": "text-generation"
},
"summarization": {
"name": "Summarization",
"description": "Summarize long text into concise summaries",
"icon": "📝",
"endpoint": "summarization"
},
"translation": {
"name": "Translation",
"description": "Translate text between languages",
"icon": "🌐",
"endpoint": "translation"
},
"question_answering": {
"name": "Question Answering",
"description": "Answer questions based on given context",
"icon": "❓",
"endpoint": "question-answering"
},
"sentiment_analysis": {
"name": "Sentiment Analysis",
"description": "Analyze emotional tone of text",
"icon": "💭",
"endpoint": "sentiment-analysis"
},
"code_generation": {
"name": "Code Generation",
"description": "Generate code from natural language",
"icon": "💻",
"endpoint": "code-generation"
},
"image_classification": {
"name": "Image Classification",
"description": "Classify images into categories",
"icon": "🖼️",
"endpoint": "image-classification"
},
"feature_extraction": {
"name": "Feature Extraction",
"description": "Extract embeddings/features from text",
"icon": "🔍",
"endpoint": "feature-extraction"
}
}
MODELS = {
"text-generation": [
"meta-llama/Llama-3.2-1B-Instruct",
"meta-llama/Llama-3.2-3B-Instruct",
"mistralai/Mistral-7B-Instruct-v0.2",
"microsoft/Phi-3-mini-128k-instruct",
"Qwen/Qwen2.5-7B-Instruct",
"deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"
],
"summarization": [
"facebook/bart-large-cnn",
"google/pegasus-xsum",
"t5-base"
],
"translation": [
"facebook/mbart-large-50-many-to-many-mmt",
"Helsinki-NLP/opus-mt-zh-en",
"Helsinki-NLP/opus-mt-en-zh"
],
"question-answering": [
"deepset/roberta-base-squad2",
"distilbert-base-cased-distilled-squad"
],
"sentiment-analysis": [
"distilbert-base-uncased-finetuned-sst-2-english",
"nlptown/bert-base-multilingual-uncased-sentiment"
],
"code-generation": [
"deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct",
"mistralai/CodeInstruct-7B"
]
}
def get_tool_card(tool_id: str) -> str:
"""Generate tool card HTML"""
tool = TOOLS.get(tool_id, {})
models = MODELS.get(tool.get("endpoint", ""), [])
models_html = "<br>".join([f"• `{m}`" for m in models[:3]])
if len(models) > 3:
models_html += f"<br>... and {len(models)-3} more"
return f"""
<div style='background: #1a1a2e; padding: 15px; border-radius: 10px; margin: 10px 0;'>
<h3>{tool.get('icon', '🔧')} {tool.get('name', tool_id)}</h3>
<p style='color: #888;'>{tool.get('description', '')}</p>
<details>
<summary style='color: #4ecdc4; cursor: pointer;'>Available Models ({len(models)})</summary>
<div style='margin-top: 10px; color: #aaa;'>{models_html}</div>
</details>
</div>
"""
def build_tools_gallery():
"""Build tools gallery view"""
tools_html = ""
for tool_id in TOOLS:
tools_html += get_tool_card(tool_id)
return tools_html
def build_hero():
"""Build hero section"""
return """# 🤖 Hermès AI Toolkit
Welcome to the Hermès AI Toolkit powered by Hugging Face Inference API.
## What is Hermès?
Hermès is an autonomous AI Agent that can:
- 🔍 Search and research topics
- 💻 Write and debug code
- 📊 Analyze data and generate insights
- 🌐 Translate between languages
- 📝 Summarize documents
- 💡 Answer questions intelligently
## Available Tools
Select a tool from the tabs below to get started.
## Integration
This Space is part of the [cntalk/hermes-agent-resources](https://huggingface.co/collections/cntalk/hermes-agent-resources-69f9c5b62fb70b0bbb6ae0b1) collection.
"""
# Build the interface
with gr.Blocks(
title="Hermès AI Toolkit",
theme=gr.themes.Soft(
primary_hue="teal",
secondary_hue="purple",
neutral_hue="gray",
font=[gr.themes.GoogleFont("Inter")]
)
) as demo:
gr.Markdown(build_hero())
with gr.Tabs():
with gr.TabItem("🛠️ All Tools"):
gr.HTML(build_tools_gallery())
with gr.TabItem("✍️ Text Generation"):
with gr.Row():
with gr.Column():
model_select = gr.Dropdown(
choices=MODELS["text-generation"],
value=MODELS["text-generation"][0],
label="Model"
)
prompt_input = gr.Textbox(
label="Prompt",
placeholder="Enter your prompt here...",
lines=4
)
max_tokens = gr.Slider(32, 4096, value=512, label="Max New Tokens")
temperature = gr.Slider(0.1, 2.0, value=0.7, label="Temperature")
generate_btn = gr.Button("Generate", variant="primary")
with gr.Column():
output = gr.Textbox(label="Output", lines=10)
generate_btn.click(
fn=lambda: "Feature requires HF Inference API client",
inputs=[],
outputs=output
)
with gr.TabItem("📝 Summarization"):
with gr.Row():
with gr.Column():
summ_model = gr.Dropdown(
choices=MODELS["summarization"],
value=MODELS["summarization"][0],
label="Model"
)
summ_input = gr.Textbox(
label="Input Text",
placeholder="Paste text to summarize...",
lines=6
)
summ_btn = gr.Button("Summarize", variant="primary")
with gr.Column():
summ_output = gr.Textbox(label="Summary", lines=6)
summ_btn.click(
fn=lambda: "Feature requires HF Inference API client",
inputs=[],
outputs=summ_output
)
with gr.TabItem("🌐 Translation"):
gr.Markdown("Translation tools using Helsinki-NLP and mBART models")
gr.Examples(
examples=[["Hello, how are you?", "en", "zh"]],
inputs=[],
label="Example translations"
)
with gr.TabItem("❓ QA"):
gr.Markdown("Question Answering using RoBERTa-based models")
with gr.TabItem("💭 Sentiment"):
gr.Markdown("Sentiment Analysis with DistilBERT")
with gr.TabItem("💻 Code"):
gr.Markdown("Code generation powered by DeepSeek Coder")
gr.Markdown("""
---
### 🔗 Hermès Resources
| Resource | Link |
|---------|------|
| Collection | [hermes-agent-resources](https://huggingface.co/collections/cntalk/hermes-agent-resources-69f9c5b62fb70b0bbb6ae0b1) |
| AI Toolkit Space | [hello-hermes](https://huggingface.co/spaces/cntalk/hello-hermes) |
| Examples Dataset | [hermes-examples](https://huggingface.co/datasets/cntalk/hermes-examples) |
| Agent Prompts | [agent-prompts](https://huggingface.co/datasets/cntalk/agent-prompts) |
| Skills Dataset | [hermes-skills](https://huggingface.co/datasets/cntalk/hermes-skills) |
Built with ❤️ for the Hermès AI Agent system
""")
demo.launch()
|