mlverse / chattr

https://mlverse.github.io/chattr/
Other
192 stars 20 forks source link

Error when submit question: `message` must be a character vector, not a <httr2_response> object. #90

Closed Seviks closed 6 months ago

Seviks commented 6 months ago

When submit a text or a question, there is no anwer and an error is raised (see below).

R version: 4.3.3 packages are up to date Installed with remotes::install_github("mlverse/chattr") per 23th of April.

Example:

Error: 
! in callr subprocess.
Caused by error in `abort(req_result)`:
! `message` must be a character vector, not a <httr2_response> object.
---
Subprocess backtrace:
 1. chattr::ch_submit(defaults = defaults, prompt = prompt, stream = stream, …
 2. chattr:::ch_submit.ch_openai(defaults = defaults, prompt = prompt, stream = stream, …
 3. chattr:::ch_openai_complete(prompt = prompt, defaults = defaults)
 4. rlang::abort(req_result)
 5. rlang:::validate_signal_args(message, class, call, .subclass, "abort")
 6. rlang:::check_character(message, call = env)
 7. rlang:::stop_input_type(x, "a character vector", ..., allow_na = FALSE, …
 8. rlang::abort(message, ..., call = call, arg = arg)
 9. | rlang:::signal_abort(cnd, .file)
10. | base::signalCondition(cnd)
11. global (function (e) …
Warning: Error in observe: Streaming returned error
  51: <Anonymous>
  50: signalCondition
  49: signal_abort
  48: abort
  47: observe
  46: <observer>
   3: shiny::runApp
   2: runGadget
   1: chattr:::chattr_app
edgararuiz commented 6 months ago

Hi, @Seviks , what does simply using chattr() or maybe chattr_test() returns?

Seviks commented 6 months ago

See below for the two returns. Apparently I misunderstood the pricing plan - it seems the API does not work with free trial. Since the problem does not concern the tool, I am closing this issue - maybe you want to check if a specific error message is appropriate.

> chattr()

── chattr - Available models 
Select the number of the model you would like to use:

1: OpenAI - Chat Completions - gpt-3.5-turbo (gpt35) 

2: OpenAI - Chat Completions - gpt-4 (gpt4) 

Selection: 1

── chattr 
• Provider: OpenAI - Chat Completions
• Path/URL: https://api.openai.com/v1/chat/completions
• Model: gpt-3.5-turbo
• Label: GPT 3.5 (OpenAI)
Error in `ide_build_prompt()`:
! No 'prompt' provided, and no prompt cannot be infered from the current document
Run `rlang::last_trace()` to see where the error occurred.
> chattr_test()
! {error}Type:insufficient_quota
Message: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
Error in `abort()`:
! `message` must be a character vector, not a <httr2_response> object.
Run `rlang::last_trace()` to see where the error occurred.