AI agents & LLM apps

Language models hallucinate numbers. If your assistant answers questions about Pakistan's economy, such as "what's the latest inflation?", "how have remittances trended?" or "what's KIBOR today?", give it PakDataHub as a tool, so every figure comes from the official source with a date attached.

Two tools are enough

Most agents need only search and fetch:

[
  {
    "name": "search_pakistan_series",
    "description": "Find PakDataHub series ids for a Pakistan economic/financial concept (e.g. 'cpi', 'kibor', 'remittances saudi', 'raast').",
    "input_schema": { "type": "object", "properties": { "q": { "type": "string" } }, "required": ["q"] }
  },
  {
    "name": "get_pakistan_series",
    "description": "Get observations for a PakDataHub series id. Returns dated values from the official source (SBP/PBS/PTA/MUFAP).",
    "input_schema": { "type": "object", "properties": {
      "series_id": { "type": "string" },
      "from": { "type": "string", "description": "YYYY-MM-DD" },
      "transform": { "type": "string", "enum": ["yoy", "mom", "pct_change", "3ma", "index"] },
      "limit": { "type": "integer" } }, "required": ["series_id"] }
  }
]

Implement them as two HTTP calls:

import httpx
H = {"X-API-Key": "pk_live_xxx"}
B = "https://api.pakdatahub.com/v1"

def search_pakistan_series(q):
    return httpx.get(f"{B}/search", params={"q": q, "limit": 8}).json()["data"]

def get_pakistan_series(series_id, **params):
    params.setdefault("limit", 24)
    r = httpx.get(f"{B}/series/{series_id}", params=params, headers=H).json()
    return {"meta": r["meta"], "data": r["data"]}

Add /v1/funds/screener for mutual-fund questions and /v1/commodities/by-city for prices by city.

Grounding the model in the docs

Prompting tips

·

Also as Markdown: use-case-ai-agents.md · All docs