Skip to content

Commit dbcb31a

Browse files
committed
fix: remove some default values, improve docstrings and error types
1 parent d2bb998 commit dbcb31a

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed

linkup/client.py

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,19 @@ async def async_content(self, url: str) -> LinkupContent:
8686
def search(
8787
self,
8888
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"],
9191
structured_output_schema: Union[Type[BaseModel], str, None] = None,
9292
) -> Any:
9393
"""
9494
Search for a query in the Linkup API.
9595
9696
Args:
9797
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
103102
supporting it, and "structured" will base the output on the format provided in
104103
structured_output_schema.
105104
structured_output_schema: If output_type is "structured", specify the schema of the
@@ -108,16 +107,14 @@ def search(
108107
109108
Returns:
110109
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.
115114
116115
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".
121118
LinkupInvalidRequestError: If structured_output_schema doesn't represent a valid object
122119
JSON schema when output_type is "structured".
123120
LinkupAuthenticationError: If the Linkup API key is invalid, or there is no more credit
@@ -148,20 +145,19 @@ def search(
148145
async def async_search(
149146
self,
150147
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"],
153150
structured_output_schema: Union[Type[BaseModel], str, None] = None,
154151
) -> Any:
155152
"""
156153
Asynchronously search for a query in the Linkup API.
157154
158155
Args:
159156
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
165161
supporting it, and "structured" will base the output on the format provided in
166162
structured_output_schema.
167163
structured_output_schema: If output_type is "structured", specify the schema of the
@@ -170,16 +166,14 @@ async def async_search(
170166
171167
Returns:
172168
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.
177173
178174
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".
183177
LinkupInvalidRequestError: If structured_output_schema doesn't represent a valid object
184178
JSON schema when output_type is "structured".
185179
LinkupAuthenticationError: If the Linkup API key is invalid, or there is no more credit
@@ -280,7 +274,7 @@ def _get_search_params(
280274

281275
if output_type == "structured":
282276
if structured_output_schema is None:
283-
raise ValueError(
277+
raise TypeError(
284278
"A structured_output_schema must be provided when using "
285279
"output_type='structured'"
286280
)

0 commit comments

Comments
 (0)