@@ -87,7 +87,8 @@ make_req <- function(req_data, server, endpoint, perform = TRUE) {
87
87
httr2 :: req_url_path_append(endpoint ) | >
88
88
httr2 :: req_body_json(prep_req_data(req_data ), auto_unbox = FALSE ) | >
89
89
# turn off errors since error messages can't be seen in sub-process
90
- httr2 :: req_error(is_error = function (resp ) FALSE )
90
+ httr2 :: req_error(is_error = function (resp ) FALSE ) | >
91
+ httr2 :: req_headers(!!! get_headers())
91
92
if (perform ) {
92
93
r <- r | >
93
94
httr2 :: req_perform() | >
@@ -97,6 +98,27 @@ make_req <- function(req_data, server, endpoint, perform = TRUE) {
97
98
}
98
99
99
100
101
+ get_headers <- function () {
102
+ agent <- the $ agent
103
+ if (is.null(agent )) {
104
+ sess <- sessionInfo()
105
+ the $ agent <- agent <- paste0(
106
+ " rollama/" , packageVersion(" rollama" ),
107
+ " (" , sess $ platform , " ) " ,
108
+ sess $ R.version $ version.string
109
+ )
110
+ }
111
+ list (
112
+ " Content-Type" = " application/json" ,
113
+ " Accept" = " application/json" ,
114
+ " User-Agent" = agent ,
115
+ # get additional headers from option (if set)
116
+ getOption(" rollama_headers" )
117
+ ) | >
118
+ unlist()
119
+ }
120
+
121
+
100
122
screen_answer <- function (x , model = NULL ) {
101
123
pars <- unlist(strsplit(x , " \n " , fixed = TRUE ))
102
124
cli :: cli_h1(" Answer from {cli::style_bold({model})}" )
0 commit comments