WecoAI Functions
abuild async
¶
Build a specialized function for a task asynchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_description | str | The description of the task for which the function is being built. | required |
api_key | str | The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - | None |
Returns:
Type | Description |
---|---|
tuple[str, int, str] | A tuple containing the function name, version number and description. |
aquery async
¶
aquery(fn_name, version=-1, text_input='', images_input=[], return_reasoning=False, strict=False, api_key=None)
Queries a specific function with the input (text, images or both) asynchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn_name | str | The name of the function to query. | required |
version | Optional[Union[str, int]] | The version alias/number of the function to query. Default is -1 which results in the latest version being used. | -1 |
text_input | str | The text input to the function. | '' |
images_input | List[str] | A list of image URLs or base64 encoded images to be used as input to | [] |
return_reasoning | bool | A flag to indicate if the reasoning should be returned. Default is False. | False |
strict | bool | A flag to indicate if the function should be queried in strict mode where the inputs provided should match the input modalities of the LLM chosen for this function. For example, when strict is True, a text-image query to a function that uses a text-only LLM will raise an error. When strict is False, the function will attempt to handle the input by dropping the image components. Default is False. | False |
api_key | str | The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - | None |
Returns:
Type | Description |
---|---|
dict | A dictionary containing the output of the function, the number of input tokens, the number of output tokens, |
batch_query ¶
Batch queries a single function with multiple inputs.
This method uses the asynchronous queries to submit a batch of queries concurrently and waits for all responses to be received before returning the results. Order of the responses corresponds to the order of the inputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn_name | str | The name of the function to query. | required |
batch_inputs | List[Dict[str, Any]] | A list of dictionaries, each representing an input for the function. Each dictionary can contain: - "text_input": A string for text input. - "images_input": A list of image URLs or base64 encoded images. | required |
version | str | int | The version alias/number of the function to query. Default is -1 which results in the latest version being used. | -1 |
return_reasoning | bool | A flag to indicate if the reasoning should be returned. Default is False. | False |
strict | bool | A flag to indicate if the function should be queried in strict mode where the inputs provided should match the input modalities of the LLM chosen for this function. For example, when strict is True, a text-image query to a function that uses a text-only LLM will raise an error. When strict is False, the function will attempt to handle the input by dropping the image components. Default is False. | False |
api_key | str | The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - | None |
Returns:
Type | Description |
---|---|
List[Dict[str, Any]] | A list of dictionaries, each containing the result of a function query. Each dictionary includes: - The function's output. - The number of input tokens. - The number of output tokens. - The latency in milliseconds. |
build ¶
Build a specialized function for a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_description | str | The description of the task for which the function is being built. | required |
api_key | str | The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - | None |
Returns:
Type | Description |
---|---|
tuple[str, int, str] | A tuple containing the function name, version number and description. |
query ¶
query(fn_name, version=-1, text_input='', images_input=[], return_reasoning=False, strict=False, api_key=None)
Queries a specific function with the input (text, images or both).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn_name | str | The name of the function to query. | required |
version | str | int | The version alias/number of the function to query. Default is -1 which results in the latest version being used. | -1 |
text_input | str | The text input to the function. | '' |
images_input | List[str] | A list of image URLs or base64 encoded images to be used as input to the function. | [] |
return_reasoning | bool | A flag to indicate if the reasoning should be returned. Default is False. | False |
strict | bool | A flag to indicate if the function should be queried in strict mode where the inputs provided should match the input modalities of the LLM chosen for this function. For example, when strict is True, a text-image query to a function that uses a text-only LLM will raise an error. When strict is False, the function will attempt to handle the input by dropping the image components. Default is False. | False |
api_key | str | The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - | None |
Returns:
Type | Description |
---|---|
dict | A dictionary containing the output of the function, the number of input tokens, the number of output tokens, and the latency in milliseconds. |