perplexity_api 0.1.1 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 821bf76a4e00f4a38efd595687006831daf4b0bbd5166df367dd9435b0a05869
4
- data.tar.gz: 6d0e5e40ed4e61ea77f41b731b7586e201448defabd51f47715942f3e4aebff5
3
+ metadata.gz: e12f67af2fe793c9b3e55bab4bf16bb16ddc01340af2b6ed1ae89e54c0501a63
4
+ data.tar.gz: adec45a5e5209bafef27fc2ce2dd8a098654b1c7ef32de6c52bd62629a40a14c
5
5
  SHA512:
6
- metadata.gz: 23add32739947a021034a449583aeecd09e446ff2b5f109669a767785894e8b75387ad778293433538dc3f6309fbbd57200c06c7acbd4746de9a839c0c4b7763
7
- data.tar.gz: 511c3f2abd79b85b49d9f9c7c4c22fc66b021d2dd266785693e0e6018c75171683de4ddcb2a7ff00014f99eebb9cb33689e0ba89b22eac4b65feddea4854c772
6
+ metadata.gz: 1823a33101eea983a021a20c225a379193116bc0efbaffc8aff5a49afd45d111fcb096ef6a10da433a5b136c4f8469911c3b74a46744d9873d8a0fc39aa640f3
7
+ data.tar.gz: 7d73bbe2a1d1b865bc5c72f440ebf7622df70001b0ac5f453d65432fc3668eaa507b67b6fcd3883baed28a6425d3aa130d3dfcd8f41f011732af71461fc4d7a3
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,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ perplexity_api (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.6.1)
10
+ rake (10.5.0)
11
+ rspec (3.13.0)
12
+ rspec-core (~> 3.13.0)
13
+ rspec-expectations (~> 3.13.0)
14
+ rspec-mocks (~> 3.13.0)
15
+ rspec-core (3.13.3)
16
+ rspec-support (~> 3.13.0)
17
+ rspec-expectations (3.13.3)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.13.0)
20
+ rspec-mocks (3.13.2)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.13.0)
23
+ rspec-support (3.13.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.17)
30
+ perplexity_api!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.17.2
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # PerplexityApi
2
+ [![Gem Version](https://badge.fury.io/rb/perplexity_api.svg)](https://badge.fury.io/rb/perplexity_api)
3
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
2
4
 
3
5
  A Ruby wrapper gem for Perplexity AI's API. This gem allows you to easily integrate Perplexity AI's powerful language models into your Ruby applications.
4
6
 
@@ -37,23 +39,16 @@ There are multiple ways to configure the API key:
37
39
 
38
40
  #### 1. Using Environment Variables (Recommended)
39
41
 
40
- The gem will automatically look for environment variables. Create a `.env` file in your project root:
42
+ The gem will automatically look for environment variables:
41
43
 
42
44
  ```
43
45
  PERPLEXITY_API_KEY=your-api-key-here
44
46
  ```
45
47
 
46
- A sample `.env.sample` file is included in the repository as a template. Copy it to create your own `.env` file:
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:
48
+ A sample `.env.sample` file is included in the repository as a template for the environment variables you can use:
55
49
 
56
50
  ```
51
+ PERPLEXITY_API_KEY=your-api-key-here
57
52
  PERPLEXITY_DEFAULT_MODEL=sonar
58
53
  PERPLEXITY_TEMPERATURE=0.5
59
54
  PERPLEXITY_MAX_TOKENS=2048
@@ -61,6 +56,13 @@ PERPLEXITY_TOP_P=0.9
61
56
  PERPLEXITY_TOP_K=0
62
57
  ```
63
58
 
59
+ You can set these environment variables in your application's environment or use a method of your choice to load them from a `.env` file.
60
+
61
+ ```ruby
62
+ # After setting environment variables, use the PerplexityApi gem
63
+ require 'perplexity_api'
64
+ ```
65
+
64
66
  #### 2. Using Ruby Configuration
65
67
 
66
68
  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(load_env: true, debug_mode: false)
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 load_dotenv(debug_mode: false)
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
@@ -1,3 +1,3 @@
1
1
  module PerplexityApi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -21,9 +21,4 @@ module PerplexityApi
21
21
  client = Client.new(api_key: api_key)
22
22
  client.models
23
23
  end
24
-
25
- # Helper method to explicitly load .env file
26
- def self.load_env(debug_mode: false)
27
- load_dotenv(debug_mode: debug_mode)
28
- end
29
24
  end
@@ -38,7 +38,6 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "bundler", "~> 1.17"
39
39
  spec.add_development_dependency "rake", "~> 10.0"
40
40
  spec.add_development_dependency "rspec", "~> 3.0"
41
- spec.add_development_dependency "dotenv", "~> 2.7"
42
41
 
43
42
  spec.required_ruby_version = ">= 2.6.0"
44
43
  end
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perplexity_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hisafumi Kikkawa
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
10
  date: 2025-03-27 00:00:00.000000000 Z
@@ -52,20 +51,6 @@ dependencies:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
53
  version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: dotenv
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '2.7'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '2.7'
69
54
  description: A Ruby library for easily using Perplexity AI's API. Allows setting API
70
55
  keys, selecting models, and customizing options.
71
56
  email:
@@ -77,9 +62,11 @@ files:
77
62
  - ".env.sample"
78
63
  - ".gitignore"
79
64
  - ".rspec"
65
+ - ".rspec_status"
80
66
  - ".travis.yml"
81
67
  - CODE_OF_CONDUCT.md
82
68
  - Gemfile
69
+ - Gemfile.lock
83
70
  - LICENSE.txt
84
71
  - PUBLISHING.md
85
72
  - README.md
@@ -99,7 +86,6 @@ metadata:
99
86
  homepage_uri: https://github.com/hisafumi-kikkawa/perplexity_api
100
87
  source_code_uri: https://github.com/hisafumi-kikkawa/perplexity_api
101
88
  changelog_uri: https://github.com/hisafumi-kikkawa/perplexity_api/blob/master/CHANGELOG.md
102
- post_install_message:
103
89
  rdoc_options: []
104
90
  require_paths:
105
91
  - lib
@@ -114,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
100
  - !ruby/object:Gem::Version
115
101
  version: '0'
116
102
  requirements: []
117
- rubygems_version: 3.0.3.1
118
- signing_key:
103
+ rubygems_version: 3.6.2
119
104
  specification_version: 4
120
105
  summary: Ruby wrapper for Perplexity API
121
106
  test_files: []