Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .mdformat.toml

This file was deleted.

6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ repos:
args: [--fix]
- id: ruff-format

- repo: https://github.com/hukkin/mdformat
rev: 0.7.22
- repo: https://github.com/rvben/rumdl-pre-commit
rev: v0.1.46
hooks:
- id: mdformat
- id: rumdl-fmt
exclude: CHANGELOG.md

- repo: https://github.com/ComPWA/taplo-pre-commit
Expand Down
14 changes: 14 additions & 0 deletions .rumdl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[global]
line-length = 100

[MD013]
reflow = true

[MD032]
allow-lazy-continuation = false

[MD033]
allowed-elements = ["details", "summary"]

[per-file-ignores]
".github/pull_request_template.md" = ["MD041"]
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ When adding or changing a public API capability, update the relevant pieces toge
- request/response typing and models,
- sync and async behavior when applicable,
- tests,
- README/examples if the user-facing API changed.
- README if the user-facing API changed.

## Validation

Expand Down
53 changes: 22 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ pip install linkup-sdk[x402]

```python
import os
from linkup import LinkupClient
import linkup

os.environ["LINKUP_API_KEY"] = "<your-linkup-api-key>"
# or dotenv.load_dotenv()
client = LinkupClient()
client = linkup.Client()
...
```

Option 3: Pass the Linkup API key to the Linkup Client when creating it.

```python
from linkup import LinkupClient
import linkup

client = LinkupClient(api_key="<your-linkup-api-key>")
client = linkup.Client(api_key="<your-linkup-api-key>")
...
```

Expand All @@ -99,16 +99,16 @@ The `search` function also supports three output types:
```python
from typing import Any

from linkup import LinkupClient, LinkupSourcedAnswer
import linkup

client = LinkupClient() # API key can be read from the environment variable or passed as an argument
client = linkup.Client() # API key can be read from the environment variable or passed as an argument
search_response: Any = client.search(
query="What are the 3 major events in the life of Abraham Lincoln?",
depth="deep", # "standard" or "deep"
output_type="sourcedAnswer", # "searchResults" or "sourcedAnswer" or "structured"
structured_output_schema=None, # must be filled if output_type is "structured"
)
assert isinstance(search_response, LinkupSourcedAnswer)
assert isinstance(search_response, linkup.SourcedAnswer)
print(search_response.model_dump())
```

Expand Down Expand Up @@ -142,10 +142,10 @@ You can use the `render_js` flag to execute the JavaScript code of the page befo
content, and ask to `include_raw_html` to the response if you feel like it.

```python
from linkup import LinkupClient, LinkupFetchResponse
import linkup

client = LinkupClient() # API key can be read from the environment variable or passed as an argument
fetch_response: LinkupFetchResponse = client.fetch(
client = linkup.Client() # API key can be read from the environment variable or passed as an argument
fetch_response: linkup.FetchResponse = client.fetch(
url="https://docs.linkup.so",
render_js=False,
include_raw_html=True,
Expand All @@ -172,10 +172,10 @@ The `research` function creates an asynchronous research task. You can then use
`list_research` to inspect it later.

```python
from linkup import LinkupClient, LinkupResearchTask
import linkup

client = LinkupClient()
research_task: LinkupResearchTask = client.research(
client = linkup.Client()
research_task: linkup.ResearchTask = client.research(
query="What changed in the AI browser market this quarter?",
output_type="sourcedAnswer",
)
Expand All @@ -188,21 +188,17 @@ The `create_tasks` function lets you submit mixed `search`, `fetch`, and `resear
batch, then inspect them through `get_task` or `list_tasks`.

```python
from linkup import (
LinkupClient,
LinkupFetchTaskInput,
LinkupSearchTaskInput,
)
import linkup

client = LinkupClient()
client = linkup.Client()
tasks = client.create_tasks(
[
LinkupSearchTaskInput(
linkup.SearchTaskInput(
query="Linkup latest product updates",
depth="deep",
output_type="sourcedAnswer",
),
LinkupFetchTaskInput(
linkup.FetchTaskInput(
url="https://docs.linkup.so",
),
]
Expand All @@ -221,17 +217,17 @@ This makes possible to call the Linkup API several times concurrently for instan
import asyncio
from typing import Any

from linkup import LinkupClient, LinkupSourcedAnswer
import linkup

async def main() -> None:
client = LinkupClient() # API key can be read from the environment variable or passed as an argument
client = linkup.Client() # API key can be read from the environment variable or passed as an argument
search_response: Any = await client.async_search(
query="What are the 3 major events in the life of Abraham Lincoln?",
depth="deep", # "standard" or "deep"
output_type="sourcedAnswer", # "searchResults" or "sourcedAnswer" or "structured"
structured_output_schema=None, # must be filled if output_type is "structured"
)
assert isinstance(search_response, LinkupSourcedAnswer)
assert isinstance(search_response, linkup.SourcedAnswer)
print(search_response.model_dump())

asyncio.run(main())
Expand Down Expand Up @@ -279,11 +275,11 @@ account = Account.from_mnemonic("<YOUR MNEMONIC PHRASE>")
Then pass it to `create_x402_signer` and use the Linkup client:

```python
from linkup import LinkupClient
import linkup
from linkup.x402 import create_x402_signer

signer = create_x402_signer(account)
client = LinkupClient(x402_signer=signer)
client = linkup.Client(x402_signer=signer)

result = client.search(
query="What is x402?",
Expand All @@ -292,8 +288,3 @@ result = client.search(
)
print(result.answer)
```

#### 📚 More Examples

See the `examples/` directory for more examples and documentation, for instance on how to use Linkup
entrypoints using asynchronous functions to call the Linkup API several times concurrenly.
23 changes: 0 additions & 23 deletions examples/1_search_results_search.py

This file was deleted.

25 changes: 0 additions & 25 deletions examples/2_sourced_answer_search.py

This file was deleted.

37 changes: 0 additions & 37 deletions examples/3_structured_search.py

This file was deleted.

49 changes: 0 additions & 49 deletions examples/4_asynchronous_search.py

This file was deleted.

20 changes: 0 additions & 20 deletions examples/5_fetch.py

This file was deleted.

8 changes: 0 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Homepage = "https://github.com/LinkupPlatform/linkup-python-sdk"
Source = "https://github.com/LinkupPlatform/linkup-python-sdk"
Tracker = "https://github.com/LinkupPlatform/linkup-python-sdk/issues"


[dependency-groups]
dev = [
"prek>=0.3.5",
Expand All @@ -53,13 +52,11 @@ typeCheckingMode = "strict"
[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "function"


[tool.coverage.report]
exclude_also = ["raise TypeError", "raise ValueError"]
show_missing = true
skip_covered = true


[tool.ruff]
line-length = 100
target-version = "py310"
Expand Down Expand Up @@ -106,7 +103,6 @@ select = [
]

[tool.ruff.lint.extend-per-file-ignores]
"examples/*.py" = ["D"]
"src/linkup/__init__.py" = ["D104"]
"tests/**/*test.py" = ["D", "S101"]

Expand All @@ -121,11 +117,9 @@ ignore = [
[tool.ruff.lint.flake8-type-checking]
runtime-evaluated-base-classes = ["pydantic.BaseModel"]


[tool.hatch.build.targets.wheel]
packages = ["src/linkup"] # Because project and source code directory names differ


[tool.semantic_release]
allow_zero_version = true
build_command = """
Expand All @@ -141,12 +135,10 @@ version_toml = ["pyproject.toml:project.version"]
[tool.semantic_release.commit_parser_options]
parse_squash_commits = false


[tool.uv]
exclude-newer = "2 weeks" # Reduce risks of supply chain attacks
required-version = ">=0.10.0,<0.11.0"

[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]

Loading
Loading