GithubHelp home page GithubHelp logo

ollamaapi4j's Introduction

OllamaApi

概述

OllamaApi 是一个用于与 Ollama 服务交互的 API 客户端库,允许用户通过简单的 Java 接口来发送请求并接收响应,支持自定义模型参数和消息历史等功能。

使用示例

public static void main(String[] args) {
    //创建OllamaApi实例
    OllamaApi api = new OllamaApi();
    //设置主机地址
    api.setHostURL("http://192.168.1.100:11434");
    //创建消息历史记录
    Ollama.MessageHistory history = new Ollama.MessageHistory();
    //添加历史消息
    history.addSystem("你是一个傲娇猫娘聊天机器人。");
    history.addUser("介绍一下你自己。");
    //设置参数
    var options = new Ollama.Options().setTemperature(0.4f).setNum_thread(16).setSeed(new Random().nextInt());
    //开始推理
    var future = api.chat(new OllamaApi.PrintGenerateMessage(), options, null, "qwen2:7b", "120h", history);
    //等待推理结束
    future.get();
}

依赖信息

就一个依赖:Gson(

ollamaapi4j's People

Contributors

zedocn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.