Agent class description, visible in UI
This commit is contained in:
1 parent
e9ebb1378a
commit
6530ff0a24
4 files changed
+49
-1
No files matched your search
@@ -6,6 +6,11 @@ from string import Template
|
||||
from inference import LlamaMessage, replicate_llama_completion
|
||||
from agent import Agent, AgentField
|
||||
|
||||
CLASS_DESCRIPTION = """
|
||||
Description of the Conversation Agent.
|
||||
Here go additional instructions for configuration, like guidelines for the different prompts.
|
||||
""".strip()
|
||||
|
||||
chat_system_prompt_template = Template("""$role
|
||||
The first message contains information about you and a conversation that you're participating in.
|
||||
Respond only with your next message in the conversation.
|
||||
@@ -84,6 +89,7 @@ class ThreadContext:
|
||||
|
||||
class ConversationAgent(Agent):
|
||||
identifier = "conversation"
|
||||
description = CLASS_DESCRIPTION
|
||||
schema_fields = [
|
||||
AgentField('system_prompt', 'string', default="You are a friendly AI having a casual conversation with the user."),
|
||||
]
|
||||
|
||||
+11
-1
@@ -155,12 +155,22 @@ class App:
|
||||
"id": agent.id,
|
||||
"name": agent.name,
|
||||
"description": agent.description,
|
||||
"picture": agent.picture
|
||||
"picture": agent.picture,
|
||||
"kind": agent.kind,
|
||||
} for agent in agents]
|
||||
|
||||
def get_agent_kinds(self):
|
||||
return [kind.identifier for kind in self.agent_classes]
|
||||
|
||||
def get_agent_kind_info(self, kind):
|
||||
agent_class = next((it for it in self.agent_classes if it.identifier == kind), None)
|
||||
if agent_class is None:
|
||||
raise Exception(f"invalid agent kind: {kind}")
|
||||
return {
|
||||
"name": agent_class.identifier,
|
||||
"description": getattr(agent_class, 'description', None),
|
||||
}
|
||||
|
||||
def delete_chat(self, chat_id):
|
||||
with self.sql_session() as session:
|
||||
session.execute(db.Membership.__table__.delete().where(db.Membership.chat_id == chat_id))
|
||||
|
||||
@@ -146,6 +146,9 @@ def start_server(app):
|
||||
elif action == "get-agent-kinds":
|
||||
await send({'message': "agents retrieved", 'kinds': app.get_agent_kinds(), 'nonce': nonce})
|
||||
|
||||
elif action == "get-agent-kind-info":
|
||||
await send({'message': "agent kind retrieved", 'info': app.get_agent_kind_info(body['kind']), 'nonce': nonce})
|
||||
|
||||
elif action == "get-agents":
|
||||
await send({'message': "agents retrieved", 'agents': app.get_agents(user_id), 'nonce': nonce})
|
||||
|
||||
|
||||
Reference in new issue
Block a user