Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,8 +36,8 @@ class GraphInput(BaseModel):
|
|
| 36 |
y_label: str = Field(description="Y-axis label", default="")
|
| 37 |
|
| 38 |
class CreateGraphTool(BaseTool):
|
| 39 |
-
name = "create_graph"
|
| 40 |
-
description = """Generates a plot (bar, line, or pie) and returns it as an HTML-formatted Base64-encoded image string. Use this tool when teaching concepts that benefit from visual representation, such as: statistical distributions, mathematical functions, data comparisons, survey results, grade analyses, scientific relationships, economic models, or any quantitative information that would be clearer with a graph. The data and labels arguments must be JSON-encoded strings."""
|
| 41 |
args_schema: Type[BaseModel] = GraphInput
|
| 42 |
|
| 43 |
def _run(self, data_json: str, labels_json: str, plot_type: str,
|
|
@@ -54,6 +54,7 @@ class CreateGraphTool(BaseTool):
|
|
| 54 |
except Exception as e:
|
| 55 |
return f"<p style='color:red;'>Error creating graph: {str(e)}</p>"
|
| 56 |
|
|
|
|
| 57 |
# --- LangChain Setup ---
|
| 58 |
def create_langchain_agent():
|
| 59 |
"""Initialize LangChain agent with tools and memory."""
|
|
|
|
| 36 |
y_label: str = Field(description="Y-axis label", default="")
|
| 37 |
|
| 38 |
class CreateGraphTool(BaseTool):
|
| 39 |
+
name: str = "create_graph"
|
| 40 |
+
description: str = """Generates a plot (bar, line, or pie) and returns it as an HTML-formatted Base64-encoded image string. Use this tool when teaching concepts that benefit from visual representation, such as: statistical distributions, mathematical functions, data comparisons, survey results, grade analyses, scientific relationships, economic models, or any quantitative information that would be clearer with a graph. The data and labels arguments must be JSON-encoded strings."""
|
| 41 |
args_schema: Type[BaseModel] = GraphInput
|
| 42 |
|
| 43 |
def _run(self, data_json: str, labels_json: str, plot_type: str,
|
|
|
|
| 54 |
except Exception as e:
|
| 55 |
return f"<p style='color:red;'>Error creating graph: {str(e)}</p>"
|
| 56 |
|
| 57 |
+
|
| 58 |
# --- LangChain Setup ---
|
| 59 |
def create_langchain_agent():
|
| 60 |
"""Initialize LangChain agent with tools and memory."""
|