Olympiabhub
Olympiabhub est une librairie Python pour interagir avec l'API Olympia, compatible avec le format OpenAI.
Installation
pip install olympiabhub
Configuration
-
Ajouter votre token API :
- Via variable d'environnement :
OLYMPIA_API_TOKENouOLYMPIA_API_KEYdans votre.env - Ou directement dans le code :
token="votre-token"
- Via variable d'environnement :
-
Pour utiliser via Nubonyxia, ajouter la variable dans votre
.env:
PROXY=127.0.0.1:8080 # Format: IP:PORT
Utilisation
Chat Completions
from olympiabhub import OlympiaAPI
from dotenv import load_dotenv
load_dotenv()
# Initialisation
api = OlympiaAPI(model="llama3.1")
# Format de messages façon OpenAI
messages = [
{"role": "system", "content": "Tu es un assistant utile et concis."},
{"role": "user", "content": "Explique-moi ce qu'est l'effet de serre en une phrase."}
]
# Sans proxy
response = api.chat_completion(
messages=messages,
temperature=0.7,
max_tokens=500
)
# Afficher la réponse
print(response['choices'][0]['message']['content'])
# Avec proxy Nubonyxia
response = api.chat_completion_nubonyxia(
messages=messages,
temperature=0.7,
max_tokens=500
)
# Afficher la réponse
print(response['choices'][0]['message']['content'])
Completions (texte simple)
# Sans proxy
response = api.completion(
prompt="Explique-moi comment fonctionne la photosynthèse.",
temperature=0.7,
max_tokens=500
)
# Afficher la réponse
print(response['choices'][0]['text'])
# Avec proxy Nubonyxia
response = api.completion_nubonyxia(
prompt="Explique-moi comment fonctionne la photosynthèse.",
temperature=0.7,
max_tokens=500
)
# Afficher la réponse
print(response['choices'][0]['text'])
Embeddings
# Création d'embeddings pour une liste de textes
texts = [
"Premier texte à encoder",
"Second texte à encoder"
]
# Sans proxy
embeddings = api.embedding(texts=texts)
# Afficher les embeddings
for i, embedding in enumerate(embeddings['data']):
print(f"Embedding {i+1}:", embedding['embedding'][:5], "...") # Affiche les 5 premières valeurs
# Avec proxy Nubonyxia
embeddings = api.embedding_nubonyxia(texts=texts)
# Afficher les embeddings
for i, embedding in enumerate(embeddings['data']):
print(f"Embedding {i+1}:", embedding['embedding'][:5], "...") # Affiche les 5 premières valeurs
Liste des modèles disponibles
# Obtenir la liste des modèles LLM
# Sans proxy
llm_models = api.get_llm_models()
print("Modèles LLM disponibles:", llm_models)
# Avec proxy Nubonyxia
llm_models = api.get_llm_models_nubonyxia()
print("Modèles LLM disponibles:", llm_models)
# Obtenir la liste des modèles d'embedding
# Sans proxy
embedding_models = api.get_embedding_models()
print("Modèles d'embedding disponibles:", embedding_models)
# Avec proxy Nubonyxia
embedding_models = api.get_embedding_models_nubonyxia()
print("Modèles d'embedding disponibles:", embedding_models)
Paramètres disponibles
Chat Completion et Completion
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
| temperature | float | 0.7 | Contrôle la créativité (0 = déterministe, 1 = créatif) |
| max_tokens | int | 500 | Nombre maximum de tokens dans la réponse |
| top_p | float | 1.0 | Contrôle la diversité des réponses |
| n | int | 1 | Nombre de réponses à générer |
| stream | bool | False | Activer le streaming de la réponse |
| frequency_penalty | float | 0 | Pénalité pour la répétition de fréquence |
| presence_penalty | float | 0 | Pénalité pour la répétition de présence |
Configuration avancée
Vous pouvez personnaliser l'URL de base et le User-Agent :
api = OlympiaAPI(
model="llama3.1",
token="votre-token",
base_url="https://votre-url-api.com",
user_agent="Votre-User-Agent"
)
Metadata
Release files for Olympiabhub 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| olympiabhub-1.0.0.tar.gz | 6.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Olympiabhub-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.7 kB
Release files / olympiabhub-1.0.0.tar.gz
| Download URL | olympiabhub-1.0.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe3f9be578f4e2cdc65ca92de6bb4fbc6424f8336605e43053fa0b641a7e73b1
|
|
BLAKE2b-256 checksum How to use checksums |
f5be6e7eafc405b2fc23923e44ac93a79e11d4af0a1a8214ba432a854a98e644
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / Olympiabhub-1.0.0-py3-none-any.whl
| Download URL | Olympiabhub-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2544d1cae260117c8ccb96df72f8418ce9a96aa23c4395dcf9f5dd244419540
|
|
BLAKE2b-256 checksum How to use checksums |
f915cd9ab0daa5a86387566e0767d64c26b69c7a5f564b85b51baf047ad8d47b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Security for Olympiabhub 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.