Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
Improve testing (#12)
Browse files Browse the repository at this point in the history
* Improve testing

* Bump version
  • Loading branch information
vsakkas authored Nov 16, 2023
1 parent 7236963 commit 9e5e0dd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# <img src="https://raw.githubusercontent.com/vsakkas/bard.py/master/images/logo.svg?token=GHSAT0AAAAAAB7MEK465TODCKRPHN3YQY54ZKGUN4Q" width="28px" /> Bard.py

[![Latest Release](https://img.shields.io/github/v/release/vsakkas/bard.py.svg)](https://github.com/vsakkas/bard.py/releases/tag/v0.2.1)
[![Latest Release](https://img.shields.io/github/v/release/vsakkas/bard.py.svg)](https://github.com/vsakkas/bard.py/releases/tag/v0.2.2)
[![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/vsakkas/bard.py/blob/master/LICENSE)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bard-py"
version = "0.2.1"
version = "0.2.2"
description = "Python Client for Bard."
authors = ["vsakkas <[email protected]>"]
license = "MIT"
Expand Down
18 changes: 17 additions & 1 deletion tests/test_ask.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import pytest
from thefuzz import fuzz

from bard import BardClient


@pytest.mark.asyncio
async def test_ask() -> None:
expected_responses = [
"Hello there! How can I help you today?",
"Hello there! How can I help you today? [Image of Bard AI Chatbot]",
"Hello there! How can I help you today? [Image of Bard, a large language model from Google AI]",
"Hello there! How can I help you today? [Image of a friendly robot with a warm smile]",
]

async with BardClient() as bard:
_ = await bard.ask("Tell me a joke")
response = await bard.ask("Hello, Bard!")

score = 0
for expected_response in expected_responses:
score = fuzz.token_sort_ratio(response, expected_response)
if score >= 80:
return True

assert False, f"Unexpected response: {response}, match score: {score}"


@pytest.mark.asyncio
Expand Down

0 comments on commit 9e5e0dd

Please sign in to comment.