|
import requests |
|
import json |
|
import subprocess |
|
|
|
def run_command(command): |
|
try: |
|
result = subprocess.run(command, shell=True, check=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
print(f"Success: {result.stdout}") |
|
except subprocess.CalledProcessError as e: |
|
print(f"Error: {e.stderr}") |
|
|
|
run_command("ollama serve") |
|
|
|
reqUrl = "http://localhost:11434/api/pull" |
|
|
|
headersList = { |
|
"Accept": "*/*", |
|
"Content-Type": "application/json" |
|
} |
|
|
|
payload = json.dumps({ |
|
"name": "gemma:7b" |
|
}) |
|
|
|
response = requests.request("POST", reqUrl, data=payload, headers=headersList) |
|
|
|
print(response.text) |