aboutsummaryrefslogtreecommitdiffstats
path: root/runpod/main.py
blob: ae12ba482f3b996bc88940db18eb813dcdd7d347 (plain) (blame)
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
27
28
29
30
31
32
#!/usr/bin/env python
"""ollama-runpod endpoint"""


import runpod
import requests


def ollama(job):
    """the endpoint handler"""
    headers = {"Content-Type": "application/json"}
    data = {
        "model": job["model"],
        "system": job["prompt_system"],
        "prompt": job["prompt_user"] + job["content"],
        "stream": False,
        "format": "json",
        "options": {
            "temperature": job["temp"],
        },
    }

    response = requests.post(
        "http://127.0.0.1:11434/api/generate", data=data, headers=headers, timeout=10
    )

    return response


def main() -> None:
    """entrypoint"""
    runpod.serverless({"handler": ollama})