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

API call with python requests #6

Open
kubs0ne opened this issue May 23, 2024 · 1 comment
Open

API call with python requests #6

kubs0ne opened this issue May 23, 2024 · 1 comment

Comments

@kubs0ne
Copy link

kubs0ne commented May 23, 2024

Hello,
I was able to successfully run the server using the repo. However I am wondering how to perform an API call with python requests library. I was trying to do it like this:

`def _query():
    API_URL = 'http:https://localhost:8080/completion'
    
    image_path = ...
    user_prompt = ...
    
    with open(image_path, 'rb') as image_file:
        files = {'image_file': image_file}
        data = {'user_prompt': user_prompt}

        response = requests.post(API_URL, files=files, data=data)
        
        if response.status_code == 200:
            response_data = response.json()
            text = response_data['content']
            return text
        else:
            return f"Error: {response.status_code}"

response = _query()
print("Response:", response)`

I always get 404 error.

@trzy
Copy link
Owner

trzy commented May 23, 2024

I haven’t tested in a while but this repo should have examples for both this llava cpp server as well as llama.cpp (which I recommend you switch to because it is being actively developed still): https://github.com/trzy/multimodal-cloud-tests/blob/main/llava-cpp-test.py

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