Sure, here's a draft for the README.md:
markdown Copy code
Google Bard is a Ruby gem adaptation of the Python package BardAPI. This Python package is using reverse engineering to access Bard in an unofficial way, allowing developers to generate text completions with an API.
I actually made this gem as wanted Bard for my latest project: a WhastsApp bot supercharged with AI. Check it out here: ciel.chat
This gem is exploiting reverse engineering for Bard, and it might fail in the future due to Google's code evolutions. Not sure yet wether I will maintain it or change into the official API when it's live. Feel free to contribute.
You can install the gem by adding it to your Gemfile:
Or install it yourself:
gem install google_bard
- Visit https://bard.google.com/
- Session: Application → Cookies → Copy the value of
__Secure-1PSIDcookie. -> This is your token.
First, require the gem in your code:
Initialize the Bard object:
bard = GoogleBard.new(token, timeout, proxies)
- token (required): Your __Secure-1PSID value from Google Bard.
- timeout (optional): Timeout for the requests (default is 20 seconds).
- proxies (optional): Proxy configuration if you want to use proxies.
- Then call the completion method with your text input:
response = bard.completion("Hello, world!")
The completion method returns an
OpenStruct with the following attributes:
- success: Whether the request was successful.
- content: The generated completion.
- conversation_id: The ID of the conversation.
- response_id: The ID of the response.
- factuality_queries: The factuality queries.
- text_query: The text query.
- choices: The choices provided by the completion.
response.success response.content # -> completion if success, error if not
Contributing Bug reports and pull requests are welcome on GitHub at github.com/username/google_bard.
License The gem is available as open source under the terms of the MIT License.