perplexity_api 0.1.1 → 0.2.0
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/.rspec_status +24 -0
- data/Gemfile.lock +37 -0
- data/README.md +13 -10
- data/lib/perplexity_api/configuration.rb +2 -22
- data/lib/perplexity_api/version.rb +1 -1
- data/lib/perplexity_api.rb +0 -5
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1fb38e349b1dec664c558b497eb1cfebb13db32a2dfe8b73235c67d1d60a8da
|
4
|
+
data.tar.gz: 65c6e01e0fc38d3709b74928931804a1cd2894c5c1e2f1229f2efa12347c2a24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbf92894516bd532e9027e64d100d98559610d14f879d4e6e346998d3adf85ba5f4dbc3c108db9c62773dd8a935ddd95df6c2e1c75fabc3ccd1efe8c85e3fd2d
|
7
|
+
data.tar.gz: 5cb07fc82fad69e9f4c0b483db88e6f010250360f9aff30ab3e02152dd28eb6d9a08a901f98ae066b3eeddf1aa9c860060fe0cdbfaba00d0263073ec41ce6043
|
data/.rspec_status
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
---------------------------------------------------- | ------ | --------------- |
|
3
|
+
./spec/perplexity_api/client_spec.rb[1:1:1:1] | passed | 0.0228 seconds |
|
4
|
+
./spec/perplexity_api/client_spec.rb[1:1:2:1] | passed | 0.0001 seconds |
|
5
|
+
./spec/perplexity_api/client_spec.rb[1:2:1] | passed | 0.00063 seconds |
|
6
|
+
./spec/perplexity_api/client_spec.rb[1:2:2] | passed | 0.00161 seconds |
|
7
|
+
./spec/perplexity_api/client_spec.rb[1:2:3:1] | passed | 0.0053 seconds |
|
8
|
+
./spec/perplexity_api/client_spec.rb[1:2:4:1] | passed | 0.00045 seconds |
|
9
|
+
./spec/perplexity_api/configuration_spec.rb[1:1:1:1] | passed | 0.0081 seconds |
|
10
|
+
./spec/perplexity_api/configuration_spec.rb[1:1:2:1] | passed | 0.00034 seconds |
|
11
|
+
./spec/perplexity_api/configuration_spec.rb[1:1:3:1] | passed | 0.00192 seconds |
|
12
|
+
./spec/perplexity_api/configuration_spec.rb[1:2:1] | passed | 0.00362 seconds |
|
13
|
+
./spec/perplexity_api/configuration_spec.rb[1:3:1:1] | passed | 0.00084 seconds |
|
14
|
+
./spec/perplexity_api/configuration_spec.rb[1:3:2:1] | passed | 0.00007 seconds |
|
15
|
+
./spec/perplexity_api/configuration_spec.rb[2:1:1] | passed | 0.00073 seconds |
|
16
|
+
./spec/perplexity_api/configuration_spec.rb[2:1:2] | passed | 0.00006 seconds |
|
17
|
+
./spec/perplexity_api/configuration_spec.rb[2:2:1] | passed | 0.00739 seconds |
|
18
|
+
./spec/perplexity_api/configuration_spec.rb[2:2:2] | passed | 0.0001 seconds |
|
19
|
+
./spec/perplexity_api/configuration_spec.rb[2:3:1] | passed | 0.00102 seconds |
|
20
|
+
./spec/perplexity_api_spec.rb[1:1] | passed | 0.00011 seconds |
|
21
|
+
./spec/perplexity_api_spec.rb[1:2:1] | passed | 0.00011 seconds |
|
22
|
+
./spec/perplexity_api_spec.rb[1:3:1] | passed | 0.00017 seconds |
|
23
|
+
./spec/perplexity_api_spec.rb[1:3:2] | passed | 0.00013 seconds |
|
24
|
+
./spec/perplexity_api_spec.rb[1:4:1:1] | passed | 0.00151 seconds |
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
perplexity_api (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.6.1)
|
10
|
+
dotenv (2.8.1)
|
11
|
+
rake (10.5.0)
|
12
|
+
rspec (3.13.0)
|
13
|
+
rspec-core (~> 3.13.0)
|
14
|
+
rspec-expectations (~> 3.13.0)
|
15
|
+
rspec-mocks (~> 3.13.0)
|
16
|
+
rspec-core (3.13.3)
|
17
|
+
rspec-support (~> 3.13.0)
|
18
|
+
rspec-expectations (3.13.3)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.13.0)
|
21
|
+
rspec-mocks (3.13.2)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.13.0)
|
24
|
+
rspec-support (3.13.2)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
bundler (~> 1.17)
|
31
|
+
dotenv (~> 2.7)
|
32
|
+
perplexity_api!
|
33
|
+
rake (~> 10.0)
|
34
|
+
rspec (~> 3.0)
|
35
|
+
|
36
|
+
BUNDLED WITH
|
37
|
+
1.17.2
|
data/README.md
CHANGED
@@ -37,23 +37,16 @@ There are multiple ways to configure the API key:
|
|
37
37
|
|
38
38
|
#### 1. Using Environment Variables (Recommended)
|
39
39
|
|
40
|
-
The gem will automatically look for environment variables
|
40
|
+
The gem will automatically look for environment variables:
|
41
41
|
|
42
42
|
```
|
43
43
|
PERPLEXITY_API_KEY=your-api-key-here
|
44
44
|
```
|
45
45
|
|
46
|
-
A sample `.env.sample` file is included in the repository as a template
|
47
|
-
|
48
|
-
```bash
|
49
|
-
cp .env.sample .env
|
50
|
-
```
|
51
|
-
|
52
|
-
Then edit the `.env` file with your actual API key. Make sure to add `.env` to your `.gitignore` file to avoid committing sensitive information.
|
53
|
-
|
54
|
-
You can also configure other options via environment variables:
|
46
|
+
A sample `.env.sample` file is included in the repository as a template for the environment variables you can use:
|
55
47
|
|
56
48
|
```
|
49
|
+
PERPLEXITY_API_KEY=your-api-key-here
|
57
50
|
PERPLEXITY_DEFAULT_MODEL=sonar
|
58
51
|
PERPLEXITY_TEMPERATURE=0.5
|
59
52
|
PERPLEXITY_MAX_TOKENS=2048
|
@@ -61,6 +54,16 @@ PERPLEXITY_TOP_P=0.9
|
|
61
54
|
PERPLEXITY_TOP_K=0
|
62
55
|
```
|
63
56
|
|
57
|
+
If you're using the dotenv gem in your application, you can load these variables from a `.env` file:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
require 'dotenv'
|
61
|
+
Dotenv.load # Load environment variables from .env file
|
62
|
+
|
63
|
+
# Then use the PerplexityApi gem
|
64
|
+
require 'perplexity_api'
|
65
|
+
```
|
66
|
+
|
64
67
|
#### 2. Using Ruby Configuration
|
65
68
|
|
66
69
|
To configure the API key in your code:
|
@@ -2,32 +2,13 @@ module PerplexityApi
|
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :api_key, :api_base, :default_model, :default_options, :debug_mode
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(debug_mode: false)
|
6
6
|
@debug_mode = debug_mode
|
7
7
|
|
8
|
-
# Load .env file if dotenv is available and load_env is true
|
9
|
-
if load_env
|
10
|
-
load_dotenv
|
11
|
-
end
|
12
|
-
|
13
8
|
# Load configuration from environment variables
|
14
9
|
load_from_env
|
15
10
|
end
|
16
11
|
|
17
|
-
def load_dotenv
|
18
|
-
begin
|
19
|
-
require "dotenv"
|
20
|
-
if File.exist?(".env")
|
21
|
-
Dotenv.load
|
22
|
-
debug_log "Loaded .env file"
|
23
|
-
else
|
24
|
-
debug_log ".env file not found"
|
25
|
-
end
|
26
|
-
rescue LoadError
|
27
|
-
debug_log "dotenv gem not available. Install it with: gem install dotenv"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
12
|
def load_from_env
|
32
13
|
@api_key = ENV["PERPLEXITY_API_KEY"]
|
33
14
|
@api_base = ENV["PERPLEXITY_API_BASE"] || "https://api.perplexity.ai"
|
@@ -65,9 +46,8 @@ module PerplexityApi
|
|
65
46
|
yield(configuration) if block_given?
|
66
47
|
end
|
67
48
|
|
68
|
-
def
|
49
|
+
def reload_env(debug_mode: false)
|
69
50
|
configuration.debug_mode = debug_mode
|
70
|
-
configuration.load_dotenv
|
71
51
|
configuration.load_from_env
|
72
52
|
end
|
73
53
|
end
|
data/lib/perplexity_api.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perplexity_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hisafumi Kikkawa
|
@@ -77,9 +77,11 @@ files:
|
|
77
77
|
- ".env.sample"
|
78
78
|
- ".gitignore"
|
79
79
|
- ".rspec"
|
80
|
+
- ".rspec_status"
|
80
81
|
- ".travis.yml"
|
81
82
|
- CODE_OF_CONDUCT.md
|
82
83
|
- Gemfile
|
84
|
+
- Gemfile.lock
|
83
85
|
- LICENSE.txt
|
84
86
|
- PUBLISHING.md
|
85
87
|
- README.md
|