ollama java
1.0.0
อินเทอร์เฟซ Ollamaservice ให้การโต้ตอบกับ Ollama Web Service
public interface OllamaService {
CompletionResponse completion ( CompletionRequest completionRequest );
TagsResponse getTags ();
ShowResponse show ( ShowRequest showRequest );
void copy ( CopyRequest copyRequest );
void delete ( String modelName );
void streamingCompletion ( CompletionRequest completionRequest , StreamResponseProcessor < String > handler );
EmbeddingResponse embed ( EmbeddingRequest embeddingRequest );
} คลาส OllamaserviceFactory มีหน้าที่รับผิดชอบในการสร้างอินสแตนซ์ของ OllamaService มันมีวิธีการสร้างเพื่อสร้างอินสแตนซ์ของบริการด้วยการกำหนดค่าที่ระบุ
public class OllamaServiceFactory {
public static OllamaService create ( OllamaProperties properties ) { // ...
}
public static OllamaService create ( OllamaProperties properties , Gson gson ) { // ...
}
}อินเทอร์เฟซ StreamResponseProcessor มีวิธีการในการประมวลผลการตอบสนองการสตรีม
public interface StreamResponseProcessor < T > {
void processStreamItem ( T item );
void processCompletion ( T fullResponse );
void processError ( Throwable throwable );
} เพียงสร้างอินสแตนซ์ของ OllamaService กับโรงงานและใช้งาน
ดูที่นี่
หรือดูโครงการ Spring-Boot-ollama-Sample
https://github.com/jmorganca/ollama/blob/main/docs/api.md
https://github.com/jmorganca/ollama/blob/main/docs/linux.md
$ curl https://ollama.ai/install.sh | sh
>>> Installing ollama to /usr/local/bin...
>>> Creating ollama user...
>>> Adding current user to ollama group...
>>> Creating ollama systemd service...
>>> Enabling and starting ollama service...
Created symlink /etc/systemd/system/default.target.wants/ollama.service → /etc/systemd/system/ollama.service.
>>> NVIDIA GPU installed. # open http://localhost:11434/
# or via curl
$ curl http://localhost:11434/api/tags
$ ollama run mistralหากต้องการดูบันทึกของ Ollama ที่ทำงานเป็นบริการเริ่มต้นให้เรียกใช้:
$ journalctl -u ollamaลบบริการ Ollama:
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.serviceลบ Ollama Binary ออกจากไดเรกทอรีถังขยะของคุณ (ทั้ง /usr /local /bin, /usr /bin, หรือ /bin):
sudo rm $( which ollama )ลบผู้ใช้บริการที่ดาวน์โหลดและ Ollama Service:
sudo rm -r /usr/share/ollama
sudo userdel ollama