Created
January 31, 2025 10:06
-
-
Save ZiTAL/b74823c91e09cd0dc0e9a947877d374f to your computer and use it in GitHub Desktop.
orange pi / raspberry pi deepseek: ollama server and client example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| mkdir -p /tmp/ollama | |
| cd /tmp/ollama | |
| wget https://github.com/ollama/ollama/releases/download/v0.5.7/ollama-linux-arm64.tgz | |
| tar -xvzf ollama-linux-arm64.tgz | |
| mv /tmp/ollama /opt | |
| ln -s /opt/ollama/bin/ollama /usr/local/bin/ollama | |
| chmod +x /usr/local/bin/ollama |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /etc/systemd/system/ollama-server.service | |
| [Unit] | |
| Description=Ollama server | |
| After=network.target | |
| [Service] | |
| Environment="OLLAMA_HOST=0.0.0.0:3001" | |
| WorkingDirectory=/home/pi | |
| User=pi | |
| Group=pi | |
| ExecStart=/usr/local/bin/ollama serve | |
| [Install] | |
| WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /etc/systemd/system/ollama.service | |
| [Unit] | |
| Description=Ollama DeepSeek 1.5b | |
| After=network.target | |
| [Service] | |
| Environment="OLLAMA_HOST=0.0.0.0:3001" | |
| WorkingDirectory=/home/pi | |
| User=pi | |
| Group=pi | |
| ExecStart=/usr/local/bin/ollama run deepseek-r1:1.5b | |
| [Install] | |
| WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| systemctl daemon-reload | |
| systemctl enable ollama-server | |
| systemctl enable ollama | |
| systemctl start ollama-server | |
| systemctl start ollama |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server_name ia.zital.eus ia.opi5; | |
| location / { | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto $scheme; | |
| proxy_set_header Connection ""; | |
| proxy_buffering off; | |
| proxy_pass http://ia.opi5:3001; | |
| chunked_transfer_encoding on; | |
| } | |
| error_log /var/log/nginx/ia-error.log; | |
| access_log /var/log/nginx/ia-access.log; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import requests | |
| import json | |
| prompt = " ".join(sys.argv[1:]) | |
| if prompt.strip() == '': | |
| print("Prompt required") | |
| sys.exit() | |
| url = "https://ia.zital.eus/api/generate" | |
| payload = { | |
| "model": "deepseek-r1:1.5b", | |
| "prompt": prompt, | |
| "stream": True | |
| } | |
| response = requests.post(url, json=payload, stream=True) | |
| for line in response.iter_lines(): | |
| if line: | |
| chunk = json.loads(line.decode('utf-8')) | |
| print(chunk.get("response", ""), end="", flush=True) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python3 client.py Hi