Skip to main content

Python SDK for Thesis.io APIs.

Project description

Thesis.io APIs

Thesis API in Python

Installation

pip install thesis_py

Usage

Import the package and initialize the Thesis client with your API key:

from thesis_py import Thesis

thesis = Thesis(api_key="your-api-key")

Common requests

  # basic search
  results = thesis.search("This is a Thesis.io query:")

  # keyword search (non-neural)
  results = thesis.search("Google-style query", type="keyword")

  # search with date filters
  results = thesis.search("This is a Thesis.io query:", start_published_date="2019-01-01", end_published_date="2019-01-31")

  # search with domain filters
  results = thesis.search("This is a Thesis.io query:", include_domains=["www.cnn.com", "www.nytimes.com"])

  # search and get text contents
  results = thesis.search_and_contents("This is a Thesis.io query:")

  # search and get contents with contents options
  results = thesis.search_and_contents("This is a Thesis.io query:",
                                    text={"include_html_tags": True, "max_characters": 1000})

  # find similar documents
  results = thesis.find_similar("https://example.com")

  # find similar excluding source domain
  results = thesis.find_similar("https://example.com", exclude_source_domain=True)

  # find similar with contents
  results = thesis.find_similar_and_contents("https://example.com", text=True)

  # get text contents
  results = thesis.get_contents(["tesla.com"])

  # get contents with contents options
  results = thesis.get_contents(["urls"],
                             text={"include_html_tags": True, "max_characters": 1000})

  # basic answer
  response = thesis.answer("This is a query to answer a question")

  # answer with full text
  response = thesis.answer("This is a query to answer a question", text=True)

  # answer with streaming
  response = thesis.stream_answer("This is a query to answer:")

  # Print each chunk as it arrives when using the stream_answer method
  for chunk in response:
    print(chunk, end='', flush=True)

  # research task example – answer a question with citations
  # Example prompt & schema inspired by the TypeScript example.
  QUESTION = (
      "Summarize the history of San Francisco highlighting one or two major events "
      "for each decade from 1850 to 1950"
  )
  OUTPUT_SCHEMA: Dict[str, Any] = {
      "type": "object",
      "required": ["timeline"],
      "properties": {
          "timeline": {
              "type": "array",
              "items": {
                  "type": "object",
                  "required": ["decade", "notableEvents"],
                  "properties": {
                      "decade": {
                          "type": "string",
                          "description": 'Decade label e.g. "1850s"',
                      },
                      "notableEvents": {
                          "type": "string",
                          "description": "A summary of notable events.",
                      },
                  },
              },
          },
      },
  }
  resp = thesis_py.research..create_task(
      instructions=QUESTION,
      model="thesis-research",
      output_schema=OUTPUT_SCHEMA,
  )

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

thesis_py-1.0.0.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

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

thesis_py-1.0.0-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file thesis_py-1.0.0.tar.gz.

File metadata

  • Download URL: thesis_py-1.0.0.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for thesis_py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a6a2c205d56af8517bebca0c01aa172fc9cca3e09335304dbd67be5013602a0a
MD5 464ef447ca5a580cc5fd6c247c2f3071
BLAKE2b-256 295181268aa44f3209279bfd4a3a0e6a2ee88920284196ffe732322949338511

See more details on using hashes here.

File details

Details for the file thesis_py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: thesis_py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 60.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for thesis_py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c031921e12120d75aad7ad756f085ad4082d9f5635c6ce9751e460616819e2dd
MD5 6209eb6b8420446adb1d5bae7e1dadf9
BLAKE2b-256 20c6305639852dae855b1289b8a5d7ec14d7665d7010720f202993cc5653bbb2

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