google_palm_api 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/lib/google_palm_api/client.rb +16 -12
- data/lib/google_palm_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b076d778e0a488d4b456cc10cc3243850ef90288c040dcdb94edf7dcd91a121
|
4
|
+
data.tar.gz: 6c40d661c77996cb8c72b865b0b85771e3afde4298db9100ee93a4488cfea198
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f35f5be9055fbf1a7141b3ffd372fc18adff924a89c2dcca58d68c5783fd13b486ab53bc7eb859b1f9f40bb6f52071d384bb66f338ba684ada848c3d932a5d7
|
7
|
+
data.tar.gz: 41e126d177942335e3161c7691cbeef9dfb0d43b0158f420ff35fb7865d76b88761242758a17b66264c9a6dff437e91e3c35b0dca840e52a431ba2ca959d62ff
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# GooglePalmApi
|
2
2
|
|
3
|
-
|
3
|
+
Ruby API client for the Google PaLM APIs.
|
4
|
+
|
5
|
+
![Tests status](https://github.com/andreibondarev/google_palm_api/actions/workflows/ci.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/google_palm_api.svg)](https://badge.fury.io/rb/google_palm_api)
|
4
6
|
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/google_palm_api`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -47,9 +47,10 @@ module GooglePalmApi
|
|
47
47
|
top_k: nil,
|
48
48
|
safety_settings: nil,
|
49
49
|
stop_sequences: nil,
|
50
|
-
client: nil
|
50
|
+
client: nil,
|
51
|
+
model: nil
|
51
52
|
)
|
52
|
-
response = connection.post("/v1beta2/models/#{DEFAULTS[:completion_model_name]}:generateText") do |req|
|
53
|
+
response = connection.post("/v1beta2/models/#{model || DEFAULTS[:completion_model_name]}:generateText") do |req|
|
53
54
|
req.params = {key: api_key}
|
54
55
|
|
55
56
|
req.body = {prompt: {text: prompt}}
|
@@ -85,24 +86,27 @@ module GooglePalmApi
|
|
85
86
|
# @return [Hash]
|
86
87
|
#
|
87
88
|
def generate_chat_message(
|
88
|
-
|
89
|
+
messages:,
|
90
|
+
prompt: nil,
|
89
91
|
context: nil,
|
90
92
|
examples: nil,
|
91
|
-
messages: nil,
|
92
93
|
temperature: nil,
|
93
94
|
candidate_count: nil,
|
94
95
|
top_p: nil,
|
95
96
|
top_k: nil,
|
96
|
-
client: nil
|
97
|
+
client: nil,
|
98
|
+
model: nil
|
97
99
|
)
|
98
100
|
# Overwrite the default ENDPOINT_URL for this method.
|
99
|
-
response = connection.post("/v1beta2/models/#{DEFAULTS[:chat_completion_model_name]}:generateMessage") do |req|
|
101
|
+
response = connection.post("/v1beta2/models/#{model || DEFAULTS[:chat_completion_model_name]}:generateMessage") do |req|
|
100
102
|
req.params = {key: api_key}
|
101
103
|
|
102
|
-
req.body = {prompt: {
|
103
|
-
|
104
|
-
req.body[:
|
105
|
-
req.body[:
|
104
|
+
req.body = {prompt: {}}
|
105
|
+
|
106
|
+
req.body[:prompt][:messages] = messages if messages
|
107
|
+
req.body[:prompt][:context] = context if context
|
108
|
+
req.body[:prompt][:examples] = examples if examples
|
109
|
+
|
106
110
|
req.body[:temperature] = temperature || DEFAULTS[:temperature]
|
107
111
|
req.body[:candidate_count] = candidate_count if candidate_count
|
108
112
|
req.body[:top_p] = top_p if top_p
|
@@ -163,8 +167,8 @@ module GooglePalmApi
|
|
163
167
|
# @param [String] prompt
|
164
168
|
# @return [Hash]
|
165
169
|
#
|
166
|
-
def count_message_tokens(
|
167
|
-
response = connection.post("/v1beta2/models/#{model}:countMessageTokens") do |req|
|
170
|
+
def count_message_tokens(prompt:, model: nil)
|
171
|
+
response = connection.post("/v1beta2/models/#{model || DEFAULTS[:chat_completion_model_name]}:countMessageTokens") do |req|
|
168
172
|
req.params = {key: api_key}
|
169
173
|
|
170
174
|
req.body = {prompt: {messages: [{content: prompt}]}}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_palm_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|