Spaces:
Sleeping
Sleeping
to return json
Browse files
app.py
CHANGED
|
@@ -117,7 +117,7 @@ class SimilarityModel:
|
|
| 117 |
try:
|
| 118 |
assert isinstance(tools_data, list) and all(isinstance(d, dict) for d in tools_data)
|
| 119 |
except AssertionError:
|
| 120 |
-
return tools_data, [{"Error": tools_data}]
|
| 121 |
|
| 122 |
# Create a unique key for caching based on the tools data
|
| 123 |
tools_cache_key = json.dumps(tools_data, sort_keys=True)
|
|
@@ -150,7 +150,7 @@ class SimilarityModel:
|
|
| 150 |
if not top_tools:
|
| 151 |
output_text = "No tools found."
|
| 152 |
|
| 153 |
-
return output_text, top_tools
|
| 154 |
|
| 155 |
def create_ui(model: SimilarityModel):
|
| 156 |
"""Pretty UI with Gradio for user to interact with"""
|
|
@@ -161,7 +161,7 @@ def create_ui(model: SimilarityModel):
|
|
| 161 |
inputs=[
|
| 162 |
gr.Textbox(label="Query"),
|
| 163 |
gr.Textbox(
|
| 164 |
-
lines=
|
| 165 |
label="Define tool declaration here",
|
| 166 |
info="Please enter a valid JSON string. For e.g, a list of dict's (name & desc π).",
|
| 167 |
placeholder='''[
|
|
|
|
| 117 |
try:
|
| 118 |
assert isinstance(tools_data, list) and all(isinstance(d, dict) for d in tools_data)
|
| 119 |
except AssertionError:
|
| 120 |
+
return tools_data, json.dumps([{"Error": tools_data}])
|
| 121 |
|
| 122 |
# Create a unique key for caching based on the tools data
|
| 123 |
tools_cache_key = json.dumps(tools_data, sort_keys=True)
|
|
|
|
| 150 |
if not top_tools:
|
| 151 |
output_text = "No tools found."
|
| 152 |
|
| 153 |
+
return output_text, json.dumps(top_tools)
|
| 154 |
|
| 155 |
def create_ui(model: SimilarityModel):
|
| 156 |
"""Pretty UI with Gradio for user to interact with"""
|
|
|
|
| 161 |
inputs=[
|
| 162 |
gr.Textbox(label="Query"),
|
| 163 |
gr.Textbox(
|
| 164 |
+
lines=6,
|
| 165 |
label="Define tool declaration here",
|
| 166 |
info="Please enter a valid JSON string. For e.g, a list of dict's (name & desc π).",
|
| 167 |
placeholder='''[
|