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

test_connection() returns different type of object, depending on whether ollama server is running. #29

Closed
otoomet opened this issue Nov 5, 2024 · 4 comments

Comments

@otoomet
Copy link

otoomet commented Nov 5, 2024

When the server is running, I get

> test_connection()
Ollama local server running
<httr2_response>
GET http://localhost:11434/
Status: 200 OK
Content-Type: text/plain
Body: In memory (17 bytes)

Note: this is a httr2_response object

When the server is not running, I get

> test_connection()
Ollama local server not running or wrong server.
Download and launch Ollama app to run the server. Visit https://ollama.com or https://github.com/ollama/ollama
<httr2_request>
GET http://localhost:11434
Body: empty

Note: this is httr2_request object.

The documentation states that:

Value
    A httr2 response object.

I'd expect the function to return an object of the same class in both cases, and the documentation to match the behavior.

A related note: it would be great to add another function, or maybe an argument (e.g. logical = TRUE), so that the function would return TRUE/FALSE. This would simplify testing in the code whether the server is running. Even if the result would correspond to the documentation, I need to test it using httr2 functionality, which is (slightly) more complex. There could also be another option (eg quietly = TRUE) to suppress the messages on screen.

@hauselin
Copy link
Owner

Thanks for the suggestion! I'll take a look and implement in the next version!

@hauselin
Copy link
Owner

The function now returns boolean instead of httr2_response object.

@otoomet
Copy link
Author

otoomet commented Dec 29, 2024

Thanks :-)

Will take a look when back at my work computer!

@hauselin
Copy link
Owner

hauselin commented Dec 30, 2024

I actually made a few changes so as to not break other packages that rely on ollamar. All the changes should address your issues above. See https://hauselin.github.io/ollama-r/reference/test_connection.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants