Skip to content

Commit c8e2fdc

Browse files
fixes
1 parent 0756f61 commit c8e2fdc

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,37 @@ Welcome to your new gem! In this directory, you'll find the files you need to be
66

77
## Installation
88

9-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10-
119
Install the gem and add to the application's Gemfile by executing:
1210

13-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
11+
$ bundle add google_palm_api
1412

1513
If bundler is not being used to manage dependencies, install the gem by executing:
1614

17-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
15+
$ gem install google_palm_api
1816

1917
## Usage
2018

21-
TODO: Write usage instructions here
22-
19+
```ruby
20+
require 'google_palm_api'
21+
```
22+
```ruby
23+
client.generate_text(prompt:)
24+
```
25+
```ruby
26+
client.generate_chat_message(prompt:)
27+
```
28+
```ruby
29+
client.embed(text:)
30+
```
31+
```ruby
32+
client.get_model(model:)
33+
```
34+
```ruby
35+
client.list_models()
36+
```
37+
```ruby
38+
client.count_message_tokens(message:)
39+
```
2340
## Development
2441

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

lib/google_palm_api/client.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def initialize(api_key:)
4040
#
4141
def generate_text(
4242
prompt:,
43-
model: nil,
4443
temperature: nil,
4544
candidate_count: nil,
4645
max_output_tokens: nil,
@@ -50,7 +49,7 @@ def generate_text(
5049
stop_sequences: nil,
5150
client: nil
5251
)
53-
response = connection.post("/v1beta2/models/#{model || DEFAULTS[:completion_model_name]}:generateText") do |req|
52+
response = connection.post("/v1beta2/models/#{DEFAULTS[:completion_model_name]}:generateText") do |req|
5453
req.params = {key: api_key}
5554

5655
req.body = {prompt: { text: prompt }}
@@ -87,7 +86,6 @@ def generate_text(
8786
#
8887
def generate_chat_message(
8988
prompt:,
90-
model: nil,
9189
context: nil,
9290
examples: nil,
9391
messages: nil,
@@ -98,11 +96,10 @@ def generate_chat_message(
9896
client: nil
9997
)
10098
# Overwrite the default ENDPOINT_URL for this method.
101-
response = connection.post("/v1beta2/models/#{model || DEFAULTS[:chat_completion_model_name]}:generateMessage") do |req|
99+
response = connection.post("/v1beta2/models/#{DEFAULTS[:chat_completion_model_name]}:generateMessage") do |req|
102100
req.params = {key: api_key}
103101

104102
req.body = {prompt: { messages: [{content: prompt}] }}
105-
req.body[:model] = model if model
106103
req.body[:context] = context if context
107104
req.body[:examples] = examples if examples
108105
req.body[:messages] = messages if messages

0 commit comments

Comments
 (0)