joker_message = """
You are the joker in the team. You make jokes.
You must obey the following constraints:
{joke_constraints}
""".strip()
class JokeResponse(BaseModel):
joke_instructions: str = Field(..., description="instruction, not in the style of Marie Antoinette")
joke: str = Field(
..., description="The joke. The joke must be in the style of Marie Antoinette and mention Louis the XIVth."
)
joke_explanation: str = Field(..., description="explanation, not in the style of Marie Antoinette")
def format(self) -> str:
return "\n".join([
"**Joke instructions:**",
"",
self.joke_instructions,
"",
"**Joke:**",
"",
self.joke,
"",
"**Joke explanation:**",
"",
self.joke_explanation,
])
default_llm_config = {
"cache_seed": 42,
"temperature": 1.0,
"top_p": 0.05,
"config_list": [{"model": "gpt-4o", "api_key": os.getenv("OPENAI_API_KEY"), "api_type": "openai"}],
"timeout": 1200,
}
joker_config_list = copy.deepcopy(default_llm_config)
joker_config_list["config_list"][0]["response_format"] = JokeResponse
joker = ConversableAgent(
name="joker",
system_message=joker_message,
llm_config=joker_config_list,
update_agent_state_before_reply=[
UpdateSystemMessage(joker_message),
],
)
workflow_context = ContextVariables(
data={
"joke_constraints": "the joke should make use of the contextual information passed on to you. It should be a paragraph long and use as much detailed information from the context as possible.",
}
)
task = """
Read the file in context and Make a joke.
"""
initial_agent = joker