(self, params: Union[str, dict], **kwargs)
| 87 | |
| 88 | |
| 89 | def call(self, params: Union[str, dict], **kwargs) -> str: |
| 90 | assert GOOGLE_SEARCH_KEY is not None, "Please set the GOOGLE_SEARCH_KEY environment variable." |
| 91 | try: |
| 92 | query = params["query"] |
| 93 | except: |
| 94 | return "[Search] Invalid request format: Input must be a JSON object containing 'query' field" |
| 95 | |
| 96 | if isinstance(query, str): |
| 97 | response = self.google_search(query) |
| 98 | else: |
| 99 | assert isinstance(query, List) |
| 100 | with ThreadPoolExecutor(max_workers=3) as executor: |
| 101 | response = list(executor.map(self.google_search, query)) |
| 102 | response = "\n=======\n".join(response) |
| 103 | return response |
| 104 | |
| 105 | |
| 106 | ###### Test Code ###### |
no test coverage detected