Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,9 @@ import pandas as pd # If you're working with DataFrames
|
|
11 |
import matplotlib.figure # If you're using matplotlib figures
|
12 |
import numpy as np
|
13 |
|
14 |
-
from custom_agent import CustomHfAgent
|
|
|
|
|
15 |
|
16 |
|
17 |
# For Altair charts
|
@@ -30,6 +32,7 @@ import pydeck as pdk
|
|
30 |
import logging
|
31 |
import streamlit as st
|
32 |
from transformers import load_tool, Agent
|
|
|
33 |
|
34 |
# Configure the logging settings for transformers
|
35 |
transformers_logger = logging.getLogger("transformers.file_utils")
|
@@ -39,20 +42,6 @@ transformers_logger.setLevel(logging.INFO) # Set the desired logging level
|
|
39 |
import time
|
40 |
import torch
|
41 |
|
42 |
-
class ToolLoader:
|
43 |
-
def __init__(self, tool_names):
|
44 |
-
self.tools = self.load_tools(tool_names)
|
45 |
-
|
46 |
-
def load_tools(self, tool_names):
|
47 |
-
loaded_tools = []
|
48 |
-
for tool_name in tool_names:
|
49 |
-
try:
|
50 |
-
tool = load_tool(tool_name)
|
51 |
-
loaded_tools.append(tool)
|
52 |
-
except Exception as e:
|
53 |
-
log_response(f"Error loading tool '{tool_name}': {e}")
|
54 |
-
return loaded_tools
|
55 |
-
|
56 |
|
57 |
def handle_submission(user_message, selected_tools, url_endpoint):
|
58 |
|
@@ -84,26 +73,7 @@ def log_response(response):
|
|
84 |
print(response)
|
85 |
|
86 |
|
87 |
-
|
88 |
-
tool_names = [
|
89 |
-
"Chris4K/random-character-tool",
|
90 |
-
"Chris4K/text-generation-tool",
|
91 |
-
"Chris4K/sentiment-tool",
|
92 |
-
"Chris4K/token-counter-tool",
|
93 |
-
"Chris4K/most-downloaded-model",
|
94 |
-
"Chris4K/rag-tool",
|
95 |
-
"Chris4K/word-counter-tool",
|
96 |
-
"Chris4K/sentence-counter-tool",
|
97 |
-
"Chris4K/EmojifyTextTool",
|
98 |
-
"Chris4K/NamedEntityRecognitionTool",
|
99 |
-
"Chris4K/TextDownloadTool",
|
100 |
-
"Chris4K/source-code-retriever-tool",
|
101 |
-
"Chris4K/text-to-image",
|
102 |
-
"Chris4K/text-to-video",
|
103 |
-
"Chris4K/image-transformation",
|
104 |
-
"Chris4K/latent-upscaler-tool"
|
105 |
-
# More cool tools to come
|
106 |
-
]
|
107 |
|
108 |
# Create tool loader instance
|
109 |
tool_loader = ToolLoader(tool_names)
|
|
|
11 |
import matplotlib.figure # If you're using matplotlib figures
|
12 |
import numpy as np
|
13 |
|
14 |
+
from custom_agent import CustomHfAgent
|
15 |
+
from tool_loader import ToolLoader
|
16 |
+
from tool_config import tool_names
|
17 |
|
18 |
|
19 |
# For Altair charts
|
|
|
32 |
import logging
|
33 |
import streamlit as st
|
34 |
from transformers import load_tool, Agent
|
35 |
+
from tool_loader import ToolLoader
|
36 |
|
37 |
# Configure the logging settings for transformers
|
38 |
transformers_logger = logging.getLogger("transformers.file_utils")
|
|
|
42 |
import time
|
43 |
import torch
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
def handle_submission(user_message, selected_tools, url_endpoint):
|
47 |
|
|
|
73 |
print(response)
|
74 |
|
75 |
|
76 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
# Create tool loader instance
|
79 |
tool_loader = ToolLoader(tool_names)
|