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="Bearer GALADRIEL_API_KEY",
)
completion = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
],
)
print("completion:", completion)
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="Bearer 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="Bearer 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.2.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.2.tar.gz.
File metadata
- Download URL: sentience-0.0.2.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 |
23612bf685c1f5cabf754c682f0f302584c37562bddd22c2c7693b85c908c771
|
|
| MD5 |
dd161344cccf1a879f303a9a3eee3566
|
|
| BLAKE2b-256 |
a83aa5325af253d18dce4e92bf1cde34383c2a484a571facb7e6b8a79b3c6e82
|
File details
Details for the file sentience-0.0.2-py3-none-any.whl.
File metadata
- Download URL: sentience-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.8 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 |
cfd68d9ac6148774a61fdf4e535bbd2a9bad3567af636ae144a04303627bddf8
|
|
| MD5 |
a470e448109fe1a98af69eebeb3bbbac
|
|
| BLAKE2b-256 |
848c59a2755c8e2b675f5f18aaacc639f0cb78a10fa197d57ec99d45ae33e32f
|