1- from datetime import datetime
21from typing import Any , Dict , Optional
3- from uuid import uuid4
42
53from langchain_core .tools import BaseTool
64from 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- }
0 commit comments