19 lines
572 B
Python
19 lines
572 B
Python
"""Pinned OpenAI-compatible completion boundary; not a monetary spending cap."""
|
|
import threading
|
|
|
|
class SingleCall:
|
|
def __init__(self):
|
|
self.used = False
|
|
self.lock = threading.Lock()
|
|
|
|
def call(self, create, kwargs):
|
|
with self.lock:
|
|
if self.used:
|
|
raise RuntimeError('One provider call only; no retries')
|
|
self.used = True
|
|
kwargs = dict(kwargs)
|
|
kwargs['max_tokens'] = 160
|
|
kwargs['stream'] = False
|
|
kwargs.pop('max_completion_tokens',None)
|
|
return create(**kwargs)
|