Python client library for the Sensenova API
Project description
Sensenova Python Library
The Sensenova Python library provides convenient access to the Sensenova API from applications written in the Python language.
Installation
You don't need this source code unless you want to modify the package. If you just want to use the package, just run:
pip install --upgrade sensenova
Usage
Configure API KEY
Set environment variable:
export SENSENOVA_ACCESS_KEY_ID=
export SENSENOVA_SECRET_ACCESS_KEY=
Or set sensenova.access_key_id and sensenova.secret_access_key to its value:
import sensenova
sensenova.access_key_id = "..."
sensenova.secret_access_key = "..."
API
cli
sensenova api chat_completions.create -m xxx -g user "Say this is a test!" --stream
python
import sensenova
# create a chat completion
chat_completion = sensenova.ChatCompletion.create(
model="xxx",
messages=[{"role": "user", "content": "Say this is a test!"}]
)
# print the chat completion
print(chat_completion.data.choices[0].message)
python async
Async support is available in the API by prepending a to a network-bound method:
import sensenova
import asyncio
async def create_chat_completion():
chat_completion_resp = await sensenova.ChatCompletion.acreate(
model="xxx",
messages=[{"role": "user", "content": "Say this is a test!"}]
)
print(chat_completion_resp.data.choices[0].message)
asyncio.run(create_chat_completion())
To make async requests more efficient, you can pass in your own aiohttp.ClientSession, but you must manually close the client session at the end of your program/event loop:
import sensenova
from aiohttp import ClientSession
sensenova.aiosession.set(ClientSession())
# At the end of your program, close the http session
await sensenova.aiosession.get().close()
Tools
Run the following command on data.json to get the cleaned_data.json file
sensenova tools fine_tunes.prepare_data -f data.json
Requirements
- Python 3.7.1+
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
Built Distribution
File details
Details for the file sensenova-1.0.6.tar.gz
.
File metadata
- Download URL: sensenova-1.0.6.tar.gz
- Upload date:
- Size: 29.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51c099511f2a56c56a9b0340ed240b85bc0da2e5f0ba9217302b33f3fc4c4495 |
|
MD5 | 1660d3b7b02b33d50ffce0d73408bd25 |
|
BLAKE2b-256 | 229accf90e817a90c988ebfdd70f3f82228d877109216e8c81de6dcc41b48ef9 |
File details
Details for the file sensenova-1.0.6-py3-none-any.whl
.
File metadata
- Download URL: sensenova-1.0.6-py3-none-any.whl
- Upload date:
- Size: 49.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a219b759040acb9c85c6f70253a744ed1e6134a180f87252f1914515bf58558 |
|
MD5 | e8cbc7bb0df11aecaba973379e21b4f7 |
|
BLAKE2b-256 | 9fcaa6cdb22470a0a6c3fb3ba9880c18a805c913354e7a6a2a3f08d4a5b95026 |