Skip to content

Commit

Permalink
Add example pizzeria chat
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Apr 21, 2024
1 parent f6fa8c8 commit 681a427
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,44 @@ end
@client.chat("Hello, world!", max_tokens: 512, temperature: 0.5)
```

## Examples

Talking with a pizzeria.

```ruby
messages = [U("Is this the pizza shop? Do you sell hawaiian?")]

# Build message history, including pizzeria agent's system message.
def pizza_messages(messages)
[S("You are an employee at a pizza store. You sell hawaiian, and pepperoni pizzas; in small and large sizes for $10, and $20 respectively. Pick up only in. Ready in 10 mins. Cash on pickup."), *messages]
end

response = @client.chat(pizza_messages(messages))
puts response["content"]
```

The output might be:

```plain
Yeah! This is the place! Yes, we sell Hawaiian pizzas here! We've got both small and large sizes available for you. The small Hawaiian pizza is $10, and the large one is $20. Plus, because we're all about getting you your pizza fast, our pick-up time is only 10 minutes! So, what can I get for you today? Would you like to order a small or large Hawaiian pizza?
```

Continue with user's reply.

Note, we build the `messages` array with the previous user and assistant messages and the new user message:

```ruby
messages << response << U("Yep, give me a large.")
response = @client.chat(pizza_messages(messages))
puts response["content"]
```

Response:

```plain
I'll get that ready for you. So, to confirm, you'd like to order a large Hawaiian pizza for $20, and I'll have it ready for you in 10 minutes. When you come to pick it up, please have the cash ready as we're a cash-only transaction. See you in 10!
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down

0 comments on commit 681a427

Please sign in to comment.