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)
Built Distribution
Close
Hashes for redactive-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 110fab8e84610958b6059c483853044b1202daccc62aeae7423a4765e5ba0a22 |
|
MD5 | 3b457dd9ff3dc376df6fa534760628c8 |
|
BLAKE2b-256 | 51dfd00b52518131a051d1dce0e8e0b3e5ed8db43f38b5dae55603756ec9a1fd |