Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,6 @@ class AgentMemory:
|
|
47 |
|
48 |
def add_short_term(self, data: Dict[str, Any]) -> None:
|
49 |
self.short_term.append(data)
|
50 |
-
# Keep only the last 10 entries
|
51 |
if len(self.short_term) > 10:
|
52 |
self.short_term.pop(0)
|
53 |
|
@@ -73,7 +72,6 @@ class AgentHub:
|
|
73 |
self.global_memory = AgentMemory()
|
74 |
self.session_id = str(uuid.uuid4())
|
75 |
|
76 |
-
# Initialize NLP components
|
77 |
try:
|
78 |
self.tokenizer = AutoTokenizer.from_pretrained("distilgpt2")
|
79 |
self.model = AutoModelForCausalLM.from_pretrained("distilgpt2")
|
@@ -173,7 +171,6 @@ class IntelligentAgent:
|
|
173 |
# ---------------------------
|
174 |
# Specialized Agent Implementations
|
175 |
# ---------------------------
|
176 |
-
|
177 |
class WebResearchAgent(IntelligentAgent):
|
178 |
def __init__(self, hub: AgentHub):
|
179 |
super().__init__("web_research", hub)
|
@@ -297,7 +294,6 @@ class TextProcessingAgent(IntelligentAgent):
|
|
297 |
else:
|
298 |
chunk_size = 5
|
299 |
chunking_strategy = "sentence_blocks"
|
300 |
-
chunks = []
|
301 |
if chunking_strategy == "character_blocks":
|
302 |
chunks = [task[i:i+chunk_size] for i in range(0, len(task), chunk_size)]
|
303 |
elif chunking_strategy == "word_blocks":
|
@@ -1007,7 +1003,7 @@ def create_gradio_interface():
|
|
1007 |
return {"error": str(e)}
|
1008 |
with gr.Blocks(title="SmolAgents Toolbelt") as interface:
|
1009 |
gr.Markdown("# SmolAgents Toolbelt")
|
1010 |
-
gr.Markdown("A collection of specialized agents for various tasks with
|
1011 |
with gr.Tabs():
|
1012 |
with gr.Tab("Single Agent"):
|
1013 |
agent_type = gr.Dropdown(
|
@@ -1025,8 +1021,10 @@ def create_gradio_interface():
|
|
1025 |
chain_input = gr.Textbox(label="Input", placeholder="Enter your request for the chain...")
|
1026 |
chain_sequence = gr.Textbox(label="Agent Sequence", placeholder="Comma-separated agent names (e.g., text_processing,data_analysis)")
|
1027 |
chain_output = gr.JSON(label="Chain Output")
|
|
|
|
|
1028 |
chain_btn = gr.Button("Process Chain")
|
1029 |
-
chain_btn.click(fn=process_request, inputs=[
|
1030 |
with gr.Tab("Help"):
|
1031 |
gr.Markdown("""
|
1032 |
## Available Agents
|
@@ -1040,7 +1038,7 @@ def create_gradio_interface():
|
|
1040 |
- **File Management Agent**: Handles file creation, reading, listing, and deletion.
|
1041 |
|
1042 |
### Usage
|
1043 |
-
1. Select an agent (or choose '
|
1044 |
2. Enter your request.
|
1045 |
3. For chains, provide a comma-separated list of agent IDs.
|
1046 |
""")
|
|
|
47 |
|
48 |
def add_short_term(self, data: Dict[str, Any]) -> None:
|
49 |
self.short_term.append(data)
|
|
|
50 |
if len(self.short_term) > 10:
|
51 |
self.short_term.pop(0)
|
52 |
|
|
|
72 |
self.global_memory = AgentMemory()
|
73 |
self.session_id = str(uuid.uuid4())
|
74 |
|
|
|
75 |
try:
|
76 |
self.tokenizer = AutoTokenizer.from_pretrained("distilgpt2")
|
77 |
self.model = AutoModelForCausalLM.from_pretrained("distilgpt2")
|
|
|
171 |
# ---------------------------
|
172 |
# Specialized Agent Implementations
|
173 |
# ---------------------------
|
|
|
174 |
class WebResearchAgent(IntelligentAgent):
|
175 |
def __init__(self, hub: AgentHub):
|
176 |
super().__init__("web_research", hub)
|
|
|
294 |
else:
|
295 |
chunk_size = 5
|
296 |
chunking_strategy = "sentence_blocks"
|
|
|
297 |
if chunking_strategy == "character_blocks":
|
298 |
chunks = [task[i:i+chunk_size] for i in range(0, len(task), chunk_size)]
|
299 |
elif chunking_strategy == "word_blocks":
|
|
|
1003 |
return {"error": str(e)}
|
1004 |
with gr.Blocks(title="SmolAgents Toolbelt") as interface:
|
1005 |
gr.Markdown("# SmolAgents Toolbelt")
|
1006 |
+
gr.Markdown("A collection of specialized agents for various tasks with evolved logic :contentReference[oaicite:0]{index=0}.")
|
1007 |
with gr.Tabs():
|
1008 |
with gr.Tab("Single Agent"):
|
1009 |
agent_type = gr.Dropdown(
|
|
|
1021 |
chain_input = gr.Textbox(label="Input", placeholder="Enter your request for the chain...")
|
1022 |
chain_sequence = gr.Textbox(label="Agent Sequence", placeholder="Comma-separated agent names (e.g., text_processing,data_analysis)")
|
1023 |
chain_output = gr.JSON(label="Chain Output")
|
1024 |
+
# Use a hidden state component for request type instead of a literal string
|
1025 |
+
chain_type = gr.State("chain")
|
1026 |
chain_btn = gr.Button("Process Chain")
|
1027 |
+
chain_btn.click(fn=process_request, inputs=[chain_type, chain_input, chain_sequence], outputs=chain_output)
|
1028 |
with gr.Tab("Help"):
|
1029 |
gr.Markdown("""
|
1030 |
## Available Agents
|
|
|
1038 |
- **File Management Agent**: Handles file creation, reading, listing, and deletion.
|
1039 |
|
1040 |
### Usage
|
1041 |
+
1. Select an agent (or choose 'Chain of Thought' for a sequence).
|
1042 |
2. Enter your request.
|
1043 |
3. For chains, provide a comma-separated list of agent IDs.
|
1044 |
""")
|