AI-Orchestration

quest server action

Create a quest for a server action

Give the quest a name, a goal and proper initiate method, in this case server action

Tie the quest to a model - in this example department

The quest in this example are to write at policy document with goals and responsibilities for a choosen  department. At the departments view there is a server action that starts the process to author the policy and save it on the department.

The result is dependent on the quest goal / description, the choosen agent / agents, how the agents are created and the choosen LLM on the agent.


Define the context for the quest

Give the quest a proper context, in this case Company information are important.
You can either have a language in the goal or give the language that logged in user has choosen and finds natural.


Write a goal for the quest

The description for a quest is also the goal for the quest. Write a detailed objective for the assignment, clearly stating what needs to be done, the scope of the assignment, and how the results should be presented. If it is a text, most language models usually use Markdown to enrich the content. Since, in this case, it is a server action, we can use information from the current record in the objective description; write the field name within curly brackets {name}.

Since the result is received by a Python program, it can sometimes be convenient to request a JSON. In such cases, include what it should look like with brackets, attributes, and data. This is not necessary in our example because we want a text.


Write your programming code

Write the Python program that carries out the assignment, builds a chain of agents, or a supervisor that uses the agents independently.

The assignment is stored in the variable "quest". The "build" method instantiates the quest, and the "invoke({})" method executes it. It is important to include the session when calling build. It is also important to pass in the current department. The attributes of the department are used in the objective of the quest.

 The code should also include what should be done with the result of the agents' work. The invoke method returns a list of what the agent(s) have done.
quest.get_last_ai_message_content(result) returns the last message or conclusion. The message or response is formatted in Markdown for most language models; quest.markdown2html(answer) converts the response to HTML.

In this case, the end user can select one or more departments, and the quest should be carried out for each department.

 department.write({'goals_responsibilities':quest.markdown2html(answer)})

Writes the answer to the goals_responsibilities attribute of the department. 
 


Choose an agent for the Quest

A quest can work with one or several agents. Select an agent—in this case, an agent who specializes in organizations. The agent must have a language model attached to it.

A quest has an agent, and the agent has a language model.

A quest constructs a chain of agents that together tackle the task. In cases where there are multiple agents, the work can either proceed in sequence or be coordinated by a supervisor. In this simple example, the quest builds a chain with a single agent.

The Importance of Status

For a quest to function properly, it is essential that the language model is confirmed (there is a test button for the language model), the agent is active, and the quest itself is active. Only when all these components are in place is the quest fully operational.


Use the server action

You can find the server action as a menu option in the gear icon to the left in the form view, or in the center in the list view.


This example with quest and agent is available in the module ai_agent_hr.