Zoonk.AI.Tasks.AITask behaviour (Zoonk v0.1.0-dev)

View Source

Behaviour for AI tasks.

Callbacks

  • system_prompt/0: Returns the system prompt for the task.
  • user_prompt/1: Returns the user prompt for the task.
  • json_schema/0: Returns the JSON schema for the task.
  • model/0: Returns the default model for the task.
  • generate_object/1: Sends a request to the AI service using the default model.
  • generate_object/2: Sends a request to the AI service using a specified model.

Summary

Callbacks

Generates an object using the AI service based on the provided input.

Generates an object using the AI service based on the provided input and model.

Sets the JSON schema for the task.

Returns the default model for the task.

System prompt for the task.

User prompt for the task.

Callbacks

generate_object(map)

@callback generate_object(map()) :: {:ok, map()} | {:error, term()}

Generates an object using the AI service based on the provided input.

It uses the default model for the task. If you need to specify a different model, you can use the generate_object/2 function.

generate_object(map, t)

@callback generate_object(map(), String.t()) :: {:ok, map()} | {:error, term()}

Generates an object using the AI service based on the provided input and model.

If you need to use the default model, you can use the generate_object/1 function.

json_schema()

@callback json_schema() :: map()

Sets the JSON schema for the task.

It must use our schema module for composing schemas: Zoonk.AI.AISchema

model()

@callback model() :: String.t()

Returns the default model for the task.

system_prompt()

@callback system_prompt() :: String.t()

System prompt for the task.

user_prompt(map)

@callback user_prompt(map()) :: String.t()

User prompt for the task.

The input is a map containing the user's input and language.