Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,6 +47,7 @@ class AgentMemory:
|
|
| 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,6 +73,7 @@ class AgentHub:
|
|
| 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")
|
|
@@ -1021,7 +1023,6 @@ def create_gradio_interface():
|
|
| 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)
|
|
@@ -1046,4 +1047,4 @@ def create_gradio_interface():
|
|
| 1046 |
|
| 1047 |
if __name__ == "__main__":
|
| 1048 |
demo = create_gradio_interface()
|
| 1049 |
-
demo.launch(server_name="0.0.0.0", server_port=7860, share=True
|
|
|
|
| 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 |
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")
|
|
|
|
| 1023 |
chain_input = gr.Textbox(label="Input", placeholder="Enter your request for the chain...")
|
| 1024 |
chain_sequence = gr.Textbox(label="Agent Sequence", placeholder="Comma-separated agent names (e.g., text_processing,data_analysis)")
|
| 1025 |
chain_output = gr.JSON(label="Chain Output")
|
|
|
|
| 1026 |
chain_type = gr.State("chain")
|
| 1027 |
chain_btn = gr.Button("Process Chain")
|
| 1028 |
chain_btn.click(fn=process_request, inputs=[chain_type, chain_input, chain_sequence], outputs=chain_output)
|
|
|
|
| 1047 |
|
| 1048 |
if __name__ == "__main__":
|
| 1049 |
demo = create_gradio_interface()
|
| 1050 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|