10 Ollama JSON API
Uç Noktası | Tanım |
---|---|
/api/blob | |
/api/chat | |
/api/copy | |
/api/create | |
/api/delete | |
/api/embed | |
/api/embeddings | |
/api/generate | |
/api/ps | |
/api/pull | |
/api/push | |
/api/show | |
/api/tags | |
/api/version |
Ollama serve komutu ile arkaplan hizmeti başlatıyoruz
ollama serve
http://localhost:11434/
Ollama API örnek ve dokumantasyonu
İlk örnekler için curl komutunu kullanacağız. Windows’ta aşağıdaki scoop komutu ile kurabilirsiniz.
scoop install curl
API sunum noktası varsayılan değerlerde: http://localhost:11434/api uç noktasıdır.
API JSON nesneleri ile çağırılır. Çağrılabilecek
{
"model": "ds15",
"prompt": "What is your name?"
}
En basit çağrıda sonuçlar bir akış (stream) olarak döndürülür.
curl http://localhost:11434/api/generate -d '{"model": "ds15", "prompt": "What is your name?" } '
Daha kolay olması için stream false ile çağıralım.
curl http://localhost:11434/api/generate -d '{"model": "ds15", "prompt": "What is your name?", "stream": false } '
curl http://localhost:11434/api/chat -d '{"model": "ds15", "prompt": "What is your name?", "stream": false } '
“format”:“json”
10.1 API Generate vs chat
Aşağıda çevirisi yapılmış Reddit yazısı
Generate, sıfır atış (zero shot) cağrısıdır. Yani bir istek gönderirsiniz ve model bir yanıt üretir. Bu, konuşmanın sonudur.
Chat (sohbet), ileri geri konuşma yapabilir ve önceki aramaları bağlama dahil eder.
Aşağıdaki örnek ollama github sorunlardan alınmıştır.
Generate: Oluştur: Tek bir mesaj gönder ve yanıt al.
Chat: tek bir mesaj ve önceki sohbet geçmişini gönderip yanıt alın.
TODO: Aşağıdaki test edin, birlikte sohbet etmek için iki mesaj mı göndermemiz gerekiyor yoksa tek tek mesajlar da işe yarıyor mu?
İngilizce
What’s the capital of France? LLM: Paris
And what about Germany? LLM: ???
Türkçe > Fransa’nın başkenti neresidir? > LLM: Paris
Peki ya Almanya? LLM: ???
10.2 Diğer öğreticiler
- https://geshan.com.np/blog/2025/02/ollama-api/