Skip to main content

Pytohn SDK for eLLMental

Project description

eLLMental SDK

eLLMental is a Python library for interacting with a custom evaluation API. This library allows you to set an evaluation context, execute evaluations, push test results, and manage search pipelines and test cases.

Installation

Since eLLMental is a private repository, you need to install it from a local path. First clone the repo and then you can install the library using pip from the local path:

pip install /path/to/your/eLLMental
Replace /path/to/your/eLLMental with the actual path to the directory containing setup.py.

Usage

Below is a step-by-step guide on how to use the eLLMental library.

Initialization

First, import the library and create an instance of the eLLMental class with the base URL of your API:

from Ellmental import Ellmental

base_url = "http://your-api-url.com"
authorization_token= "your bearer toke generated by eLLMental"
eLLMental = Ellmental(base_url, authorization_token)

Search pipeline

Listing Search Pipelines

List all available search pipelines:

pipelines = eLLMental.list_search_pipelines()
print(pipelines)

Searching with a Pipeline

Perform a search using a specific pipeline and context:

pipeline_id = "your_pipeline_id"
context_id = "your_context_id"
query = "your_query"
results = pipelines = eLLMental.list_search_pipelines()
.search_pipeline_query(pipeline_id, context_id, query)
print(results)

Evaluations

Setting the Evaluation Context

Set the evaluation context by specifying the test suite ID:

test_suite_id = "your_test_suite_id"
eLLMental.set_evaluation_context(test_suite_id)

Listing Evaluation Cases

List all test cases in the evaluation context:

test_cases = eLLMental.list_evaluation_cases()
print(test_cases)

Starting an Evaluation Execution

Start an evaluation execution:

eLLMental.start_evaluation_execution()

Pushing Evaluation Results

Push the results of a test case:

test_case_id = "your_test_case_id"
test_result = {"some": "result"}
status = "Pass"  # or "Failure"
metadata = {"additional": "info"}
response = eLLMental.push_evaluation_result(test_case_id, test_result, status, metadata)
print(response)

Finishing the Evaluation Execution

Finish the evaluation execution:

response = eLLMental.finish_evaluation_execution()
print(response)

Complete evaluation example:

from Ellmental import Ellmental
import json
import time

def main():
    eLLMental = eLLMental("http://localhost:4000", "API KEY TOKEN") # init the SDK with your instance URL
    eLLMental.set_evaluation_context(2) # init the evaluation context with your evaluation id
    test_cases = eLLMental.list_evaluation_cases() # fetch all your evaluation cases
    eLLMental.start_evaluation_execution() # start a new evaluation execution
    for test_case in test_cases:

        test_input = json.loads(test_case["test_query"])
        expected_result = int(test_case["expected_results"])
        test_result = function_under_test(test_input[0], test_input[1])
        status = "Pass" if expected_result == test_result else "Fail"

        eLLMental.push_evaluation_result(test_case["id"], test_result, status) # notify the evaluation result

    eLLMental.finish_evaluation_execution() # finish the current evaluation execution

def function_under_test(a, b):
    time.sleep(2)
    return a + b

if __name__ == "__main__":
    main()

Analytics

🚧 TO DO 🚧

Data

🚧 TO DO 🚧

Development

If you are contributing to the SDK after perfom your changes in order to create a new pip package to be installed / released you have to run the following command:

python setup.py sdist bdist_wheel

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

ellmental-0.1.3.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.

eLLMental-0.1.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file ellmental-0.1.3.tar.gz.

File metadata

  • Download URL: ellmental-0.1.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for ellmental-0.1.3.tar.gz
Algorithm Hash digest
SHA256 18fb84f0a75f14d86c355d83fcd56f95d99885595c1b2907082870e4a615e8aa
MD5 64562ba9234cbd78db5a6c416f95198d
BLAKE2b-256 3f4c4110e584128ba506e10abab606d10eb1f06a07efb736a2b0f2f03611a664

See more details on using hashes here.

File details

Details for the file eLLMental-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: eLLMental-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for eLLMental-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a279bd7fabb5eca0341df77090db547804982ae2980e1c23f3d97c3db993b18b
MD5 8e7a8e35c86c49d03e55151dda403769
BLAKE2b-256 c0a167c77a52271047f421038c0f822a850ebbfb596d1af2b1bc99bc47679548

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