> ## Documentation Index
> Fetch the complete documentation index at: https://docs-v1.latitude.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Joke Generator

> Learn how to build a prompt that thinks like a human and generates jokes.

<Card title="Live example" href="https://app.latitude.so/share/d/658d47ee-cef7-4e38-a5a7-71a7b5017755" arrow="true" cta="Copy to your Latitude">
  You can play with this example in the Latitude Playground.
</Card>

## Overview

Have you ever tried to ask an LLM for a joke, and they either always tell the same one or give you a response that doesn't make any sense?

In this example, we will use the Agent's capability to think like a human using Chain Of Thought reasoning to generate a joke. The Agent will first think about the joke, then tell it to you.

## The prompt

```yaml theme={null}
---
provider: openai
model: gpt-4o
type: agent
---

You're a team of autonomous agents. Your task is to create the funniest joke you can think of about the following topic:

<user>
  {{ topic }}
</user>

You must come up with an answer as a team. To do so, you must communicate with
each other. You should analize, propose and evaluat joke-related aspects about
the topic, come up with a few different drafts for the final joke, and finally
evaluate and build upon them until you are all happy with a final response.
Finally, return your final joke you all agree on.

<assistant>
  Okay! Let's work together on this. How should we start?
</assistant>
```

## Breakdown

### Agent configuration

To build an autonomous Chain Of Thought reasoning structure, we want the AI to think as many times as they want to, and finally return a final answer. To do so, we just need to enable the agentic mode by setting the `type` to `agent` in the prompt configuration.

```type {4} theme={null}
---
provider: openai
model: gpt-4o
type: agent
---
```

### Simple prompt

Now, let's first define the prompt. We want to add a simple description of the task, and an input topic given by the user.

```yaml {6-10} theme={null}
---
provider: openai
model: gpt-4o
type: agent
---
You're a team of autonomous agents. Your task is to create the funniest joke you can think of about the following topic:

<user>
  {{ topic }}
</user>
```

### Improvin the chain of thought process

Finally, we'll add a few instructions to help the agent think.

In this case, I will make the AI think it is made of a team of agents, even though it is just a single prompt. This works because each step the AI will generate a new message based on the whole previous conversation. While they normally expect that all `assistant` messages are from the same agent, we can just tell them that they're collaborating with more AI assistants and make them rate each other's jokes.

```yaml {13-17} theme={null}
---
provider: openai
model: gpt-4o
type: agent
---

You're a team of autonomous agents. Your task is to create the funniest joke you can think of about the following topic:

<user>
  {{ topic }}
</user>

You must come up with an answer as a team. To do so, you must communicate with
each other. You should analize, propose and evaluat joke-related aspects about
the topic, come up with a few different drafts for the final joke, and finally
evaluate and build upon them until you are all happy with a final response.
Finally, return your final joke you all agree on.
```

And just for giving the AI a little push, we can **fake the first message of this conversation**, so it can start thinking right away.

```yaml {19-21} theme={null}
---
provider: openai
model: gpt-4o
type: agent
---

You're a team of autonomous agents. Your task is to create the funniest joke you can think of about the following topic:

<user>
  {{ topic }}
</user>

You must come up with an answer as a team. To do so, you must communicate with
each other. You should analize, propose and evaluat joke-related aspects about
the topic, come up with a few different drafts for the final joke, and finally
evaluate and build upon them until you are all happy with a final response.
Finally, return your final joke you all agree on.

<assistant>
  Okay! Let's work together on this. How should we start?
</assistant>
```

## Resources

* [Playground docs](/guides/prompt-manager/playground) - Learn how to use the Playground to test and run prompts.
* [Autonomous Agents](/guides/prompt-manager/agents) - Learn how to build autonomous agents that can think like humans.
