Skip to content

Commit 8f4c9d2

Browse files
committed
fix: removed feedback endpoint
1 parent b69c08e commit 8f4c9d2

File tree

6 files changed

+7
-185
lines changed

6 files changed

+7
-185
lines changed

examples/submit_feedback_tool.py

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from .credits import GetCreditsTool
2-
from .feedback import SubmitFeedbackTool
32
from .smartscraper import SmartscraperTool
43

5-
__all__ = ["SmartscraperTool", "GetCreditsTool", "SubmitFeedbackTool"]
4+
__all__ = ["SmartscraperTool", "GetCreditsTool"]

langchain_scrapegraph/tools/feedback.py

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
11
"""Integration tests for ScrapeGraph AI tools.
22
3-
To run these tests, you need a ScrapeGraph AI API key.
3+
To run these tests, you need a ScrapeGraphAI API key.
44
You can get a test key from https://scrapegraphai.com
55
66
Set the SGAI_API_KEY environment variable to run these tests.
77
"""
88

99
import os
10-
from typing import ClassVar, Type
10+
from typing import Type
1111

1212
import pytest
1313
from dotenv import load_dotenv
1414
from langchain_tests.integration_tests import ToolsIntegrationTests
1515

16-
from langchain_scrapegraph.tools import (
17-
GetCreditsTool,
18-
SmartscraperTool,
19-
SubmitFeedbackTool,
20-
)
16+
from langchain_scrapegraph.tools import GetCreditsTool, SmartscraperTool
2117

2218
# Load environment variables from .env file
2319
load_dotenv()
2420

2521

2622
class TestSmartscraperToolIntegration(ToolsIntegrationTests):
27-
request_id: ClassVar[str] = "" # Class variable to store request_id
28-
2923
@property
3024
def tool_constructor(self) -> Type[SmartscraperTool]:
3125
return SmartscraperTool
@@ -40,19 +34,10 @@ def tool_constructor_params(self) -> dict:
4034
@property
4135
def tool_invoke_params_example(self) -> dict:
4236
return {
43-
"user_prompt": "TEST. Extract the main heading.",
37+
"user_prompt": "Extract the main heading.",
4438
"website_url": "https://example.com",
4539
}
4640

47-
@pytest.mark.xfail(reason="Overridden to capture request_id for feedback test")
48-
def test_invoke_matches_output_schema(self) -> None:
49-
"""Override to capture request_id"""
50-
tool = self.get_tool()
51-
result = tool._run(**self.tool_invoke_params_example)
52-
# Store the request_id for use in feedback test
53-
TestSmartscraperToolIntegration.request_id = result.get("request_id", "")
54-
assert isinstance(result, dict)
55-
5641

5742
class TestGetCreditsToolIntegration(ToolsIntegrationTests):
5843
@property
@@ -69,26 +54,3 @@ def tool_constructor_params(self) -> dict:
6954
@property
7055
def tool_invoke_params_example(self) -> dict:
7156
return {} # GetCredits doesn't require any parameters
72-
73-
74-
class TestSubmitFeedbackToolIntegration(ToolsIntegrationTests):
75-
@property
76-
def tool_constructor(self) -> Type[SubmitFeedbackTool]:
77-
return SubmitFeedbackTool
78-
79-
@property
80-
def tool_constructor_params(self) -> dict:
81-
api_key = os.getenv("SGAI_API_KEY")
82-
if not api_key:
83-
pytest.skip("SGAI_API_KEY environment variable not set")
84-
return {"api_key": api_key}
85-
86-
@property
87-
def tool_invoke_params_example(self) -> dict:
88-
if not TestSmartscraperToolIntegration.request_id:
89-
pytest.skip("No request_id available from smartscraper test")
90-
return {
91-
"request_id": TestSmartscraperToolIntegration.request_id,
92-
"rating": 5,
93-
"feedback_text": "Test feedback",
94-
}

tests/unit_tests/mocks.py

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from datetime import datetime
21
from typing import Any, Dict, Optional
3-
from uuid import uuid4
42

53
from langchain_core.tools import BaseTool
64
from pydantic import BaseModel, Field
@@ -10,12 +8,11 @@ class MockSyncClient:
108
def __init__(self, api_key: str = None, *args, **kwargs):
119
"""Initialize with mock methods that return proper response structures"""
1210
self._api_key = api_key
13-
self._request_id = str(uuid4()) # Generate a consistent request_id for tests
1411

1512
def smartscraper(self, website_url: str, user_prompt: str) -> dict:
1613
"""Mock smartscraper method"""
1714
return {
18-
"request_id": self._request_id,
15+
"request_id": "test-id",
1916
"status": "completed",
2017
"website_url": website_url,
2118
"user_prompt": user_prompt,
@@ -30,15 +27,6 @@ def get_credits(self) -> dict:
3027
"""Mock get_credits method"""
3128
return {"remaining_credits": 50, "total_credits_used": 543}
3229

33-
def submit_feedback(self, request_id: str, rating: int, feedback_text: str) -> dict:
34-
"""Mock submit_feedback method"""
35-
return {
36-
"feedback_id": str(uuid4()),
37-
"request_id": request_id,
38-
"message": "Feedback submitted successfully",
39-
"feedback_timestamp": datetime.now().isoformat(),
40-
}
41-
4230
def close(self) -> None:
4331
"""Mock close method"""
4432
pass
@@ -68,24 +56,3 @@ class MockGetCreditsTool(BaseTool):
6856

6957
def _run(self, **kwargs: Any) -> Dict:
7058
return {"remaining_credits": 50, "total_credits_used": 543}
71-
72-
73-
class MockSubmitFeedbackInput(BaseModel):
74-
request_id: str = Field(description="Test request ID")
75-
rating: int = Field(description="Test rating")
76-
feedback_text: str = Field(description="Test feedback")
77-
78-
79-
class MockSubmitFeedbackTool(BaseTool):
80-
name: str = "SubmitFeedback"
81-
description: str = "Test description"
82-
args_schema: type[BaseModel] = MockSubmitFeedbackInput
83-
client: Optional[MockSyncClient] = None
84-
api_key: str
85-
86-
def _run(self, **kwargs: Any) -> Dict:
87-
return {
88-
"feedback_id": "test-id",
89-
"message": "Success",
90-
"feedback_timestamp": "2024-01-01T00:00:00",
91-
}

tests/unit_tests/test_tools.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33

44
from langchain_tests.unit_tests import ToolsUnitTests
55

6-
from langchain_scrapegraph.tools import (
7-
GetCreditsTool,
8-
SmartscraperTool,
9-
SubmitFeedbackTool,
10-
)
6+
from langchain_scrapegraph.tools import GetCreditsTool, SmartscraperTool
117
from tests.unit_tests.mocks import (
128
MockGetCreditsTool,
139
MockSmartscraperTool,
14-
MockSubmitFeedbackTool,
1510
MockSyncClient,
1611
)
1712

@@ -49,22 +44,3 @@ def tool_constructor_params(self) -> dict:
4944
@property
5045
def tool_invoke_params_example(self) -> dict:
5146
return {}
52-
53-
54-
class TestSubmitFeedbackToolUnit(ToolsUnitTests):
55-
@property
56-
def tool_constructor(self) -> Type[SubmitFeedbackTool]:
57-
return MockSubmitFeedbackTool
58-
59-
@property
60-
def tool_constructor_params(self) -> dict:
61-
with patch("langchain_scrapegraph.tools.feedback.SyncClient", MockSyncClient):
62-
return {"api_key": "sgai-test-api-key"}
63-
64-
@property
65-
def tool_invoke_params_example(self) -> dict:
66-
return {
67-
"request_id": "test-request-id",
68-
"rating": 5,
69-
"feedback_text": "Test feedback",
70-
}

0 commit comments

Comments
 (0)