Skip to main content

Client Python pour l'IA Cédric — requêtes à Ollama avec file d'attente automatique

Project description

cedric-ai

Client Python pour interroger l'IA Cédric (propulsé par Ollama).

Gère automatiquement la file d'attente si le serveur est éteint — les requêtes sont exécutées dès qu'il rallume.

Installation

pip install cedric-ai

Utilisation rapide

from cedric_ai import CedricAI

ai = CedricAI(host="ai.monsite.com", token="MON_TOKEN")

# Requête directe
reponse = ai.ask("C'est quoi Python ?")
print(reponse)

Requête asynchrone (file d'attente)

Si le serveur est éteint, la requête est sauvegardée et exécutée automatiquement dès qu'il se rallume.

from cedric_ai import CedricAI

ai = CedricAI(host="ai.monsite.com", token="MON_TOKEN")

# Ajouter en file d'attente
job_id = ai.ask_async("Explique la relativité")

# Attendre le résultat (bloquant, max 10 min)
result = ai.wait_for_result(job_id, timeout=600)
print(result)

Avec callback

def quand_ca_repond(job_id, reponse):
    print(f"Réponse reçue : {reponse}")

job_id = ai.ask_async("Salut !", callback=quand_ca_repond)

Avec une personnalité personnalisée

CEDRIC = "Tu t'appelles Cédric, tu as 16 ans, tu parles comme un ado français."

reponse = ai.ask("T'as passé une bonne journée ?", system=CEDRIC)
print(reponse)

Statut de la file

print(ai.queue_status())
# {'online': True, 'pending': 2, 'done': 5, 'errors': 0, 'total': 7}

ai.clear_done()  # Supprime les jobs terminés

Paramètres

Paramètre Défaut Description
host "localhost" Adresse du serveur
port 11434 Port Ollama
model "llama3" Modèle à utiliser
token None Token d'authentification
queue_mode True Active la file d'attente automatique
queue_file "cedric_queue.json" Fichier de persistance de la file
retry_interval 30 Secondes entre chaque tentative si hors ligne
timeout 120 Timeout par requête en secondes

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

cedric_ai-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cedric_ai-1.0.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file cedric_ai-1.0.0.tar.gz.

File metadata

  • Download URL: cedric_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cedric_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f86a7b4823985d58e3385274e8b6cecbc058fdab9e38890e3eb7618082270196
MD5 e3652153399c7f78052c8ba0b079b3d9
BLAKE2b-256 4777cdbd150af2f4991dced335effe24e615f43e4bb9116d36169c0763b46bd3

See more details on using hashes here.

File details

Details for the file cedric_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cedric_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cedric_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 106b9a292289c8896ecff00c43dc330be5962e69880a4dd0a7cb72da2edf59aa
MD5 2ed07f371addc63988942726cb5aa542
BLAKE2b-256 5f54cd57268fed9e835510b6bfbd1deb4e032d0a5ec7fd98062e014c48fdbf34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page