Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: gptstudio::gptstudio_sitrep() states failing to connect to Anthropic API when it is actually connected #231

Open
3 tasks done
bio-info-guy opened this issue Oct 18, 2024 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@bio-info-guy
Copy link

Confirm setup

  • I have installed the development version of {gptstudio} (pak::pak("MichelNivard/gptstudio")) and tested if the problem remains.
  • I have installed the {reprex} and {sessioninfo} packages to be able to run this issue's code snippet pak::pak(c("reprex", "sessioninfo")).

What happened?

When i run the command gptstudio::gptstudio_sitrep(), it states that I failed to connect to the Anthropic API service. However, I can confirm that I am using my own API for anthropic. Upon a closer look, I believe that the check_api_connection_anthropic function checks for connecitivity by calling for claude-2.1, which requires a request url of: "https://api.anthropic.com/v1/complete" and not ""https://api.anthropic.com/v1/messages".

Relevant log output

> req_headers(request("https://api.anthropic.com/v1/complete"), 
            `anthropic-version` = "2023-06-01", `content-type` = "application/json", 
            `x-api-key` = Sys.getenv("ANTHROPIC_API_KEY")) |>
         httr2::req_body_json(
                data = list(
                        prompt = "\n\nHuman: Hello, Claude\n\nAssistant:",
                        model = "claude-2.1",
                        max_tokens_to_sample = 1024
                 )
             ) |> httr2::req_error(is_error = function(resp) FALSE) |> req_perform()
#OUTPUT:
#<httr2_response>
#POST https://api.anthropic.com/v1/complete
#Status: 200 OK
#Content-Type: application/json
#Body: In memory (195 bytes)

> req_headers(request("https://api.anthropic.com/v1/messages"), 
            `anthropic-version` = "2023-06-01", `content-type` = "application/json", 
            `x-api-key` = Sys.getenv("ANTHROPIC_API_KEY")) |>
         httr2::req_body_json(
                data = list(
                        prompt = "\n\nHuman: Hello, Claude\n\nAssistant:",
                        model = "claude-2.1",
                        max_tokens_to_sample = 1024
                 )
             ) |> httr2::req_error(is_error = function(resp) FALSE) |> req_perform()
#OUTPUT:
#<httr2_response>
#POST https://api.anthropic.com/v1/messages
#Status: 400 Bad Request
#Content-Type: application/json
#Body: In memory (94 bytes)

Session info

gptstudio::gptstudio_sitrep()
#> 
#> ── Configuration for gptstudio ─────────────────────────────────────────────────
#> Using user configuration file at
#> '/Users/ysu13/Library/Preferences/org.R-project.R/R/gptstudio/config.yml'
#> 
#> 
#> ── Current Settings ──
#> 
#> 
#> 
#> - Model: claude-3-5-sonnet-20240620
#> 
#> - Task: coding
#> 
#> - Language: en
#> 
#> - Service: anthropic
#> 
#> - Custom prompt:
#> 
#> - Stream: TRUE
#> 
#> - Code style: tidyverse
#> 
#> - Skill: beginner
#> 
#> 
#> 
#> ── Checking API connections ──
#> 
#> 
#> 
#> ── Checking OpenAI API connection 
#> 
#> ✖ API key is not set or invalid for OpenAI service.
#> 
#> 
#> 
#> ── Checking HuggingFace API connection 
#> 
#> ✖ API key is not set or invalid for HuggingFace service.
#> 
#> 
#> 
#> ── Checking Anthropic API connection 
#> 
#> ✖ Failed to connect to the Anthropic API service.
#> 
#> 
#> 
#> ── Checking Google AI Studio API connection 
#> 
#> ✖ API key is not set or invalid for Google AI Studio service.
#> 
#> 
#> 
#> ── Checking Azure OpenAI API connection 
#> 
#> ✖ API key is not set or invalid for Azure OpenAI service.
#> 
#> 
#> 
#> ── Checking Perplexity API connection 
#> 
#> ✖ API key is not set or invalid for Perplexity service.
#> 
#> 
#> 
#> ── Checking Cohere API connection 
#> 
#> ✖ API key is not set or invalid for Cohere service.
#> 
#> 
#> 
#> ── Check Ollama for Local API connection 
#> 
#> ✖ Couldn't connect to Ollama in <http://localhost:11434>. Is it running there?
#> 
#> 
#> 
#> ── Getting help ──
#> 
#> 
#> 
#> See the gptstudio homepage (<https://michelnivard.github.io/gptstudio/>) for
#> getting started guides and package documentation. File an issue or contribute
#> to the package at the GitHub repo
#> (<https://github.com/MichelNivard/gptstudio>).
#> ── End of gptstudio configuration ──────────────────────────────────────────────

Code of Conduct

  • I agree to follow this project's Code of Conduct
@bio-info-guy bio-info-guy added the bug an unexpected problem or unintended behavior label Oct 18, 2024
@calderonsamuel
Copy link
Collaborator

Thank you for your report and your reprex. We'll take a look into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants