11
11
ApiProcessorInterface ,
12
12
ApiProcessorSchema ,
13
13
)
14
+ from llmstack .processors .providers .apollo .people_search import APIResponse
14
15
from llmstack .processors .providers .metrics import MetricType
15
16
16
17
logger = logging .getLogger (__name__ )
@@ -50,21 +51,22 @@ class OrganizationSearchInput(ApiProcessorSchema):
50
51
51
52
52
53
class 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 = []
56
58
)
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 = {})
61
67
62
68
63
69
class 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
- )
68
70
page : Optional [int ] = Field (
69
71
description = "The page number to return" ,
70
72
default = 1 ,
@@ -101,7 +103,7 @@ def provider_slug() -> str:
101
103
@classmethod
102
104
def get_output_template (cls ) -> OutputTemplate | None :
103
105
return OutputTemplate (
104
- markdown = "{{response}}" ,
106
+ markdown = "{{api_response. response}}" ,
105
107
jsonpath = "$.accounts" ,
106
108
)
107
109
@@ -114,18 +116,23 @@ def process(self) -> dict:
114
116
if not values :
115
117
continue
116
118
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" :
119
126
query_params_str += f"&organization_num_employees_ranges[]={ ',' .join (values )} "
120
- elif key == "organization_locations" and values :
127
+ elif key == "organization_locations" :
121
128
query_params_str += f"&organization_locations[]={ ',' .join (values )} "
122
- elif key == "organization_not_locations" and values :
129
+ elif key == "organization_not_locations" :
123
130
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" :
125
132
query_params_str += f"&q_organization_keyword_tags[]={ ',' .join (values )} "
126
- elif key == "q_organization_name" and values :
133
+ elif key == "q_organization_name" :
127
134
query_params_str += f"&q_organization_name={ values } "
128
- elif key == "organization_ids" and values :
135
+ elif key == "organization_ids" :
129
136
query_params_str += f"&organization_ids[]={ ',' .join (values )} "
130
137
131
138
if query_params_str :
@@ -156,13 +163,18 @@ def process(self) -> dict:
156
163
157
164
async_to_sync (self ._output_stream .write )(
158
165
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" , []),
166
178
)
167
179
)
168
180
0 commit comments