Skip to content

Commit ff4bbba

Browse files
committed
feat: include_inline_citations parameter for search
1 parent 7b64e4e commit ff4bbba

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/linkup/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def search(
5757
include_domains: Union[list[str], None] = None,
5858
from_date: Union[date, None] = None,
5959
to_date: Union[date, None] = None,
60+
include_inline_citations: bool = False,
6061
) -> Any:
6162
"""
6263
Search for a query in the Linkup API.
@@ -79,6 +80,8 @@ def search(
7980
search results will not be filtered by date.
8081
to_date: The date until which the search results should be considered. If None, the
8182
search results will not be filtered by date.
83+
include_inline_citations: If output_type is "sourcedAnswer", indicates whether the
84+
answer should include inline citations.
8285
8386
Returns:
8487
The Linkup API search result. If output_type is "searchResults", the result will be a
@@ -106,6 +109,7 @@ def search(
106109
include_domains=include_domains,
107110
from_date=from_date,
108111
to_date=to_date,
112+
include_inline_citations=include_inline_citations,
109113
)
110114

111115
response: httpx.Response = self._request(
@@ -134,6 +138,7 @@ async def async_search(
134138
include_domains: Union[list[str], None] = None,
135139
from_date: Union[date, None] = None,
136140
to_date: Union[date, None] = None,
141+
include_inline_citations: bool = False,
137142
) -> Any:
138143
"""
139144
Asynchronously search for a query in the Linkup API.
@@ -156,6 +161,8 @@ async def async_search(
156161
search results will not be filtered by date.
157162
to_date: The date until which the search results should be considered. If None, the
158163
search results will not be filtered by date.
164+
include_inline_citations: If output_type is "sourcedAnswer", indicates whether the
165+
answer should include inline citations.
159166
160167
Returns:
161168
The Linkup API search result. If output_type is "searchResults", the result will be a
@@ -182,6 +189,7 @@ async def async_search(
182189
include_domains=include_domains,
183190
from_date=from_date,
184191
to_date=to_date,
192+
include_inline_citations=include_inline_citations,
185193
)
186194

187195
response: httpx.Response = await self._async_request(
@@ -316,6 +324,7 @@ def _get_search_params(
316324
include_domains: Union[list[str], None],
317325
from_date: Union[date, None],
318326
to_date: Union[date, None],
327+
include_inline_citations: bool,
319328
) -> dict[str, Union[str, bool, list[str]]]:
320329
structured_output_schema_param: str = ""
321330
if structured_output_schema is not None:
@@ -339,6 +348,7 @@ def _get_search_params(
339348
includeDomains=include_domains or [],
340349
fromDate=from_date.isoformat() if from_date is not None else "",
341350
toDate=to_date.isoformat() if to_date is not None else "",
351+
includeInlineCitations=include_inline_citations,
342352
)
343353

344354
def _validate_search_response(

tests/unit/client_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Company(BaseModel):
4444
"includeDomains": [],
4545
"fromDate": "",
4646
"toDate": "",
47+
"includeInlineCitations": False,
4748
},
4849
b"""
4950
{
@@ -84,6 +85,7 @@ class Company(BaseModel):
8485
"to_date": date(2023, 12, 31),
8586
"include_domains": ["example.com", "example.org"],
8687
"exclude_domains": ["excluded.com"],
88+
"include_inline_citations": True,
8789
},
8890
{
8991
"q": "A long query.",
@@ -95,6 +97,7 @@ class Company(BaseModel):
9597
"includeDomains": ["example.com", "example.org"],
9698
"fromDate": "2023-01-01",
9799
"toDate": "2023-12-31",
100+
"includeInlineCitations": True,
98101
},
99102
b'{"results": []}',
100103
LinkupSearchResults(results=[]),
@@ -111,6 +114,7 @@ class Company(BaseModel):
111114
"includeDomains": [],
112115
"fromDate": "",
113116
"toDate": "",
117+
"includeInlineCitations": False,
114118
},
115119
b"""
116120
{
@@ -160,6 +164,7 @@ class Company(BaseModel):
160164
"includeDomains": [],
161165
"fromDate": "",
162166
"toDate": "",
167+
"includeInlineCitations": False,
163168
},
164169
b"""
165170
{
@@ -193,6 +198,7 @@ class Company(BaseModel):
193198
"includeDomains": [],
194199
"fromDate": "",
195200
"toDate": "",
201+
"includeInlineCitations": False,
196202
},
197203
b"""
198204
{

0 commit comments

Comments
 (0)