neuraltrust


Nameneuraltrust JSON
Version 1.2.0 PyPI version JSON
download
home_pageNone
SummaryA Python library for NeuralTrust API
upload_time2024-10-17 13:11:33
maintainerNone
docs_urlNone
authorNeuralTrust
requires_python<4.0,>=3.10
licenseCommercial
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # NeuralTrust Python SDK

The NeuralTrust Python SDK provides a convenient way to interact with the NeuralTrust API for tracing, evaluation sets, knowledge bases, and testsets.

## Installation

You can install the NeuralTrust Python SDK using pip:

```bash
pip install neuraltrust
```

## Usage

To use the NeuralTrust Python SDK, you need to initialize the client with your API key:

```python
from neuraltrust import NeuralTrust

# Initialize the client with your API key
client = NeuralTrust(api_key="your_api_key_here")

# Optionally, you can specify a custom base URL and SDK version
client = NeuralTrust(api_key="your_api_key_here", base_url="https://custom.api.url", sdk_version="v2")
```

### Tracing

```python
# Create a trace
trace = client.trace(trace_id="trace_1234", conversation_id="conversation_1234", session_id="session_1234", channel_id="channel_1234")

# Add events to the trace
trace.retrieval("What's the weather like today?")
# Rest of your code and the end you call the end method
trace.end([{"chunk": "The weather today is sunny with a high of 75°F.", "score": 0.95}])

# There is another method to send the trace in an atomic way
trace.send(
    event_type=EventType.RETRIEVAL, 
    input="What's the weather like today?", 
    output=[{"chunk": "The weather today is sunny with a high of 75°F.", "score": 0.95}], 
    latency=100
)
```

### Evaluation Sets

```python
# Run evaluation set
eval_set = client.run_evaluation_set(id="eval_set_id")

# Create an evaluation set
eval_set = client.create_evaluation_set(name="My Eval Set", description="A test evaluation set")

# Get an evaluation set
eval_set = client.get_evaluation_set(id="eval_set_id")

# Delete an evaluation set
client.delete_evaluation_set(id="eval_set_id")
```

### Knowledge Bases

```python
# Create a knowledge base
kb = client.create_knowledge_base(type="upstash", credentials={"api_key": "your_doc_api_key"})

# Get a knowledge base
kb = client.get_knowledge_base(id="kb_id")

# Delete a knowledge base
client.delete_knowledge_base(id="kb_id")
```

### Testsets

```python
# Create a testset
testset = client.create_testset(name="My Testset", type="adversarial", evaluation_set_id="eval_set_id", knowledge_base_id="kb_id", num_questions=10)

# Get a testset
testset = client.get_testset(id="testset_id")

# Delete a testset
client.delete_testset(id="testset_id")
```

## Configuration

You can configure the SDK using environment variables:

- `NEURALTRUST_API_KEY`: Your NeuralTrust API key
- `NEURALTRUST_BASE_URL`: Custom base URL for the API (optional)

## Advanced Usage

### Custom Metadata and User Information

```python
from neuraltrust import User, Metadata

user = User(id="user123", name="John Doe")
metadata = Metadata(app_version="1.0.0", platform="web")

trace = client.trace(user=user, metadata=metadata)
```

### Asynchronous Tracing

The SDK uses a `ThreadPoolExecutor` for asynchronous tracing. You can adjust the number of workers:

```python
client = NeuralTrust(api_key="your_api_key_here", max_workers=10)
```

## Error Handling

The SDK will raise exceptions for API errors. Make sure to handle these appropriately in your application.

## Contributing

Contributions to the NeuralTrust Python SDK are welcome! Please refer to the contribution guidelines for more information.

## License

This SDK is distributed under the [MIT License](LICENSE).



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "neuraltrust",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "NeuralTrust",
    "author_email": "support@neuraltrust.ai",
    "download_url": "https://files.pythonhosted.org/packages/fd/c3/ce0ee4b787b1a201be2b78329590baebe95fc4a87917eeaab4c50083f1f1/neuraltrust-1.2.0.tar.gz",
    "platform": null,
    "description": "# NeuralTrust Python SDK\n\nThe NeuralTrust Python SDK provides a convenient way to interact with the NeuralTrust API for tracing, evaluation sets, knowledge bases, and testsets.\n\n## Installation\n\nYou can install the NeuralTrust Python SDK using pip:\n\n```bash\npip install neuraltrust\n```\n\n## Usage\n\nTo use the NeuralTrust Python SDK, you need to initialize the client with your API key:\n\n```python\nfrom neuraltrust import NeuralTrust\n\n# Initialize the client with your API key\nclient = NeuralTrust(api_key=\"your_api_key_here\")\n\n# Optionally, you can specify a custom base URL and SDK version\nclient = NeuralTrust(api_key=\"your_api_key_here\", base_url=\"https://custom.api.url\", sdk_version=\"v2\")\n```\n\n### Tracing\n\n```python\n# Create a trace\ntrace = client.trace(trace_id=\"trace_1234\", conversation_id=\"conversation_1234\", session_id=\"session_1234\", channel_id=\"channel_1234\")\n\n# Add events to the trace\ntrace.retrieval(\"What's the weather like today?\")\n# Rest of your code and the end you call the end method\ntrace.end([{\"chunk\": \"The weather today is sunny with a high of 75\u00b0F.\", \"score\": 0.95}])\n\n# There is another method to send the trace in an atomic way\ntrace.send(\n    event_type=EventType.RETRIEVAL, \n    input=\"What's the weather like today?\", \n    output=[{\"chunk\": \"The weather today is sunny with a high of 75\u00b0F.\", \"score\": 0.95}], \n    latency=100\n)\n```\n\n### Evaluation Sets\n\n```python\n# Run evaluation set\neval_set = client.run_evaluation_set(id=\"eval_set_id\")\n\n# Create an evaluation set\neval_set = client.create_evaluation_set(name=\"My Eval Set\", description=\"A test evaluation set\")\n\n# Get an evaluation set\neval_set = client.get_evaluation_set(id=\"eval_set_id\")\n\n# Delete an evaluation set\nclient.delete_evaluation_set(id=\"eval_set_id\")\n```\n\n### Knowledge Bases\n\n```python\n# Create a knowledge base\nkb = client.create_knowledge_base(type=\"upstash\", credentials={\"api_key\": \"your_doc_api_key\"})\n\n# Get a knowledge base\nkb = client.get_knowledge_base(id=\"kb_id\")\n\n# Delete a knowledge base\nclient.delete_knowledge_base(id=\"kb_id\")\n```\n\n### Testsets\n\n```python\n# Create a testset\ntestset = client.create_testset(name=\"My Testset\", type=\"adversarial\", evaluation_set_id=\"eval_set_id\", knowledge_base_id=\"kb_id\", num_questions=10)\n\n# Get a testset\ntestset = client.get_testset(id=\"testset_id\")\n\n# Delete a testset\nclient.delete_testset(id=\"testset_id\")\n```\n\n## Configuration\n\nYou can configure the SDK using environment variables:\n\n- `NEURALTRUST_API_KEY`: Your NeuralTrust API key\n- `NEURALTRUST_BASE_URL`: Custom base URL for the API (optional)\n\n## Advanced Usage\n\n### Custom Metadata and User Information\n\n```python\nfrom neuraltrust import User, Metadata\n\nuser = User(id=\"user123\", name=\"John Doe\")\nmetadata = Metadata(app_version=\"1.0.0\", platform=\"web\")\n\ntrace = client.trace(user=user, metadata=metadata)\n```\n\n### Asynchronous Tracing\n\nThe SDK uses a `ThreadPoolExecutor` for asynchronous tracing. You can adjust the number of workers:\n\n```python\nclient = NeuralTrust(api_key=\"your_api_key_here\", max_workers=10)\n```\n\n## Error Handling\n\nThe SDK will raise exceptions for API errors. Make sure to handle these appropriately in your application.\n\n## Contributing\n\nContributions to the NeuralTrust Python SDK are welcome! Please refer to the contribution guidelines for more information.\n\n## License\n\nThis SDK is distributed under the [MIT License](LICENSE).\n\n\n",
    "bugtrack_url": null,
    "license": "Commercial",
    "summary": "A Python library for NeuralTrust API",
    "version": "1.2.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "111b551917b24e70066a1ea439e7f93e6385d85ec7f78b30292d878c350ba2f2",
                "md5": "0f58b4f83da0847cf6d465ae4fdbda3a",
                "sha256": "9f51c7c4262e64241122580a9e574d7a2891f95406bc98743da2776e0c226c7d"
            },
            "downloads": -1,
            "filename": "neuraltrust-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0f58b4f83da0847cf6d465ae4fdbda3a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 40199,
            "upload_time": "2024-10-17T13:11:32",
            "upload_time_iso_8601": "2024-10-17T13:11:32.302621Z",
            "url": "https://files.pythonhosted.org/packages/11/1b/551917b24e70066a1ea439e7f93e6385d85ec7f78b30292d878c350ba2f2/neuraltrust-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fdc3ce0ee4b787b1a201be2b78329590baebe95fc4a87917eeaab4c50083f1f1",
                "md5": "365e45d26c36597b5c42b2d77b11c01d",
                "sha256": "6a83c1dbe5dc433a9e9a87ad25919ff570d4b899961a06791bce952f6bdf23e2"
            },
            "downloads": -1,
            "filename": "neuraltrust-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "365e45d26c36597b5c42b2d77b11c01d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 24495,
            "upload_time": "2024-10-17T13:11:33",
            "upload_time_iso_8601": "2024-10-17T13:11:33.759229Z",
            "url": "https://files.pythonhosted.org/packages/fd/c3/ce0ee4b787b1a201be2b78329590baebe95fc4a87917eeaab4c50083f1f1/neuraltrust-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-17 13:11:33",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "neuraltrust"
}
        
Elapsed time: 0.77831s