Skip to main content

linkup-monitor: a monitoring solution for world's best search for AI apps

Project description

LinkUp Monitor

A monitoring solution for world's best search for AI apps.

linkup-monitor is a python package aimed at providing a monitoring solution for Linkup, a web searching tool that allows you to scrape LLM-friendly answers from the web. linkup-monitor exploits PostgreSQL as a backend database and monitors queries, execution times, success status, search type and output type, allowing for a broad control over search analytics.

Installation and usage

linkup-monitor can be installed using pip in the following way:

pip install linkup-monitor
# or, for a faster installation
uv pip install linkup-monitor

And is available as in your python script:

  • You can initialize it:
from linkup_monitor.postgres_client import PostgresClient
from linkup_monitor.monitor import LinkupClient, MonitoredLinkupClient
import os

pg_client = PostgresClient(host='localhost', port=5432, user='postgres', password = 'admin', database = 'postgres') # replace with your Postgres configuration
linkup_client = LinkupClient(api_key=os.getenv('LINKUP_API_KEY')) # assuming you exported LINKUP_API_KEY as an environment variable
monitored_client = MonitoredLinkupClient(linkup_client = linkup_client, postgres_client = pg_client)
  • Synchronously search the web:
from linkup_monitor.monitor import SearchInput


data = SearchInput(
    query = "Who won the Nobel Prize for Chemistry in 2023?",
    output_type = "searchResults",
    output_schema = None,
    depth = "deep",
)
response = monitored_client.search(data = data)
print(response)
  • Asynchronously search the web:
from linkup_monitor.monitor import SearchInput
import asyncio

async def main():
    data = SearchInput(
        query = "What were Microsoft revenue and operating income in USD in the fiscal year 2022?",
        output_type = "structured",
        output_schema = "{\"properties\": {\"company\": {\"description\": \"Company name\",\"type\": \"string\"},\"fiscalYear\": {\"description\": \"The fiscal year for the reported data\",\"type\": \"string\"},\"operatingIncome\": {\"description\": \"Microsoft's operating income in USD\",\"type\": \"number\"},\"revenue\": {\"description\": \"Microsoft's revenue in USD\",\"type\": \"number\"}},\"type\": \"object\"}",
        depth = "deep",
    )
    response = await monitored_client.asearch(data = data)
    print(response)

if __name__ == "__main__":
    asyncio.run(main())
  • Get the monitoring data:
from linkup_monitor.monitor import SelectDatabaseData
# get raw data without filtering them
output_data = monitored_client.get_data(return_mode="raw")
print(output_data)
# get data in JSON format, save them to a JSON file and filter them by status code, ordering them by ascending timestamp and limiting the returned values to 100
filter_data = SelectDatabaseData(
    created_at = False,
    status_code = 200, # you can also set it to 500, which identifies failed searches
    output_type = None,
    query = None,
    search_type = None,
    limit = 100
)
output_data = monitored_client.get_data(data=filter_data, return_mode="json", save_to_file=True)
print(output_data)
# get data in pd.DataFrame format and save them as a CSV file and filter them by output type, ordering them by descending timestamp
filter_data = SelectDatabaseData(
    created_at = True,
    status_code = None, # you can also set it to 500, which identifies failed searches
    output_type = "sourcedAnswer",
    query = None,
    search_type = None,
    limit = None,
)
output_data = monitored_client.get_data(data=filter_data, return_mode="pandas", save_to_file=True)
print(output_data)
  • Use the decorator for a functional integration:
from linkup import LinkupClient
from linkup_monitor.postgres_client import PostgresClient
from linkup_monitor.monitor import monitor, monitored_search, SearchInput

linkup_client = LinkupClient(api_key="YOUR_API_KEY")
postgres_client = PostgresClient(host="localhost", port=5432, database="your_db", user="your_user", password="your_password")

@monitor(pg_client = postgres_client)
def search(linkup_client: LinkupClient, data: SearchInput):
    return monitored_search(linkup_client, data)

You can find a complete reference for the package in REFERENCE.md

Contributing

Contributions are always welcome!

Find contribution guidelines at CONTRIBUTING.md

License and Funding

This project is open-source and is provided under an MIT License.

If you found it useful, please consider funding it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linkup_monitor-0.1.1.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linkup_monitor-0.1.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file linkup_monitor-0.1.1.tar.gz.

File metadata

  • Download URL: linkup_monitor-0.1.1.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for linkup_monitor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 06e88d031544716be7f2408ffd1c999c1b64341c7c6ef4a2598ec7d61b6049f1
MD5 d4cdd24e9b2342b569e80b1ff42c3fdb
BLAKE2b-256 4fe5d726949c34ce1636780b73439e40d68da80e1466bd6cf1fe0fff9cd5a6d4

See more details on using hashes here.

File details

Details for the file linkup_monitor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for linkup_monitor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa7eecc2aebed7d58de93047fb866a4b1061222740cd4730bde6bf7f7b2c2553
MD5 f66c6a15d227bc022778143c1e3b9df1
BLAKE2b-256 68cea7358fa5bc9edbff87be85e0f0aa436b540432bc756102ef38e3434c86be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page