llumpy.core.AsyncModelClient¶
- class AsyncModelClient(model, model_client)[source]¶
Bases:
_SingleUseConversationMixIn,ABCAbstract base class for asynchronous model clients
Methods
__init__(model, model_client)Create new client
extract_text(response)Extract text from vendor-specific response object
prompt_many(conversation, *[, handler, retries])Prompt a model with a full conversation
prompt_one(message, *[, handler, retries])Prompt a model with a single user message
prompt_stream(conversation, **prompt_kwargs)Prompt a model and stream the response
system([content, file])Init conversation with a system message
user([content, file])Init conversation with a user message
validate()Validate the client is ready to use
vendor_prompt(conversation, **prompt_kwargs)Raw API call, returns vendor-specific response object
vendor_prompt_stream(conversation, ...)Raw API call, returns vendor-specific response stream object
Attributes
Name of the model
- async prompt_many(conversation, *, handler=None, retries=5, **prompt_kwargs)[source]¶
Prompt a model with a full conversation
- Parameters:
conversation (Conversation) – Conversation with prompt to send to LLM
handler (AsyncRetryHandler | None) – Optional handler to ensure the response is valid (Default: None)
retries (int) – Number of retries allowed (Default: 5)
prompt_kwargs (Any) – kwargs for chat
- Returns:
Completed chat response text or parsed object from retry handler
- Return type:
- async prompt_one(message, *, handler=None, retries=5, **prompt_kwargs)[source]¶
Prompt a model with a single user message
- Parameters:
message (str) – Message to send to LLM
handler (AsyncRetryHandler | None) – Optional handler to ensure the response is valid (Default: None)
retries (int) – Number of retries allowed (Default: 5)
prompt_kwargs (Any) – kwargs for chat
- Returns:
Completed chat response text or parsed object from retry handler
- Return type:
- async prompt_stream(conversation, **prompt_kwargs)[source]¶
Prompt a model and stream the response
- Parameters:
conversation (Conversation) – Messages to send to LLM
prompt_kwargs (Any) – kwargs for chat
- Returns:
Chat stream
- Return type:
- abstractmethod async vendor_prompt(conversation, **prompt_kwargs)[source]¶
Raw API call, returns vendor-specific response object
- Parameters:
conversation (Conversation)
prompt_kwargs (Any)
- Return type:
- abstractmethod async vendor_prompt_stream(conversation, **prompt_kwargs)[source]¶
Raw API call, returns vendor-specific response stream object
- Parameters:
conversation (Conversation)
prompt_kwargs (Any)
- Return type: