File size: 754 Bytes
4f7b4af
 
 
8c58253
4f7b4af
 
 
 
 
 
 
89f0c44
d6cc00c
89f0c44
 
 
 
 
4f7b4af
89f0c44
 
4f7b4af
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from ollama import generate
from config import Config
from helpers.image_helper import get_image_bytes
import requests

system_prompt = Config.SYSTEM_PROMPT

def analyze_image_file(image_file, model, user_prompt):
    # gets image bytes using helper function
    image_bytes = get_image_bytes(image_file)

    # API call to remote Ollama server (update with actual URL)
    url = 'https://5cf5-2401-4900-882d-894-a2-f66f-ba2b-969f.ngrok-free.app '
    data = {
        'model': model,
        'prompt': user_prompt,
        'image_bytes': image_bytes
    }

    response = requests.post(url, json=data)
    return response.json()

# handles stream response back from LLM
def stream_parser(stream):
    for chunk in stream:
        yield chunk['response']