llm

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 10 Imported by: 0

README

AI大模型低代码工具

Sample
test.js
import {zhipu} from 'apigo.cc/ai/llm'
import console from 'apigo.cc/gojs/console'

function main(...args) {
    let r = zhipu.fastAsk((args.length>0?args[0]:'你好', r => {
        console.print(r)
    })
    console.println()
    return r
}
Configure
env.yml
llm:
  openai:
    default:
      apiKey: ...
    aurze:
      apiKey: ...
      endpoint: ...
  zhipu:
    default:
      apiKey: ...
encrypt apiKey

install sskey

go install github.com/ssgo/tool/sskey@latest
sskey -e 'your apiKey'

copy url base64 format encrypted apiKey into llm.yml or env.yml

llm低代码 集成到应用

Install
go get -u apigo.cc/gojs
go get -u apigo.cc/ai/llm
Usage
package main

import (
	_ "apigo.cc/ai/llm"
	_ "apigo.cc/ai/zhipu"
	"apigo.cc/gojs"
	_ "apigo.cc/gojs/console"
)

func main() {
    result, err := gojs.Run(`return llm.zhipu.fastAsk('你好', console.print)`, "")
    if err != nil {
        fmt.Println(err.Error())
    } else if result != nil {
        fmt.Println(result)
    }
}

调用 Go API

Install
go get -u apigo.cc/ai/llm
Usage
package main

import (
	"apigo.cc/ai/llm/llm"
	"fmt"
)

func main() {
	zhipu := llm.Get("zhipu")

	r, usage, err := zhipu.FastAsk(llm.Messages().User().Text("你是什么模型").Make(), func(text string) {
		fmt.Print(text)
	})

	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println()
		fmt.Println("result:", r)
		fmt.Println("usage:", usage)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeLLM

func MakeLLM(lm llm.LLM) map[string]any

func SetSSKey

func SetSSKey(key, iv []byte)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL