Skip to main content

No project description provided

Project description

Redactive Python SDK

Install

pip install redactive

Usage

Auth Client

import redactive
import asyncio
from typing import Literal

# Use the API key you generated in the app dashboard.
# https://dashboard.redactive.ai
client = redactive.AuthClient(api_key="")

# This is the redirect url Redactive will redirect the user to 
# after successfully connecting to a data source.
redirect_uri = "https://url-debugger.vercel.app/"

async def connect_datasource(datasource: redactive.Datasources):
    sign_in_url = await client.begin_connection(provider=datasource, redirect_uri=redirect_uri)

    print(sign_in_url)

    # Have the user go to the sign in url and follow the OAuth flow. 
    # Once completed and at the redirect website get the URL parameter "code" and use it in exchange_tokens
    response = await client.exchange_tokens(code=code)

    # Once this is complete you can use the idToken in the response object to run semantic queries.
    print(response)

if __name__ == "__main__":
    # The current list of data sources that Redactive can connect to.
    # "confluence", "google-drive", "jira", "zendesk", "slack", "sharepoint"
    asyncio.run(connect_datasource("confluence"))

Search Client

import redactive 
import asyncio

client = redactive.SearchClient()

# This is the id token returned from the auth client method connect datasource
access_token = ""

async def semantic_query():    
    while True:
        semantic_query = input("Enter a query: ")
        if not semantic_query:
            break
        chunks = await client.query_chunks(semantic_query, access_token, count=count, filter=filter_dict)
        for chunk in chunks:
            print(chunk.chunk_body)


if __name__ == "__main__":
    asyncio.run(semantic_query())

FastAPI Example

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

redactive-0.1.1.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

redactive-0.1.1-py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 3

Supported by

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