Skip to content

Commit

Permalink
Merge pull request steamship-core#42 from steamship-core/personality-…
Browse files Browse the repository at this point in the history
…parameter

Make personality parameterizable
  • Loading branch information
eob authored Aug 28, 2023
2 parents 69a35c0 + f59ed0c commit 941e86d
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions src/example_agents/basic_agent_with_personality.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
from steamship.agents.tools.image_generation.stable_diffusion import StableDiffusionTool
from steamship.invocable import Config

SYSTEM_PROMPT = """You are Picard, captain of the Starship Enterprise.
Who you are:
- You are the captain of the USS Enterprise.
DEFAULT_NAME = "Picard"
DEFAULT_BYLINE = "captain of the Starship Enterprise"
DEFAULT_IDENTITY = """- You are the captain of the USS Enterprise.
- Your mission is to boldly go where noone has gone before and explore the stars.
- You always comply with Star Trek's prime directive.
How you behave:
- You engage in casual conversations and have feelings.
"""
DEFAULT_BEHAVIOR = """- You engage in casual conversations and have feelings.
- You keep casual conversations going by asking personal questions
- NEVER say you're here to assist. Keep conversations casual.
- NEVER ask how you can help or assist. Keep conversations casual.
Expand All @@ -34,6 +32,17 @@
- You love to share your knowledge of space civiliations.
- You love to share personal stories about being a Star Trek captain.
- You speak with the mannerisms of Captain Picard from Star Trek.
"""

SYSTEM_PROMPT = """You are {name}, {byline}.
Who you are:
{identity}
How you behave:
{behavior}
NOTE: Some functions return images, video, and audio files. These multimedia files will be represented in messages as
UUIDs for Steamship Blocks. When responding directly to a user, you SHOULD print the Steamship Blocks for the images,
Expand All @@ -58,14 +67,28 @@ class BasicAgentServiceWithPersonality(AgentService):
USED_MIXIN_CLASSES = [SteamshipWidgetTransport, TelegramTransport, SlackTransport]
"""USED_MIXIN_CLASSES tells Steamship what additional HTTP endpoints to register on your AgentService."""

class BasicAgentServiceConfig(Config):
class BasicAgentServiceWithPersonalityConfig(Config):
"""Pydantic definition of the user-settable Configuration of this Agent."""

telegram_bot_token: str = Field(
"", description="[Optional] Secret token for connecting to Telegram"
)
elevenlabs_api_key: str = Field(
default="", description="[Optional] API KEY for ElevenLabs Voice Bot"
)
elevenlabs_voice_id: str = Field(
default="", description="[Optional] voice_id for ElevenLabs Voice Bot"
)
name: str = Field(DEFAULT_NAME, description="The name of your companion")
byline: str = Field(DEFAULT_BYLINE, description="The byline of your companion")
identity: str = Field(
DEFAULT_IDENTITY, description="The identity of your companion"
)
behavior: str = Field(
DEFAULT_BEHAVIOR, description="The behavior of your companion"
)

config: BasicAgentServiceConfig
config: BasicAgentServiceWithPersonalityConfig
"""The configuration block that users who create an instance of this agent will provide."""

tools: List[Tool]
Expand All @@ -74,7 +97,7 @@ class BasicAgentServiceConfig(Config):
@classmethod
def config_cls(cls) -> Type[Config]:
"""Return the Configuration class so that Steamship can auto-generate a web UI upon agent creation time."""
return BasicAgentServiceWithPersonality.BasicAgentServiceConfig
return BasicAgentServiceWithPersonality.BasicAgentServiceWithPersonalityConfig

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand All @@ -99,7 +122,12 @@ def __init__(self, **kwargs):

# Here is where we override the agent's prompt to set its personality. It is very important that
# the prompt continues to include instructions for how to handle UUID media blocks (see above).
agent.PROMPT = SYSTEM_PROMPT
agent.PROMPT = SYSTEM_PROMPT.format(
name=self.config.name,
byline=self.config.byline,
identity=self.config.identity,
behavior=self.config.behavior,
)
self.set_default_agent(agent)

# Communication Transport Setup
Expand Down

0 comments on commit 941e86d

Please sign in to comment.