@@ -86,20 +86,19 @@ async def async_content(self, url: str) -> LinkupContent:
86
86
def search (
87
87
self ,
88
88
query : str ,
89
- depth : Literal ["standard" , "deep" ] = "standard" ,
90
- output_type : Literal ["searchResults" , "sourcedAnswer" , "structured" ] = "searchResults" ,
89
+ depth : Literal ["standard" , "deep" ],
90
+ output_type : Literal ["searchResults" , "sourcedAnswer" , "structured" ],
91
91
structured_output_schema : Union [Type [BaseModel ], str , None ] = None ,
92
92
) -> Any :
93
93
"""
94
94
Search for a query in the Linkup API.
95
95
96
96
Args:
97
97
query: The search query.
98
- depth: The depth of the search, "standard" (default) or "deep". Asking for a standard
99
- depth will make the API respond quickly. In contrast, asking for a deep depth will
100
- take longer for the API to respond, but results will be spot on.
101
- output_type: The type of output which is expected: "searchResults" (default) will output
102
- raw search results, "sourcedAnswer" will output the answer to the query and sources
98
+ depth: The depth of the search. Can be either "standard", for a straighforward and
99
+ fast search, or "deep" for a more powerful agentic workflow.
100
+ output_type: The type of output which is expected: "searchResults" will output raw
101
+ search results, "sourcedAnswer" will output the answer to the query and sources
103
102
supporting it, and "structured" will base the output on the format provided in
104
103
structured_output_schema.
105
104
structured_output_schema: If output_type is "structured", specify the schema of the
@@ -108,16 +107,14 @@ def search(
108
107
109
108
Returns:
110
109
The Linkup API search result. If output_type is "searchResults", the result will be a
111
- linkup.LinkupSearchResults. If output_type is "sourcedAnswer", the result will be a
112
- linkup.LinkupSourcedAnswer. If output_type is "structured", the result will be either an
113
- instance of the provided pydantic.BaseModel, or an arbitrary data structure, following
114
- structured_output_schema.
110
+ linkup.LinkupSearchResults. If output_type is "sourcedAnswer", the result will be a
111
+ linkup.LinkupSourcedAnswer. If output_type is "structured", the result will be
112
+ either an instance of the provided pydantic.BaseModel, or an arbitrary data
113
+ structure, following structured_output_schema.
115
114
116
115
Raises:
117
- ValueError: If structured_output_schema is not provided when output_type is
118
- "structured".
119
- TypeError: If structured_output_schema is not a string or a pydantic.BaseModel when
120
- output_type is "structured".
116
+ TypeError: If structured_output_schema is not provided or is not a string or a
117
+ pydantic.BaseModel when output_type is "structured".
121
118
LinkupInvalidRequestError: If structured_output_schema doesn't represent a valid object
122
119
JSON schema when output_type is "structured".
123
120
LinkupAuthenticationError: If the Linkup API key is invalid, or there is no more credit
@@ -148,20 +145,19 @@ def search(
148
145
async def async_search (
149
146
self ,
150
147
query : str ,
151
- depth : Literal ["standard" , "deep" ] = "standard" ,
152
- output_type : Literal ["searchResults" , "sourcedAnswer" , "structured" ] = "searchResults" ,
148
+ depth : Literal ["standard" , "deep" ],
149
+ output_type : Literal ["searchResults" , "sourcedAnswer" , "structured" ],
153
150
structured_output_schema : Union [Type [BaseModel ], str , None ] = None ,
154
151
) -> Any :
155
152
"""
156
153
Asynchronously search for a query in the Linkup API.
157
154
158
155
Args:
159
156
query: The search query.
160
- depth: The depth of the search, "standard" (default) or "deep". Asking for a standard
161
- depth will make the API respond quickly. In contrast, asking for a deep depth will
162
- take longer for the API to respond, but results will be spot on.
163
- output_type: The type of output which is expected: "searchResults" (default) will output
164
- raw search results, "sourcedAnswer" will output the answer to the query and sources
157
+ depth: The depth of the search. Can be either "standard", for a straighforward and
158
+ fast search, or "deep" for a more powerful agentic workflow.
159
+ output_type: The type of output which is expected: "searchResults" will output raw
160
+ search results, "sourcedAnswer" will output the answer to the query and sources
165
161
supporting it, and "structured" will base the output on the format provided in
166
162
structured_output_schema.
167
163
structured_output_schema: If output_type is "structured", specify the schema of the
@@ -170,16 +166,14 @@ async def async_search(
170
166
171
167
Returns:
172
168
The Linkup API search result. If output_type is "searchResults", the result will be a
173
- linkup.LinkupSearchResults. If output_type is "sourcedAnswer", the result will be a
174
- linkup.LinkupSourcedAnswer. If output_type is "structured", the result will be either an
175
- instance of the provided pydantic.BaseModel, or an arbitrary data structure, following
176
- structured_output_schema.
169
+ linkup.LinkupSearchResults. If output_type is "sourcedAnswer", the result will be a
170
+ linkup.LinkupSourcedAnswer. If output_type is "structured", the result will be
171
+ either an instance of the provided pydantic.BaseModel, or an arbitrary data
172
+ structure, following structured_output_schema.
177
173
178
174
Raises:
179
- ValueError: If structured_output_schema is not provided when output_type is
180
- "structured".
181
- TypeError: If structured_output_schema is not a string or a pydantic.BaseModel when
182
- output_type is "structured".
175
+ TypeError: If structured_output_schema is not provided or is not a string or a
176
+ pydantic.BaseModel when output_type is "structured".
183
177
LinkupInvalidRequestError: If structured_output_schema doesn't represent a valid object
184
178
JSON schema when output_type is "structured".
185
179
LinkupAuthenticationError: If the Linkup API key is invalid, or there is no more credit
@@ -280,7 +274,7 @@ def _get_search_params(
280
274
281
275
if output_type == "structured" :
282
276
if structured_output_schema is None :
283
- raise ValueError (
277
+ raise TypeError (
284
278
"A structured_output_schema must be provided when using "
285
279
"output_type='structured'"
286
280
)
0 commit comments