Skip to content

Commit

Permalink
Merge branch 'main' into deploy-previews
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmjl authored Nov 19, 2024
2 parents a7c0218 + 41eca24 commit 9dcf0f7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,37 @@ filepath = bot("A painting of a dog.")
If you're in a Jupyter Notebook,
you'll see the image show up magically as part of the output cell as well.

### Experimentation

Automagically record your prompt experimentation locally on your system
by using llamabot's `Experiment` context manager:

```python
from llamabot import Experiment, prompt, metric

@prompt
def sysprompt():
"""You are a funny llama."""

@prompt
def joke_about(topic):
"""Tell me a joke about {{ topic }}."""

@metric
def response_length(response) -> int:
return len(response.content)

with Experiment(name="llama_jokes") as exp:
# You would have written this outside of the context manager anyways!
bot = SimpleBot(sysprompt(), model_name="gpt-4o")
response = bot(joke_about("cars"))
_ = response_length(response)
```

And now they will be viewable in the locally-stored message logs:

![](./docs/cli/log-viewer/experiments.webp)

## CLI Demos

Llamabot comes with CLI demos of what can be built with it and a bit of supporting code.
Expand Down

0 comments on commit 9dcf0f7

Please sign in to comment.