compass.services.base.Service#
- class Service[source]#
Bases:
ABCAbstract base class for a Service that can be queued to run
See also
LLMServiceBase class for LLM services.
OpenAIServiceLLM service for OpenAI models.
ProcessPoolServiceService that contains a ProcessPoolExecutor instance.
ThreadedServiceService that contains a ThreadPoolExecutor instance.
Methods
Use this method to allocate resources, if needed
call(*args, **kwargs)Call the service
process(*args, **kwargs)Process a call to the service.
process_using_futures(fut, *args, **kwargs)Process a call to the service
Use this method to clean up resources, if needed
Attributes
Max number of concurrent job submissions.
Flag indicating whether the service can accept work
Service name used to pull the correct queue object
- MAX_CONCURRENT_JOBS = 10000#
Max number of concurrent job submissions.
- async classmethod call(*args, **kwargs)[source]#
Call the service
- Parameters:
*args – Positional and keyword arguments to be passed to the underlying service processing function.
**kwargs – Positional and keyword arguments to be passed to the underlying service processing function.
- Returns:
object– A response object from the underlying service.
- async process_using_futures(fut, *args, **kwargs)[source]#
Process a call to the service
The result is communicated by updating
fut.- Parameters:
fut (
asyncio.Future) – A future object that should get the result of the processing operation. If the processing function returnsanswer, this method should callfut.set_result(answer).**kwargs – Keyword arguments to be passed to the underlying processing function.