File tree Expand file tree Collapse file tree 2 files changed +13
-15
lines changed Expand file tree Collapse file tree 2 files changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -5,16 +5,17 @@ module RubyLLM
5
5
class Connection
6
6
attr_reader :provider , :connection , :config
7
7
8
- def self . basic
9
- Faraday . new do |faraday |
10
- faraday . response :logger ,
11
- RubyLLM . logger ,
12
- bodies : false ,
13
- response : false ,
14
- errors : true ,
15
- headers : false ,
16
- log_level : :debug
17
- faraday . use Faraday ::Response ::RaiseError
8
+ def self . basic ( &)
9
+ Faraday . new do |f |
10
+ f . response :logger ,
11
+ RubyLLM . logger ,
12
+ bodies : false ,
13
+ response : false ,
14
+ errors : true ,
15
+ headers : false ,
16
+ log_level : :debug
17
+ f . response :raise_error
18
+ yield f if block_given?
18
19
end
19
20
end
20
21
Original file line number Diff line number Diff line change @@ -85,14 +85,11 @@ def respond_to_missing?(method, include_private = false)
85
85
def fetch_from_parsera
86
86
RubyLLM . logger . info 'Fetching models from Parsera API...'
87
87
88
- connection = Faraday . new ( 'https://api.parsera.org' ) do |f |
88
+ connection = Connection . basic do |f |
89
89
f . request :json
90
90
f . response :json , parser_options : { symbolize_names : true }
91
- f . response :raise_error
92
- f . adapter Faraday . default_adapter
93
91
end
94
-
95
- response = connection . get ( '/v1/llm-specs' )
92
+ response = connection . get 'https://api.parsera.org/v1/llm-specs'
96
93
response . body . map { |data | Model ::Info . new ( data ) }
97
94
end
98
95
You can’t perform that action at this time.
0 commit comments