No project description provided
Project description
Galadriel Python SDK - Sentience
Setup
pip install sentience
Usage
Make LLM API call using OpenAI API spec and verify the signature:
import sentience
from openai import OpenAI
client = OpenAI(
base_url="https://api.galadriel.com/v1/verified",
api_key=GALADRIEL_API_KEY,
)
completion = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
],
)
is_valid = sentience.verify_signature(completion)
print("is_valid:", is_valid)
Fetch all previous verified inference requests:
from typing import List
import sentience
from sentience.history import GaladrielChatHistory
history: List[GaladrielChatHistory] = sentience.get_history(
galadriel_api_key=GALADRIEL_API_KEY
)
for item in history:
print("\n\nResult:")
print(f"Request: {item.request.get('messages')}")
print(f"Message: {item.response.choices[0].message}")
print(f"Hash: {item.hash}")
print(f"Signed public key: {item.public_key}")
print(f"Signature: {item.signature}")
print(f"Tx hash: {item.tx_hash}")
print(f"Attestation: {item.attestation[:10]}...")
is_valid = sentience.verify_signature(item)
print("is_valid:", is_valid)
Fetch a single verified inference request by hash:
import sentience
from sentience.history import GaladrielChatHistory
item: GaladrielChatHistory = sentience.get_by_hash(
galadriel_api_key=GALADRIEL_API_KEY,
hash="922e575ef7f07449977001c1caaf78fb6ad8b731cd625434f9215087a6c2b39f"
)
print("\n\nResult:")
print(f"Request: {item.request.get('messages')}")
print(f"Message: {item.response.choices[0].message}")
print(f"Hash: {item.hash}")
print(f"Signed public key: {item.public_key}")
print(f"Signature: {item.signature}")
print(f"Tx hash: {item.tx_hash}")
print(f"Attestation: {item.attestation[:10]}...")
is_valid = sentience.verify_signature(item)
print("is_valid:", is_valid)
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
sentience-0.0.1.tar.gz
(3.1 kB
view details)
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 sentience-0.0.1.tar.gz.
File metadata
- Download URL: sentience-0.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a032d18b2af0be488f333d85981abcf8c8a9ac7787701717ddea9d954d19d35
|
|
| MD5 |
ad135448e30b9d1ee56958121c0028fc
|
|
| BLAKE2b-256 |
e5f8d4ee61e25c5a771099118d3942268cd00915b63673abc02414938a05a973
|
File details
Details for the file sentience-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sentience-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39629bf26e69757ed3543b47c96c5c0e74ba1aae373177b3ca6780a63a2b70ff
|
|
| MD5 |
2d9b3ef0d23ac31b0880584cf5d45282
|
|
| BLAKE2b-256 |
d7d2f5b2462a2200b31de3087c5150dfad7d50b270acca169879cb01677b4501
|