Indexical SDK (for Python)
Project description
Indexical Python SDK
The Indexical SDK for Python makes it easier to use the Indexical API for Python projects that are interacting with an existing codebase. It primarily contains helper functions that can extract the appropriate sources from code/configuration files, for use in Indexical API calls.
Currently, the SDK supports analyzing projects written in JS/TS or in Python. Specifically, the SDK can extract sources in the following ways:
In JS/TS projects:
- Analyzing a JS/TS source file (
extract_sources_from_js) - Analyzing a package.json file (
extract_sources_from_package_json) - Analyzing a package-lock.json file (
extract_sources_from_package_lock_json)
In Python projects:
- Analyzing a Python JS/TS source file (
extract_sources_from_py) - Analyzing a requirements.txt file (
extract_sources_from_requirements_txt)
Installation
pip install indexical_sdk
Usage
All extract_sources_from_... functions expect a single argument (the input file's contents, as a string), and return a Dict that can be combined with the body of your API request (containing either the npm or the pypi key, depending on the type of project being analyzed). The Indexical SDK is meant to work with whatever library you're currently using for accessing file contents and making API calls. The example here uses requests and python's pathlib, but could easily be adapted for any other choice:
import indexical_sdk
from pathlib import Path
import requests
import os
package_file_contents = Path("/path/to/package.json").read_text()
prompt = "your prompt here"
npm = indexical_sdk.extract_sources_from_package_json(package_file_contents)["npm"]
API_KEY = os.getenv('INDEXICAL_API_KEY')
response = requests.post(
"https://api.indexical.dev/context",
json={
"npm": npm,
"prompt": prompt
},
headers={
"Authorization": f"Bearer {API_KEY}"
}
)
# see https://indexical.dev/docs for API docs on the expected response
The same example applies for using any of the SDK's included extractors (listed above, in the first section of the README).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file indexical_sdk-0.0.1.tar.gz.
File metadata
- Download URL: indexical_sdk-0.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
476c7a090faa3429bf59565ee12e1bf6c5fe606b907e3eb59bc3f2f5672f1c25
|
|
| MD5 |
667a6df51f1dfc0f27b438044fd08cc3
|
|
| BLAKE2b-256 |
1a1550fe7b77006a9c12dba1132d90f7691d8b336c048b386494b0eb2d663a7b
|
File details
Details for the file indexical_sdk-0.0.1-py3-none-any.whl.
File metadata
- Download URL: indexical_sdk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db8a7a962b07d7908bbb572d99d756f8958cf93728b507331e86ebd308d8b3d6
|
|
| MD5 |
2fb1e42a9667a6114a00ad1b4610226a
|
|
| BLAKE2b-256 |
5e3ae1732a8861d49d69e769c727ed75d9c4dfc613f42b2b01de7899f800c616
|