1111 ApiProcessorInterface ,
1212 ApiProcessorSchema ,
1313)
14+ from llmstack .processors .providers .apollo .people_search import APIResponse
1415from llmstack .processors .providers .metrics import MetricType
1516
1617logger = logging .getLogger (__name__ )
@@ -50,21 +51,22 @@ class OrganizationSearchInput(ApiProcessorSchema):
5051
5152
5253class OrganizationSearchOutput (ApiProcessorSchema ):
53- response : str = Field (description = "The response from the API call as a string" , default = "" )
54- response_json : Optional [Dict [str , Any ]] = Field (
55- description = "The response from the API call as a JSON object" , default = {}
54+ breadcrumbs : Optional [List [Dict [str , str ]]] = Field (description = "The breadcrumbs for the API call" , default = [])
55+ accounts : Optional [List [Dict [str , Any ]]] = Field (description = "The list of accounts from the API call" , default = [])
56+ organizations : Optional [List [Dict [str , Any ]]] = Field (
57+ description = "The list of organizations from the API call" , default = []
5658 )
57- headers : Optional [Dict [str , str ]] = Field (description = "The headers from the API call" , default = {})
58- code : int = Field (description = "The status code from the API call" , default = 200 )
59- size : int = Field (description = "The size of the response from the API call" , default = 0 )
60- time : float = Field (description = "The time it took to get the response from the API call" , default = 0.0 )
59+ api_response : APIResponse = Field (description = "The response from the API call" , default = {})
60+
61+
62+ class PeopleSearchOutput (ApiProcessorSchema ):
63+ breadcrumbs : Optional [List [Dict [str , str ]]] = Field (description = "The breadcrumbs for the API call" , default = [])
64+ people : Optional [List [Dict [str , Any ]]] = Field (description = "The list of people from the API call" , default = [])
65+ contacts : Optional [List [Dict [str , Any ]]] = Field (description = "The list of contacts for the API call" , default = [])
66+ api_response : APIResponse = Field (description = "The response from the API call" , default = {})
6167
6268
6369class OrganizationSearchConfiguration (ApiProcessorSchema ):
64- connection_id : Optional [str ] = Field (
65- description = "The connection id to use for the API call" ,
66- json_schema_extra = {"advanced_parameter" : False , "widget" : "connection" },
67- )
6870 page : Optional [int ] = Field (
6971 description = "The page number to return" ,
7072 default = 1 ,
@@ -101,7 +103,7 @@ def provider_slug() -> str:
101103 @classmethod
102104 def get_output_template (cls ) -> OutputTemplate | None :
103105 return OutputTemplate (
104- markdown = "{{response}}" ,
106+ markdown = "{{api_response. response}}" ,
105107 jsonpath = "$.accounts" ,
106108 )
107109
@@ -114,18 +116,23 @@ def process(self) -> dict:
114116 if not values :
115117 continue
116118
117- values = [urllib .parse .quote (value ) for value in values ]
118- if key == "organization_num_employees_ranges" and values :
119+ values = (
120+ [urllib .parse .quote (value ) for value in values ]
121+ if isinstance (values , list )
122+ else urllib .parse .quote (str (values ))
123+ )
124+
125+ if key == "organization_num_employees_ranges" :
119126 query_params_str += f"&organization_num_employees_ranges[]={ ',' .join (values )} "
120- elif key == "organization_locations" and values :
127+ elif key == "organization_locations" :
121128 query_params_str += f"&organization_locations[]={ ',' .join (values )} "
122- elif key == "organization_not_locations" and values :
129+ elif key == "organization_not_locations" :
123130 query_params_str += f"&organization_not_locations[]={ ',' .join (values )} "
124- elif key == "q_organization_keyword_tags" and values :
131+ elif key == "q_organization_keyword_tags" :
125132 query_params_str += f"&q_organization_keyword_tags[]={ ',' .join (values )} "
126- elif key == "q_organization_name" and values :
133+ elif key == "q_organization_name" :
127134 query_params_str += f"&q_organization_name={ values } "
128- elif key == "organization_ids" and values :
135+ elif key == "organization_ids" :
129136 query_params_str += f"&organization_ids[]={ ',' .join (values )} "
130137
131138 if query_params_str :
@@ -156,13 +163,18 @@ def process(self) -> dict:
156163
157164 async_to_sync (self ._output_stream .write )(
158165 OrganizationSearchOutput (
159- response = response_text ,
160- response_json = response_json ,
161- response_objref = objref ,
162- headers = dict (response .headers ),
163- code = response .status_code ,
164- size = len (response .text ),
165- time = response .elapsed .total_seconds (),
166+ api_response = APIResponse (
167+ response = response_text ,
168+ response_json = response_json ,
169+ response_objref = objref ,
170+ headers = dict (response .headers ),
171+ code = response .status_code ,
172+ size = len (response .text ),
173+ time = response .elapsed .total_seconds (),
174+ ),
175+ breadcrumbs = response_json .get ("breadcrumbs" , []),
176+ accounts = response_json .get ("accounts" , []),
177+ organizations = response_json .get ("organizations" , []),
166178 )
167179 )
168180
0 commit comments