Skip to main content

A Python SDK for creating JSON-RPC servers with hybrid compute capabilities

Project description

README.md

Hybrid Compute SDK

A Python SDK for creating JSON-RPC servers with hybrid compute capabilities.

Installation

pip install hybrid_compute_sdk

Run tests

python -m pytest test.py -v --full-trace

Example Usages

Stuck? Here are some implementations:

  1. CodeCaster
  2. BlockChainBusters

Using the SDK

from web3 import Web3
from openai_offchain import openai_create_question
from openai_offchain import select_best_answer
from hybrid_compute_sdk import HybridComputeSDK
import logging
import os

# Initialize logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def server_loop():
    port = int(os.environ.get("PORT", os.environ.get("OC_LISTEN_PORT", 1234)))

    # new sdk instance
    sdk = HybridComputeSDK()
    # prepare the server
    sdk.create_json_rpc_server_instance()
    # add a custom server action
    sdk.add_server_action("createQuestion()", openai_create_question)
    # add another server action
    sdk.add_server_action("selectBestAnswer()", select_best_answer)
    # start server
    sdk.serve_forever()

server_loop()

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

hybrid_compute_sdk-0.2.37.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hybrid_compute_sdk-0.2.37-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file hybrid_compute_sdk-0.2.37.tar.gz.

File metadata

  • Download URL: hybrid_compute_sdk-0.2.37.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.6

File hashes

Hashes for hybrid_compute_sdk-0.2.37.tar.gz
Algorithm Hash digest
SHA256 955b7b54e81b761937268d9d123bf886b5b9466ea5d1b25aa9ca0b6d0199a9c4
MD5 792567e3d6edc01291f9a82f4dddd7f6
BLAKE2b-256 38cf93fba5b5d03c3da8b62ec9180e825cd2fb1cbf32f2db9236b9a3a3961a2f

See more details on using hashes here.

File details

Details for the file hybrid_compute_sdk-0.2.37-py3-none-any.whl.

File metadata

File hashes

Hashes for hybrid_compute_sdk-0.2.37-py3-none-any.whl
Algorithm Hash digest
SHA256 2cf0827d45fa6784efb7dc563969d43b50fbfb4145c2620b9a681b31ac947259
MD5 d724d6892f09394ccdb7c3a25123146c
BLAKE2b-256 ced44def9e0dac4bb4155c0b5c9cd0800d2b18d0899fb35fd99d157d6fba9981

See more details on using hashes here.

Supported by

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