Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New SDK structure #14

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 28 additions & 5 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Publish to PyPI.org
on:
push:
tags: ["v*"]


jobs:
pypi:
runs-on: ubuntu-latest
Expand All @@ -12,8 +14,29 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: python3 -m pip install --upgrade build && python3 -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}

- name: Build python package
run: |
python3 -m pip install --upgrade build
python3 -m build

- name: Check package version
env:
EXPECTED_VERSION: ${{ github.ref_name }}
run: |
VERSION=$(grep -e "version\s*=\s*" -m 1 pyproject.toml | awk -F '"' '{print $2}')

if [ -z "$VERSION" ]; then
echo "Version not found"
exit 1
fi

if [ "v$VERSION" != "$EXPECTED_VERSION" ]; then
echo "Version $VERSION matches the tag name $EXPECTED_VERSION ."
exit 1
fi

# - name: Publish package to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_TOKEN }}
28 changes: 20 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
*.py[cod]
__pycache__/
build/
dist/
*.egg-info/
.pytest_cache/

# build
/*.egg*/
/prem/_dist_ver.py
/build/
/dist/
# pyenv
.python-version

venv/
docs/build
# Environments
.env
.venv

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# JetBrains
.idea/

/coverage.xml
/.coverage
37 changes: 0 additions & 37 deletions .pre-commit-config.yaml

This file was deleted.

1 change: 0 additions & 1 deletion CNAME

This file was deleted.

16 changes: 0 additions & 16 deletions LICENSE

This file was deleted.

3 changes: 0 additions & 3 deletions Manifest.in

This file was deleted.

112 changes: 46 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,117 +1,97 @@
<div align="center">
<h1 align="center">🚀 Prem Python SDK</h1>
<p align="center">The Prem Python SDK is a Python library for interacting with the <a href="https://github.com/premAI-io/prem-saas">Prem API</a></p>

[![PyPI version](https://img.shields.io/pypi/v/premai.svg)](https://pypi.org/project/premai/)
[![GitHub contributors](https://img.shields.io/github/contributors/premAI-io/prem-python-sdk.svg)](https://github.com/premAI-io/prem-python-sdk/graphs/contributors)
[![GitHub last commit](https://img.shields.io/github/last-commit/premAI-io/prem-python-sdk.svg)](https://github.com/premAI-io/prem-python-sdk/commits/master)
[![GitHub top language](https://img.shields.io/github/languages/top/premAI-io/prem-python-sdk.svg)](https://github.com/premAI-io/prem-python-sdk)
[![GitHub issues](https://img.shields.io/github/issues/premAI-io/prem-python-sdk.svg)](https://github.com/premAI-io/prem-python-sdk/issues)
</div>


<details>
<summary>Table of Contents</summary>
<ol>
<li><a href="#installation">Installation</a></li>
<li><a href="#usage">Usage</a></li>
<ol>
<li><a href="#getting-started">Getting Started</a></li>
<li><a href="#completions">Completions</a></li>
<li><a href="#embeddings">Embeddings</a></li>
<li><a href="#data-points">DataPoints</a></li>
</ol>
</ol>
</details>

## Installation

### From Source

1. Clone the Prem Python SDK repository:

```bash
git clone https://github.com/premAI-io/prem-python-sdk.git
``````

2. Install the SDK
```bash
cd prem-python-sdk
python -m venv venv
source venv/bin/activate
pip install .
```
### From PyPI
You can also install the Prem Python SDK directly from PyPI.
# Installation

## From Source

1\. Clone the Prem Python SDK repository:
```bash
git clone https://github.com/premAI-io/prem-python-sdk.git
```

2\. Install the SDK
```bash
cd prem-python-sdk
python -m venv venv
source venv/bin/activate
pip install .
```

## From PyPI
You can also install the Prem Python SDK directly from PyPI.

```bash
pip install premai
```
## Usage
### Getting Started

# Usage
## Getting Started
To use the Prem Python SDK, you need to obtain an API key from the Prem platform. You can then create a `Prem` instance to make requests to the API.

```python
from prem import Prem
from premai import Prem

api_key = "YOUR_API_KEY"
base_url = "https://api.prem.com" # Update with the base URL of the Prem API

client = Prem(api_key=api_key, base_url=base_url)
client = Prem(api_key=api_key)
```

### Completions
The `completions` module allows you to generate completions based on user input. Here's an example:
## Chat completion
The `chat.completions` module allows you to generate completions based on user input. Here's an example:

```python
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
]
model = "gpt-3.5-turbo"
project_id = YOUR_PROJECT_ID

# Create completion
response = client.completions.create(project_id=1, messages=messages, model=model, stream=False)
print(response)
response = client.chat.completions.create(
project_id=project_id,
messages=messages,
model=model
)

print(response.choices)
```

### Embeddings
## Embeddings
The `embeddings` module enables you to create embeddings for given input. Example:

```python
input_text = "What is a transformer?"
model = "text-embedding-ada-002"
project_id = YOUR_PROJECT_ID

# Create embeddings
response = client.embeddings.create(project_id=1, input=input_text, model=model)
print(response)
response = client.embeddings.create(project_id=project_id, input=input_text, model=model)

print(response.data)
```

### Data Points
## Data Points
The `datapoints` module allows you to manage data points, including creating, updating, retrieving, and deleting. Example:
```python
input_text = "What is a transformer?"
output_text = "A transformer is a deep learning model that uses self-attention."
project_id = YOUR_PROJECT_ID

# Create 10 data points
for _ in range(10):
data_point = client.datapoints.create(project_id=1, input=input_text, output=output_text, positive=True)
data_point = client.datapoints.create(project=project_id, input=input_text, output=output_text, positive=True)

# Update the last data point
patched_data_point = client.datapoints.update(datapoint_id=data_point.id, data={"positive": False})
patched_data_point = client.datapoints.patch(id=data_point.id, positive=False)

# Retrieve the updated data point
print(client.datapoints.retrieve(datapoint_id=data_point.id))
print(client.datapoints.retrieve(id=data_point.id))

# Delete the updated data point
client.datapoints.delete(datapoint_id=data_point.id)
client.datapoints.delete(id=data_point.id)

# List all data points
datapoints = client.datapoints.list(project_id=1)
datapoints = client.datapoints.list(project=project_id)
print("Total number of datapoints:", len(datapoints))
for datapoint in datapoints:
print("Deleted data point with ID:", datapoint.id)
client.datapoints.delete(datapoint_id=datapoint.id)
```
client.datapoints.delete(id=datapoint.id)
```
2 changes: 0 additions & 2 deletions dev-requirements.txt

This file was deleted.

20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

35 changes: 0 additions & 35 deletions docs/source/conf.py

This file was deleted.

21 changes: 0 additions & 21 deletions docs/source/index.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/source/prem.client.rst

This file was deleted.

Loading
Loading