Gwenlake framework
Project description
Gwenlake Python Library
The Gwenlake Python library provides convenient access to the Gwenlake API from applications written in the Python language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Gwenlake API.
Installation
If you just want to use the package, just run:
pip install -U git+https://github.com/gwenlake/gwenlake-python
Usage
The library needs to be configured with your account's secret key. Either set it as the GWENLAKE_API_KEY environment variable before using the library:
export GWENLAKE_API_KEY='sk-...'
Or set api_key to its value with the Client:
import gwenlake
client = gwenlake.Client(api_key = "sk-...")
Models
Use our inference platform to chat with models.
List models
r = client.models.list()
print(r)
Chat
messages = [
{
"role": "user",
"content": "Anything about France?"
}
]
r = client.chat.create(model="meta/llama-3.1-8b", messages=messages)
print(r)
Chat with streaming
The SDK also includes helpers to process streams and handle incoming events.
stream = client.chat.stream(model="meta/llama-3.1-8b", messages=messages)
for chunk in stream:
if chunk["choices"][0]["delta"]["content"]:
print(chunk["choices"][0]["delta"]["content"], end="")
Embeddings
Use our inference platform for embeddings using intfloat/e5-base-v2 or the multilingual intfloat/multilingual-e5-base model (supports 100 languages).
list_of_texts = [
"Olympic Games will be in Paris in 2024",
"Do Not Watch This Movie! Not funny at all",
"Can you help me write an email to my best friend?",
]
response = client.embeddings.create(input=list_of_texts, model="e5-base-v2")
for item in response.data:
print(item.embedding)
Prompts
Discover and share prompts in the Gwenlake Hub.
List prompts
response = client.prompts.list()
print(response)
Get a prompt
prompt = client.prompts.get("gwenlake/rag")
print(prompt)
Text Generation
Discover how to automatically combine prompts, datasets and models.
Retrieval Augmented Generation (RAG)
retriever = {
"dataset": "gwenlake/csrd",
"limit": 10
}
response = client.textgeneration.create(
model="meta/llama-3.1-8b",
prompt="gwenlake/rag",
input={"query": "Explain CSRD"},
retriever=retriever)
print(response["output"][0]["text"])
Files
Upload files on your private datasets.
import gwenlake
client = gwenlake.Client()
# upload a file into a dataset
r = client.files.upload("myteam/mydataset", file="test.pdf")
print(r)
# upload a file in a subdir
r = client.files.upload("myteam/mydataset/docs", file="test.pdf")
print(r)
# list files
r = client.files.list("myteam/mydataset")
print(r)
r = client.files.list("myteam/mydataset/docs")
print(r)
# get file
file = client.files.get("myteam/mydataset/test.pdf")
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gwenlake-0.4.1.tar.gz.
File metadata
- Download URL: gwenlake-0.4.1.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4625513236733577a257b7f927af07b68b24a401f556c6f62e4b871b04eb6fa5
|
|
| MD5 |
efa460b15704534df46412b514d25c4a
|
|
| BLAKE2b-256 |
ed48109d25e579d5f8e6f7f030b28af38b952c156bb480e472067887eee72673
|
Provenance
The following attestation bundles were made for gwenlake-0.4.1.tar.gz:
Publisher:
python-publish.yml on gwenlake/gwenlake-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gwenlake-0.4.1.tar.gz -
Subject digest:
4625513236733577a257b7f927af07b68b24a401f556c6f62e4b871b04eb6fa5 - Sigstore transparency entry: 180286361
- Sigstore integration time:
-
Permalink:
gwenlake/gwenlake-python@52db3f7f8b4e6af25fcd9102d42f32d497d878f1 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/gwenlake
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@52db3f7f8b4e6af25fcd9102d42f32d497d878f1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gwenlake-0.4.1-py3-none-any.whl.
File metadata
- Download URL: gwenlake-0.4.1-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b64e92b100543e3cd6e1572b002721989586bd47059fe1538e070148684ca4fe
|
|
| MD5 |
8f71597d1e1a38bd92a43ddfe6da6614
|
|
| BLAKE2b-256 |
00b6624a9923f538aeadfa45630ffba27dc5872086e4f664c632dbcdcd648ee0
|
Provenance
The following attestation bundles were made for gwenlake-0.4.1-py3-none-any.whl:
Publisher:
python-publish.yml on gwenlake/gwenlake-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gwenlake-0.4.1-py3-none-any.whl -
Subject digest:
b64e92b100543e3cd6e1572b002721989586bd47059fe1538e070148684ca4fe - Sigstore transparency entry: 180286366
- Sigstore integration time:
-
Permalink:
gwenlake/gwenlake-python@52db3f7f8b4e6af25fcd9102d42f32d497d878f1 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/gwenlake
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@52db3f7f8b4e6af25fcd9102d42f32d497d878f1 -
Trigger Event:
release
-
Statement type: