llm_lib 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/llm_lib/restclient.rb +0 -4
- data/lib/llm_lib.rb +5 -41
- 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: a7fe9391bf23bcbe47c61ac8e8449536eb3052a19f8150813bf125861492d167
|
4
|
+
data.tar.gz: c2107e7106b73200502730c128fe0220a2a374d8f1ba6cfe5e6db48c8e78b95d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc56b149e4e2e127857528a6c1754cf4e472eab9a09a4e34932b9a63d5d200eba80718b9c87dfa0f2d6d7901e9c95526b28dd348e870cc171a601b245c465830
|
7
|
+
data.tar.gz: d456b665985410472ba8248a517ab0bcc9126532cf11df46bf2e4134e8aafbb3903cdf9215164b280ff8f7b1ce55920f5af41792bb70268b54d8c71ca202300b
|
data/lib/llm_lib/restclient.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
class LlmLib::Restclient
|
2
2
|
|
3
|
-
# def self.post(url:, body:, headers: {})
|
4
3
|
def self.post(url:, body:, apikey:)
|
5
4
|
|
6
5
|
url = URI(url)
|
@@ -13,10 +12,7 @@ def self.post(url:, body:, apikey:)
|
|
13
12
|
request = Net::HTTP::Post.new(url.path)
|
14
13
|
request['Content-Type'] = 'application/json'
|
15
14
|
request["cache-control"] = 'no-cache'
|
16
|
-
# request["apikey"] = apikey
|
17
|
-
# headers.each { |key, value| request[key] = value }
|
18
15
|
request['Authorization'] = "Bearer #{apikey}"
|
19
|
-
# request.set_form_data(body)
|
20
16
|
request.body = JSON.generate(body)
|
21
17
|
|
22
18
|
begin
|
data/lib/llm_lib.rb
CHANGED
@@ -11,43 +11,13 @@ module LlmLib
|
|
11
11
|
# response = client.chat_gpt_call(prompt, max_tokens)
|
12
12
|
# puts response
|
13
13
|
|
14
|
-
# remove
|
15
|
-
# attr_reader :apikey
|
16
|
-
# def def initialize(apikey, query)
|
17
|
-
# @apikey, @query = apikey, query
|
18
|
-
# end
|
19
|
-
|
20
14
|
def initialize(apikey)
|
21
15
|
@apikey = apikey
|
22
16
|
end
|
23
17
|
|
24
|
-
# def chat_gpt_call(prompt, max_tokens, temperature = 0, top_p = 1, n = 1, stream = false, logprobs = nil, stop = "\n")
|
25
|
-
# model = "text-davinci-003"
|
26
|
-
# response = self.class.send(@api_key, {
|
27
|
-
# "model" => model,
|
28
|
-
# "prompt" => prompt,
|
29
|
-
# "max_tokens" => max_tokens,
|
30
|
-
# "temperature" => temperature,
|
31
|
-
# "top_p" => top_p,
|
32
|
-
# "n" => n,
|
33
|
-
# "stream" => stream,
|
34
|
-
# "logprobs" => logprobs,
|
35
|
-
# "stop" => stop
|
36
|
-
# })
|
37
|
-
# response
|
38
|
-
# end
|
39
|
-
|
40
|
-
# def self.send(apikey, body)
|
41
|
-
# LlmLib::Restclient.post(
|
42
|
-
# body: body,
|
43
|
-
# url: "https://api.openai.com/v1/completions",
|
44
|
-
# apikey: apikey
|
45
|
-
# )
|
46
|
-
# end
|
47
|
-
|
48
18
|
def chat_gpt_call(prompt, max_tokens, temperature = 0, top_p = 1, n = 1, stream = false, stop = "\n")
|
49
19
|
model = "gpt-3.5-turbo"
|
50
|
-
response = OpenAI.send(@
|
20
|
+
response = OpenAI.send(@apikey,
|
51
21
|
model,
|
52
22
|
prompt,
|
53
23
|
max_tokens,
|
@@ -62,7 +32,7 @@ module LlmLib
|
|
62
32
|
|
63
33
|
def gpt4_call(prompt, max_tokens, temperature = 0, top_p = 1, n = 1, stream = false, stop = "\n")
|
64
34
|
model = "gpt-4"
|
65
|
-
response = OpenAI.send(@
|
35
|
+
response = OpenAI.send(@apikey,
|
66
36
|
model,
|
67
37
|
prompt,
|
68
38
|
max_tokens,
|
@@ -97,8 +67,9 @@ module LlmLib
|
|
97
67
|
|
98
68
|
def hugging_bloom_call(query, model = "bigscience/bloom")
|
99
69
|
response = HuggingFace.send(@api_key,
|
100
|
-
|
101
|
-
|
70
|
+
model,
|
71
|
+
query
|
72
|
+
)
|
102
73
|
response
|
103
74
|
end
|
104
75
|
|
@@ -116,13 +87,6 @@ module LlmLib
|
|
116
87
|
response
|
117
88
|
end
|
118
89
|
|
119
|
-
# def self.send(apikey, body, model)
|
120
|
-
# LlmLib::Restclient.post(
|
121
|
-
# body: body,
|
122
|
-
# url: "https://api-inference.huggingface.co/models/#{model}",
|
123
|
-
# apikey: apikey
|
124
|
-
# )
|
125
|
-
# end
|
126
90
|
end
|
127
91
|
|
128
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: llm_lib
|
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
|
- Chamath Attanayaka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uri
|