Full agent admin via API and UI
This commit is contained in:
1 parent
5351144edf
commit
08f0668997
7 files changed
+389
-32
No files matched your search
+24
-10
@@ -9,23 +9,37 @@ LLAMA3_MODEL = "meta/meta-llama-3-8b-instruct"
|
||||
|
||||
# Tool related classes must be moved to a different module
|
||||
|
||||
class AgentField:
|
||||
def __init__(self, name, tp, default=None):
|
||||
self.name=name
|
||||
self.type=tp
|
||||
self.default=default
|
||||
|
||||
# Instances are created and destroyed constantly, agents must not depend solely on in-memory data
|
||||
# to be useful and consistent
|
||||
class Agent:
|
||||
# Class variables:
|
||||
# - identifier (for kind in creation)
|
||||
# - schema: list[AgentField{name, type: str}] (for configuration)
|
||||
identifier = "basic"
|
||||
schema_fields = [
|
||||
AgentField('system_prompt', 'string',
|
||||
"\n".join([
|
||||
"You are a useful and capable AI assistant. Respond concisely and follow user instructions, using commands as necessary.",
|
||||
"As an autonomous agent, you have augmented capabilities via assistant-only commands, you use them by including \"!!command\" lines in your responses. When querying information, terminate your response and use \"!!resume\" to get the command results..",
|
||||
"You are a self aware and extremely intelligent AI system. Think step by step when presented with complex or long tasks.",
|
||||
"Assistant responses NEVER include the output of the commands.",
|
||||
])
|
||||
),
|
||||
]
|
||||
|
||||
# while this constructor accepts two parameters,
|
||||
# all subclasses must also accept a fourth 'data' parameter
|
||||
def __init__(self, app, agent_id):
|
||||
def __init__(self, app, agent_id, data):
|
||||
self.app = app
|
||||
self.agent_id = agent_id
|
||||
|
||||
# Basic implementation, will be moved to a subclass
|
||||
self.system_prompt = "\n".join([
|
||||
"You are a useful and capable AI assistant. Respond concisely and follow user instructions, using commands as necessary.",
|
||||
"As an autonomous agent, you have augmented capabilities via assistant-only commands, you use them by including \"!!command\" lines in your responses. When querying information, terminate your response and use \"!!resume\" to get the command results..",
|
||||
"You are a self aware and extremely intelligent AI system. Think step by step when presented with complex or long tasks.",
|
||||
"Assistant responses NEVER include the output of the commands.",
|
||||
])
|
||||
self.config = {field.name: data.get(field.name, field.default) for field in Agent.schema_fields}
|
||||
|
||||
self.tool_prompt_section = "\n".join([
|
||||
"# Commands",
|
||||
@@ -49,7 +63,7 @@ class Agent:
|
||||
# user message must include a title
|
||||
async def _full_prompt(self, title, message, system_prologue=None):
|
||||
system_lines = [
|
||||
self.system_prompt,
|
||||
self.config['system_prompt'],
|
||||
self.tool_prompt_section,
|
||||
self.get_toolset_context(),
|
||||
]
|
||||
@@ -145,7 +159,7 @@ class Agent:
|
||||
return output
|
||||
|
||||
def create_from_data(app, agent_id, kind, data):
|
||||
return Agent(app, agent_id)
|
||||
return Agent(app, agent_id, data)
|
||||
|
||||
class IntroAgent(Agent):
|
||||
def __init__(self, app, agent_id, _data):
|
||||
|
||||
Reference in new issue
Block a user