Skip to content

OLLAMA


OLLAMA_HOST=0.0.0.0:11434 ollama serve


curl https://ai.newatlantis.top/ollama/api/generate \
--location --insecure --request POST \
--header 'Authorization: Bearer sk-ENTROPY' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "mistral:7b",
  "prompt": "Why is the sky blue?",
  "stream": false
}'


curl http://192.168.7.209:11435/api/generate \
--location --insecure --request POST \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "mistral:7b",
  "prompt": "Why is the sky blue?",
  "stream": false
}'

curl http://10.66.66.14:11434/api/generate \
--location --insecure --request POST \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "mistral:7b",
  "prompt": "Why is the sky blue?",
  "stream": false
}'


curl https://ollama.newatlantis.top/api/generate \
--location --insecure --request POST \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "mistral:7b",
  "prompt": "Why is the sky blue?",
  "stream": false
}'

Proxy Query


Write me a nodejs script in ES6 syntax that will proxy HTTP requests adding a bearer token making making sure to preserver the request type, path, and other headers and only chaging the HOST and weather the proxy is HTTP or HTTPS


import http from 'http';
import httpProxy from 'http-proxy';

// Create a proxy server with custom application logic
const proxy = httpProxy.createProxyServer({});

// Create your server that makes an operation that waits a while
// and then proxies the request
http.createServer((req, res) => {
  // Modify headers
  req.headers['Authorization'] = 'Bearer sk-56442f1e0c534aaaa22b9d34c8b55501';

  // You can modify the target based on the incoming request,
  // or by any other environmental factors, etc.
  let target = {
    host: 'ai.newatlantis.top', // Target host
    protocol: 'https:', // Target protocol (http: or https:)
    port: 443 // Target port (80 for http, 443 for https)
  };

// Change origin to true to update host header to target host
const options = {
    target: target,
    changeOrigin: true,
    secure: true, // Set to false if you want to ignore SSL validation errors (not recommended)
  };

  // Proxy the request with the modified headers and target
  proxy.web(req, res, options, (error) => {
    if (error) {
      console.error('Proxy error:', error);
      res.writeHead(500, { 'Content-Type': 'text/plain' });
      res.end('Error when connecting to proxy');
    }
  });
}).listen(8000);

console.log('Proxy server running on http://localhost:8000');