Feature Request: Add async support for Generative AI Inference client
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia esaminando la PR #835 e il client sincrono esistente di Generative AI Inference che usa requests. Confronta il client async proposto, i suoi 15 test unitari e 7 test di integrazione con il supporto richiesto per chat, streaming, embeddings, autenticazione e context manager. Il lavoro è completato quando le operazioni asincrone richieste sono coperte e le versioni di Python e i modelli indicati rimangono supportati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature Request
Description
Add native async/await support for the OCI Generative AI Inference client to enable non-blocking concurrent requests in async applications.
Problem Statement
The current SDK uses synchronous HTTP requests via the requests library. This causes issues in async applications:
- Event loop blocking: Sync calls block the event loop in FastAPI, async agents, and other async frameworks
- Limited concurrency: Cannot efficiently make concurrent API calls
- Performance bottleneck: Sequential requests are significantly slower than concurrent alternatives
Proposed Solution
Add an AsyncGenerativeAiInferenceClient class that:
- Uses
aiohttpfor true async HTTP requests - Reuses the existing OCI
Signerfor authentication - Provides async versions of all GenAI operations (chat, streaming, embeddings, etc.)
- Supports async context manager pattern
Example Usage
import asyncio
from oci.generative_ai_inference import AsyncGenerativeAiInferenceClient
async def main():
async with AsyncGenerativeAiInferenceClient(config) as client:
# Concurrent requests - 3x faster than sequential
results = await asyncio.gather(
client.chat(details1),
client.chat(details2),
client.chat(details3),
)
asyncio.run(main())
Performance Impact
Testing shows 2-3.5x throughput improvement for concurrent workloads:
| Scenario | Sequential | Concurrent | Speedup |
|---|---|---|---|
| 3 requests (Llama 3.3) | 1.30s | 0.64s | 2.01x |
| 3 requests (Llama 3.2) | 1.40s | 0.44s | 3.18x |
| 3 requests (Cohere) | 0.50s | 0.14s | 3.54x |
Use Cases
- FastAPI/async web frameworks: Non-blocking GenAI calls in async endpoints
- LangChain agents: Concurrent tool calls and chain execution
- Batch processing: Parallel processing of multiple prompts
- Real-time applications: Low-latency streaming responses
Implementation
A reference implementation is provided in PR #835 with:
- Full async client implementation
- 15 unit tests
- 7 integration tests
- Tested on Python 3.9, 3.12, 3.13, 3.14
- Tested with 6 different models
Related
- PR: #835
- Lingua principale
- Python
- Stelle
- 474
- Fork
- 321
- Merge medio
- 23m
- PR unite (30g)
- 4
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di oracle/oci-python-sdk
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
oracle/oci-python-sdk#890 · 3 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
oracle/oci-python-sdk#879 · 3 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
oracle/oci-python-sdk#878 ·
-
SDK
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
oracle/oci-python-sdk#861 · 5 commenti ·
-
SDK
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
oracle/oci-python-sdk#852 ·
Tutte le issue di oracle/oci-python-sdk
Issue simili
-
area: harness bug status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Human-Agent-Society/reef#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
learningequality/kolibri#15351 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Name consistency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eellak/triplestore#65 · 1 commento ·