| Name | javelin-sdk JSON |
| Version |
0.2.11
JSON |
| download |
| home_page | None |
| Summary | Python client for Javelin |
| upload_time | 2024-10-09 09:54:06 |
| maintainer | None |
| docs_url | None |
| author | Sharath Rajasekar |
| requires_python | <4.0,>=3.8 |
| license | Apache-2.0 |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
## Javelin: an Enterprise-Scale, Fast LLM Gateway
[](https://github.com/getjavelin/javelin-python/actions/workflows/python-publish.yml)
This is the Python client package for Javelin.
For more information about Javelin, see https://getjavelin.io
Javelin Documentation: https://docs.getjavelin.io
### Development
For local development, Please change `version = "RELEASE_VERSION"` with any semantic version example : `version = "v0.1.10"` in `pyproject.toml`
*Make sure that the file `pyproject.toml` reverted before commit back to main*
### Installation
```python
pip install javelin_sdk
```
### Quick Start
```python
from javelin_sdk import (
JavelinClient,
JavelinConfig,
Route,
NetworkError,
RouteNotFoundError,
UnauthorizedError,
)
import os, sys
try:
javelin_api_key = os.getenv('JAVELIN_API_KEY')
javelin_virtualapikey = os.getenv('JAVELIN_VIRTUALAPIKEY') #optional
llm_api_key = os.getenv("OPENAI_API_KEY")
config = JavelinConfig(
base_url="https://api-dev.javelin.live",
javelin_api_key=javelin_api_key,
javelin_virtualapikey=javelin_virtualapikey, #optional
llm_api_key=llm_api_key,
)
client = JavelinClient(config)
print('Successfully connected to Javelin Client')
except NetworkError as e:
print("Failed to create client: Network Error")
sys.exit()
except UnauthorizedError as e:
print("Failed to create client: Unauthorized")
sys.exit()
# Create a route object
route_data = {
"name": "test_route_1",
"type": "chat",
"models": [
{
"name": "gpt-3.5-turbo",
"enabled": True,
"provider": "openai",
"suffix": "/v1/chat/completions",
}
],
"config": {
"archive": True,
"organization": "myusers",
"retries": 3,
"rate_limit": 7,
},
}
route = Route.parse_obj(route_data)
try:
client.create_route(route)
except NetworkError as e:
print("Failed to create route: Network Error")
query_data = {
"model": "gpt-3.5-turbo",
"messages": [
{"role": "system", "content": "You are a helpful assistant that translates English to French."},
{"role": "user", "content": "AI has the power to transform humanity and make the world a better place"},
],
"temperature": 0.8,
}
# query the llm
try:
response = client.query_route("test_route_1", query_data)
except RouteNotFoundError as e:
print("Route Not Found")
```
Raw data
{
"_id": null,
"home_page": null,
"name": "javelin-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Sharath Rajasekar",
"author_email": "sharath@getjavelin.io",
"download_url": "https://files.pythonhosted.org/packages/76/ca/a53896be8561931b515c1c035bd63c980b4b236ef3fae1603608960a606b/javelin_sdk-0.2.11.tar.gz",
"platform": null,
"description": "## Javelin: an Enterprise-Scale, Fast LLM Gateway\n\n[](https://github.com/getjavelin/javelin-python/actions/workflows/python-publish.yml)\n\nThis is the Python client package for Javelin.\n\nFor more information about Javelin, see https://getjavelin.io \nJavelin Documentation: https://docs.getjavelin.io\n\n### Development\n\nFor local development, Please change `version = \"RELEASE_VERSION\"` with any semantic version example : `version = \"v0.1.10\"` in `pyproject.toml`\n\n*Make sure that the file `pyproject.toml` reverted before commit back to main*\n\n### Installation\n\n```python\n pip install javelin_sdk\n```\n\n### Quick Start\n\n```python\nfrom javelin_sdk import (\n JavelinClient,\n JavelinConfig,\n Route,\n NetworkError,\n RouteNotFoundError,\n UnauthorizedError,\n)\n\nimport os, sys\n\ntry:\n javelin_api_key = os.getenv('JAVELIN_API_KEY')\n javelin_virtualapikey = os.getenv('JAVELIN_VIRTUALAPIKEY') #optional\n llm_api_key = os.getenv(\"OPENAI_API_KEY\")\n\n config = JavelinConfig(\n base_url=\"https://api-dev.javelin.live\",\n javelin_api_key=javelin_api_key,\n javelin_virtualapikey=javelin_virtualapikey, #optional\n llm_api_key=llm_api_key,\n )\n client = JavelinClient(config)\n\n print('Successfully connected to Javelin Client')\n\nexcept NetworkError as e:\n print(\"Failed to create client: Network Error\")\n sys.exit()\nexcept UnauthorizedError as e:\n print(\"Failed to create client: Unauthorized\")\n sys.exit()\n\n# Create a route object\nroute_data = {\n \"name\": \"test_route_1\",\n \"type\": \"chat\",\n \"models\": [\n {\n \"name\": \"gpt-3.5-turbo\",\n \"enabled\": True,\n \"provider\": \"openai\",\n \"suffix\": \"/v1/chat/completions\",\n }\n ],\n \"config\": {\n \"archive\": True,\n \"organization\": \"myusers\",\n \"retries\": 3,\n \"rate_limit\": 7,\n },\n}\n\nroute = Route.parse_obj(route_data)\ntry:\n client.create_route(route)\nexcept NetworkError as e:\n print(\"Failed to create route: Network Error\")\n\nquery_data = {\n \"model\": \"gpt-3.5-turbo\",\n \"messages\": [\n {\"role\": \"system\", \"content\": \"You are a helpful assistant that translates English to French.\"},\n {\"role\": \"user\", \"content\": \"AI has the power to transform humanity and make the world a better place\"},\n ],\n \"temperature\": 0.8,\n}\n\n# query the llm\ntry:\n response = client.query_route(\"test_route_1\", query_data)\nexcept RouteNotFoundError as e:\n print(\"Route Not Found\")\n\n```\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Python client for Javelin",
"version": "0.2.11",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "64ec29e643567c66540e42825066f04c93019b7f0ad7d619cd0f6ab4276b7e45",
"md5": "3fb18fbc5a2a2737d9580d5dc911b274",
"sha256": "0067f266286cfe22bfca1e1f9980330a8a567a257aead48966571adb36f37e14"
},
"downloads": -1,
"filename": "javelin_sdk-0.2.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3fb18fbc5a2a2737d9580d5dc911b274",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 26566,
"upload_time": "2024-10-09T09:54:04",
"upload_time_iso_8601": "2024-10-09T09:54:04.714041Z",
"url": "https://files.pythonhosted.org/packages/64/ec/29e643567c66540e42825066f04c93019b7f0ad7d619cd0f6ab4276b7e45/javelin_sdk-0.2.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "76caa53896be8561931b515c1c035bd63c980b4b236ef3fae1603608960a606b",
"md5": "57ce0b937a32878d0ac9e8a24f05d8b7",
"sha256": "5f3cc9d52c97d724f5a06ceabc13aabd5a51a6da1e5c144a6073748b1b518fee"
},
"downloads": -1,
"filename": "javelin_sdk-0.2.11.tar.gz",
"has_sig": false,
"md5_digest": "57ce0b937a32878d0ac9e8a24f05d8b7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 21511,
"upload_time": "2024-10-09T09:54:06",
"upload_time_iso_8601": "2024-10-09T09:54:06.311134Z",
"url": "https://files.pythonhosted.org/packages/76/ca/a53896be8561931b515c1c035bd63c980b4b236ef3fae1603608960a606b/javelin_sdk-0.2.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-09 09:54:06",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "javelin-sdk"
}