Giter Site home page Giter Site logo

ollama-api's Introduction

ollama-api

介绍

接入ollama的api工具

例子

o := NewOllamaApi(Config{
		Url:   "http://localhost:11434",
		Model: "qwen:32b",
	})

prompt := "你好你是谁"

data, err := o.Generate(prompt)

if err != nil {
    t.Fatal(err)
}

fmt.Println(jsonutil.StructToJsonString(data))

//{"model":"qwen:32b","created_at":"2024-04-23T13:10:36.132216626Z","response":"我是通义千问,由阿里云开发的AI助手。我可以回答各种问题、提供信息和与用户进行对话。有什么我可以帮助你的吗?","done":true,"total_duration":3141457095,"load_duration":716703,"prompt_eval_duration":99576000,"eval_count":34,"eval_duration":3039901000}

SSE方式请求

o := NewOllamaApi(Config{
Url:   "http://localhost:11434",
Model: "qwen:32b",
})

prompt := "你好你是谁"
err := o.GenerateSSE(prompt, func (data types.OllamaGenerateResp) {
fmt.Println(data.Response)
})
if err != nil {
t.Fatal(err)
}

ollama-api's People

Contributors

fzkun 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.