Spaces:
Sleeping
Sleeping
fix some tool constructors
Browse files
tools.py
CHANGED
|
@@ -35,7 +35,7 @@ class ReadFileTool(Tool):
|
|
| 35 |
}
|
| 36 |
output_type = 'string'
|
| 37 |
|
| 38 |
-
def __init__():
|
| 39 |
"""Nothing to do for this class here, but kick the constructor of the base class."""
|
| 40 |
super().__init__()
|
| 41 |
|
|
@@ -66,7 +66,7 @@ class OpenAISpeechToTextTool(Tool):
|
|
| 66 |
}
|
| 67 |
output_type = 'string'
|
| 68 |
|
| 69 |
-
def __init__():
|
| 70 |
"""Nothing to do for this class here, but kick the constructor of the base class."""
|
| 71 |
super().__init__()
|
| 72 |
|
|
@@ -101,7 +101,7 @@ class YouTubeTranscriptionTool(Tool):
|
|
| 101 |
}
|
| 102 |
output_type = 'string'
|
| 103 |
|
| 104 |
-
def __init__():
|
| 105 |
"""Nothing to do for this class here, but kick the constructor of the base class."""
|
| 106 |
super().__init__()
|
| 107 |
|
|
@@ -144,9 +144,10 @@ class DescribeImageTool(Tool):
|
|
| 144 |
}
|
| 145 |
output_type = 'string'
|
| 146 |
|
| 147 |
-
|
| 148 |
|
| 149 |
-
|
|
|
|
| 150 |
"""ensure, that the super class is instantiated properly and creat an OpenAI client (if not already done)."""
|
| 151 |
super().__init__()
|
| 152 |
|
|
@@ -154,7 +155,7 @@ class DescribeImageTool(Tool):
|
|
| 154 |
openai_api_key = os.environ.get('REAL_OPENAI_API_KEY', # just in case we run with other openAI compatibel providers
|
| 155 |
os.environ.get('OPENAI_API_KEY')
|
| 156 |
)
|
| 157 |
-
|
| 158 |
|
| 159 |
|
| 160 |
def encode_image(self, image_path: str) -> str:
|
|
@@ -261,6 +262,7 @@ def get_tools() -> List[Tool]:
|
|
| 261 |
|
| 262 |
authorized_imports = ['requests',
|
| 263 |
'markdownify',
|
|
|
|
| 264 |
]
|
| 265 |
|
| 266 |
try:
|
|
|
|
| 35 |
}
|
| 36 |
output_type = 'string'
|
| 37 |
|
| 38 |
+
def __init__(self):
|
| 39 |
"""Nothing to do for this class here, but kick the constructor of the base class."""
|
| 40 |
super().__init__()
|
| 41 |
|
|
|
|
| 66 |
}
|
| 67 |
output_type = 'string'
|
| 68 |
|
| 69 |
+
def __init__(self):
|
| 70 |
"""Nothing to do for this class here, but kick the constructor of the base class."""
|
| 71 |
super().__init__()
|
| 72 |
|
|
|
|
| 101 |
}
|
| 102 |
output_type = 'string'
|
| 103 |
|
| 104 |
+
def __init__(self):
|
| 105 |
"""Nothing to do for this class here, but kick the constructor of the base class."""
|
| 106 |
super().__init__()
|
| 107 |
|
|
|
|
| 144 |
}
|
| 145 |
output_type = 'string'
|
| 146 |
|
| 147 |
+
_client = None # OpenAI (compatible) client. Instantiated on first use
|
| 148 |
|
| 149 |
+
|
| 150 |
+
def __init__(self):
|
| 151 |
"""ensure, that the super class is instantiated properly and creat an OpenAI client (if not already done)."""
|
| 152 |
super().__init__()
|
| 153 |
|
|
|
|
| 155 |
openai_api_key = os.environ.get('REAL_OPENAI_API_KEY', # just in case we run with other openAI compatibel providers
|
| 156 |
os.environ.get('OPENAI_API_KEY')
|
| 157 |
)
|
| 158 |
+
self.__class__._client = OpenAI(api_key=openai_api_key)
|
| 159 |
|
| 160 |
|
| 161 |
def encode_image(self, image_path: str) -> str:
|
|
|
|
| 262 |
|
| 263 |
authorized_imports = ['requests',
|
| 264 |
'markdownify',
|
| 265 |
+
'wikipedia-api',
|
| 266 |
]
|
| 267 |
|
| 268 |
try:
|