mirror of
https://shylinux.com/x/ollama-story
synced 2025-05-05 11:37:01 +08:00
Compare commits
No commits in common. "master" and "v0.0.2" have entirely different histories.
2
Makefile
2
Makefile
@ -5,7 +5,7 @@ flags = -ldflags "-w -s" -v
|
|||||||
|
|
||||||
all: def
|
all: def
|
||||||
@date +"%Y-%m-%d %H:%M:%S"
|
@date +"%Y-%m-%d %H:%M:%S"
|
||||||
go build ${flags} -o ${binarys} src/main.go src/option.go ${version} ${binpack} && ./${binarys} forever restart &>/dev/null
|
go build ${flags} -o ${binarys} src/main.go ${version} ${binpack} && ./${binarys} forever restart &>/dev/null
|
||||||
|
|
||||||
def:
|
def:
|
||||||
@[ -f ${version} ] || echo "package main">${version}
|
@[ -f ${version} ] || echo "package main">${version}
|
||||||
|
6
go.mod
6
go.mod
@ -3,9 +3,9 @@ module shylinux.com/x/ollama-story
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
shylinux.com/x/ice v1.5.73
|
shylinux.com/x/ice v1.5.59
|
||||||
shylinux.com/x/icebergs v1.9.75
|
shylinux.com/x/icebergs v1.9.61
|
||||||
shylinux.com/x/toolkits v1.0.19
|
shylinux.com/x/toolkits v1.0.16
|
||||||
)
|
)
|
||||||
|
|
||||||
require github.com/gomarkdown/markdown v0.0.0-20250207164621-7a1f277a159e // indirect
|
require github.com/gomarkdown/markdown v0.0.0-20250207164621-7a1f277a159e // indirect
|
||||||
|
13
go.sum
13
go.sum
@ -4,12 +4,13 @@ shylinux.com/x/go-git/v5 v5.6.7 h1:WD5QSco7m3QooPCgdvQ6/GyGIFPun8C+hex5N41LYlk=
|
|||||||
shylinux.com/x/go-git/v5 v5.6.7/go.mod h1:Qb0lA+uIrofZg8NQerhYcJHgGWixFqvS6p3aJ/L5Nlk=
|
shylinux.com/x/go-git/v5 v5.6.7/go.mod h1:Qb0lA+uIrofZg8NQerhYcJHgGWixFqvS6p3aJ/L5Nlk=
|
||||||
shylinux.com/x/go-qrcode v0.0.3 h1:RMo+Vidbgq3HatLBj7DDXcTbTLFUwzis5K7TqBkD38U=
|
shylinux.com/x/go-qrcode v0.0.3 h1:RMo+Vidbgq3HatLBj7DDXcTbTLFUwzis5K7TqBkD38U=
|
||||||
shylinux.com/x/go-qrcode v0.0.3/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
shylinux.com/x/go-qrcode v0.0.3/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||||
shylinux.com/x/ice v1.5.73 h1:wp+KeQ14hLOdxxSou/Y0zHi48Jm4nLx1rFOwGz8ix04=
|
shylinux.com/x/ice v1.5.59 h1:9TugxrDR5rlH+fMnm1L3sLtxoZXY5j0sR4SRLQyqcgg=
|
||||||
shylinux.com/x/ice v1.5.73/go.mod h1:uGI73gYkk+FiJt5qmy/aYhoKRJ4wobcJk3WrPGh8Waw=
|
shylinux.com/x/ice v1.5.59/go.mod h1:/jZUXZGsBpTdHy/c8JkpWtVPGg6uPHOghlUULzg4R7o=
|
||||||
shylinux.com/x/icebergs v1.9.75 h1:9zAm0ppwUWl0As/vqfQG/QR/vwXa5zmfdIGE/gmvErQ=
|
shylinux.com/x/icebergs v1.9.59/go.mod h1:d8sN77l5UZA+h8/swZ9OzqRCruoSYHWYjg5qKWnQI2s=
|
||||||
shylinux.com/x/icebergs v1.9.75/go.mod h1:3Bdp3tjzw+hUKJF+kR8pfsrbjAf72DVZmCaE8/MPFtk=
|
shylinux.com/x/icebergs v1.9.61 h1:BguYfB7lzhjtJMhNG2efzzCJplHfaO+gNC0wBzunduc=
|
||||||
|
shylinux.com/x/icebergs v1.9.61/go.mod h1:d8sN77l5UZA+h8/swZ9OzqRCruoSYHWYjg5qKWnQI2s=
|
||||||
shylinux.com/x/toolkits v0.7.10/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
shylinux.com/x/toolkits v0.7.10/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||||
shylinux.com/x/toolkits v1.0.19 h1:Nrx0xYRc5ph1WS66EZ1hJUCe+2FdSWQ4QP6tBlguikQ=
|
shylinux.com/x/toolkits v1.0.16 h1:7Oh454uAyBLfflIFEQooLNzml4pqXIReiaxEVA/YXaU=
|
||||||
shylinux.com/x/toolkits v1.0.19/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
shylinux.com/x/toolkits v1.0.16/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||||
shylinux.com/x/websocket v0.0.4 h1:AJpwblePoOpiE6C8NrvgNYpKTotXMLrDDX2chTvx44Q=
|
shylinux.com/x/websocket v0.0.4 h1:AJpwblePoOpiE6C8NrvgNYpKTotXMLrDDX2chTvx44Q=
|
||||||
shylinux.com/x/websocket v0.0.4/go.mod h1:3UGWkjTu3ie5NAZen7J+uLPBrO7DFeKloj6Jxo13Oiw=
|
shylinux.com/x/websocket v0.0.4/go.mod h1:3UGWkjTu3ie5NAZen7J+uLPBrO7DFeKloj6Jxo13Oiw=
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
$content { padding:10px 20px; }
|
$content { padding:10px 20px; }
|
||||||
$content>div.request { background-color:#94ec69; color:black; padding:10px; float:right; }
|
$content>div.message { padding:0px; overflow:auto; }
|
||||||
$content>div.response { clear:both; }
|
$content>div.message>div.request { background-color:#94ec69; color:black; padding:10px; float:right; clear:both; }
|
||||||
$content>div.response p { margin:5px 0; }
|
$content>div.message>div.request>span { float:right; }
|
||||||
$display { background-color:var(--plugin-bg-color); height:120px; }
|
$content>div.message>div.response { padding:0px; clear:both; }
|
||||||
$display textarea { margin:10px; width:calc(100% - 20px); }
|
$content>div.message>div.response p { margin:5px 0; }
|
||||||
|
$content>div.request { padding-top:10px; }
|
@ -10,17 +10,17 @@ import (
|
|||||||
|
|
||||||
type chat struct {
|
type chat struct {
|
||||||
client client
|
client client
|
||||||
request string `name:"request model* role* content* which*"`
|
|
||||||
list string `name:"list list" help:"大模型对话" icon:"src/main.png"`
|
list string `name:"list list" help:"大模型对话" icon:"src/main.png"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s chat) Request(m *ice.Message, arg ...string) {
|
func (s chat) Request(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(web.SPIDE, OLLAMA, web.SPIDE_STREAM, http.MethodPost, "/api/chat", web.SPIDE_DATA, kit.Format(kit.Dict(
|
m.Optionv(web.SPIDE_STREAM, func(text string) { web.PushNoticeGrow(m.Message, m.Option("which"), text) })
|
||||||
m.OptionSimple("model"), "stream", true, "messages", kit.List(kit.Dict(m.OptionSimple("role", "content"))),
|
m.Cmdy(web.SPIDE, ice.DEV, web.SPIDE_STREAM, http.MethodPost, "http://localhost:11434/api/chat", web.SPIDE_DATA, kit.Format(kit.Dict(
|
||||||
|
"model", m.Option("model"), "stream", true, "messages", kit.List(kit.Dict("role", "user", "content", arg[0])),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
func (s chat) List(m *ice.Message, arg ...string) {
|
func (s chat) List(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(s.client).Display("").DisplayCSS("")
|
m.Cmdy(s.client).Display("").DisplayCSS("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.ChatModCmd(chat{}) }
|
func init() { ice.Cmd("web.chat.ollama.chat", chat{}) }
|
||||||
|
@ -1,25 +1,29 @@
|
|||||||
Volcanos(chat.ONIMPORT, {
|
Volcanos(chat.ONIMPORT, {
|
||||||
_init: function(can, msg) { can.require(["https://unpkg.com/showdown/dist/showdown.min.js"])
|
_init: function(can, msg) {
|
||||||
can.ui = can.onappend.layout(can), can.ui.responseList = [], can.onmotion.toggle(can, can.ui.display, true)
|
can.require(["https://unpkg.com/showdown/dist/showdown.min.js"])
|
||||||
|
can.ui = can.onappend.layout(can), can.ui.responseList = []
|
||||||
msg.Table(function(value) { can.onimport.item(can, {
|
msg.Table(function(value) { can.onimport.item(can, {
|
||||||
name: value.NAME, nick: value.NAME+" ("+value.SIZE+")",
|
name: value.NAME, nick: value.NAME+" ("+value.SIZE+")",
|
||||||
}, function(event, item, show, target) {
|
}, function(event, item, show, target) {
|
||||||
can.onimport.tabsCache(can, item, target, function() { can.onimport.content(can, target) })
|
can.onimport.tabsCache(can, item, target, function() { can.onimport.content(can, target) })
|
||||||
|
can.db.model = item.name, can.ui.message = target.ui.message, can.ui.request = target.ui.request
|
||||||
can.onappend._status(can, msg), can.onimport.layout(can)
|
can.onappend._status(can, msg), can.onimport.layout(can)
|
||||||
}) })
|
}) })
|
||||||
},
|
},
|
||||||
content: function(can, target) {
|
content: function(can, target) {
|
||||||
can.page.Append(can, can.ui.content, [
|
target.ui = can.page.Append(can, can.ui.content, [
|
||||||
{view: chat.RESPONSE, list: [
|
{view: "message", list: [
|
||||||
|
{view: "response", list: [
|
||||||
{text: can.user.trans(can, "Please Ask Anything!", "有什么问题尽管问吧!")},
|
{text: can.user.trans(can, "Please Ask Anything!", "有什么问题尽管问吧!")},
|
||||||
]},
|
]},
|
||||||
])
|
]},
|
||||||
can.page.Append(can, can.ui.display, [
|
{view: "request", list: [
|
||||||
{type: html.TEXTAREA, placeholder: can.user.trans(can, "Please Input Your Question!", "请输入的您的问题!"), onkeydown: function(event) {
|
{type: html.TEXTAREA, onkeydown: function(event) {
|
||||||
if (event.key == code.ENTER) {
|
if (event.key == code.ENTER) {
|
||||||
can.onaction.request(event, can, event.target.value), event.target.value = "", can.onkeymap.prevent(event)
|
can.onaction.request(event, can, event.target.value), event.target.value = "", can.onkeymap.prevent(event)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
]},
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
_grow: function(can, msg, which, text) {
|
_grow: function(can, msg, which, text) {
|
||||||
@ -28,13 +32,18 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
var converter = new showdown.Converter(); target.innerHTML = converter.makeHtml(target._text)
|
var converter = new showdown.Converter(); target.innerHTML = converter.makeHtml(target._text)
|
||||||
} else {
|
} else {
|
||||||
can.page.Append(can, target, [{text: data.message.content}])
|
can.page.Append(can, target, [{text: data.message.content}])
|
||||||
} can.ui.content.scrollBy(0, 1000)
|
} can.ui.message.scrollBy(0, 1000)
|
||||||
},
|
},
|
||||||
|
layout: function(can) {
|
||||||
|
can.ui.layout(can.ConfHeight(), can.ConfWidth(), 0, function() {
|
||||||
|
can.ui.request && can.page.style(can, can.ui.message, html.MAX_HEIGHT, can.ConfHeight()-can.ui.request.offsetHeight-20)
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Volcanos(chat.ONACTION, {
|
Volcanos(chat.ONACTION, {
|
||||||
request: function(event, can, text) { can.page.Append(can, can.ui.content, [{view: chat.REQUEST, list: [{text: text}]}])
|
request: function(event, can, text) { can.page.Append(can, can.ui.message, [{view: "request", list: [{text: text}]}])
|
||||||
var response = can.page.Append(can, can.ui.content, [{view: chat.RESPONSE}])._target; can.ui.responseList.push(response)
|
var response = can.page.Append(can, can.ui.message, [{view: "response"}])._target; can.ui.responseList.push(response)
|
||||||
can.request(event, {model: can.db.value.name, role: "user", content: text, which: ""+can.ui.responseList.length})
|
can.request(event, {which: ""+can.ui.responseList.length, model: can.db.model})
|
||||||
can.runAction(event, chat.REQUEST, [], function(msg) {})
|
can.runAction(event, "request", [text], function(msg) {})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -3,22 +3,12 @@ package client
|
|||||||
import (
|
import (
|
||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
|
||||||
"shylinux.com/x/icebergs/base/web"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
OLLAMA = "ollama"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type client struct {
|
type client struct {
|
||||||
list string `name:"list NAME auto" help:"大模型"`
|
list string `name:"list NAME auto" help:"大模型"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s client) Init(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmd(web.SPIDE, mdb.CREATE, "http://localhost:11434/api/chat", OLLAMA, nfs.SRC_MAIN_PNG)
|
|
||||||
}
|
|
||||||
func (s client) List(m *ice.Message, arg ...string) {
|
func (s client) List(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.SplitIndex(s.cmdx(m, ice.LIST))
|
m.SplitIndex(s.cmdx(m, ice.LIST))
|
||||||
@ -27,8 +17,8 @@ func (s client) List(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.ChatModCmd(client{}) }
|
func init() { ice.Cmd("web.chat.ollama.client", client{}) }
|
||||||
|
|
||||||
func (s client) cmdx(m *ice.Message, arg ...string) string {
|
func (s client) cmdx(m *ice.Message, arg ...string) string {
|
||||||
return m.Cmdx(cli.SYSTEM, OLLAMA, arg)
|
return m.Cmdx(cli.SYSTEM, "ollama", arg)
|
||||||
}
|
}
|
||||||
|
46
src/main.shy
46
src/main.shy
@ -5,56 +5,22 @@ refer `
|
|||||||
模型 https://ollama.com/library/deepseek-r1
|
模型 https://ollama.com/library/deepseek-r1
|
||||||
应用 https://feizhuke.com/
|
应用 https://feizhuke.com/
|
||||||
`
|
`
|
||||||
|
chapter "DeepSeek"
|
||||||
chapter "应用"
|
|
||||||
refer `
|
refer `
|
||||||
源码 https://github.com/shylinux/ollama-story
|
官网 https://www.deepseek.com/
|
||||||
帖子 https://bbs.shylinux.com/forum.php?mod=viewthread&tid=6&extra=page%3D1
|
简介 https://blog.csdn.net/qq_40999403/article/details/139320266
|
||||||
showdown https://igithub.com/showdownjs/showdown
|
帖子 https://bbs.shylinux.com/forum.php?mod=viewthread&tid=6&page=1&extra=#pid23
|
||||||
nodejs https://nodejs.org/en
|
|
||||||
`
|
`
|
||||||
field web.chat.ollama.chat
|
|
||||||
|
|
||||||
chapter "常用模型"
|
chapter "常用模型"
|
||||||
refer `
|
refer `
|
||||||
硅基流动 https://siliconflow.cn/
|
|
||||||
深度求索 https://www.deepseek.com/
|
|
||||||
字节豆包 https://www.doubao.com/
|
字节豆包 https://www.doubao.com/
|
||||||
腾讯元宝 https://yuanbao.tencent.com/
|
腾讯元宝 https://yuanbao.tencent.com/
|
||||||
通义千问 https://tongyi.aliyun.com/
|
通义千问 https://tongyi.aliyun.com/
|
||||||
文心一言 https://yiyan.baidu.com/
|
文心一言 https://yiyan.baidu.com/
|
||||||
月之暗面 https://kimi.moonshot.cn/
|
月之暗面 https://kimi.moonshot.cn/
|
||||||
`
|
`
|
||||||
|
chapter "外部依赖"
|
||||||
chapter "常用工具"
|
|
||||||
section "AnythingLLM"
|
|
||||||
refer `
|
refer `
|
||||||
官网 https://anythingllm.com/
|
https://github.com/showdownjs/showdown
|
||||||
文档 https://docs.anythingllm.com/
|
|
||||||
源码 https://github.com/Mintplex-Labs/anything-llm
|
|
||||||
`
|
|
||||||
section "Cherry Studio"
|
|
||||||
refer `
|
|
||||||
官网 https://cherry-ai.com/
|
|
||||||
文档 https://docs.cherry-ai.com/
|
|
||||||
源码 https://github.com/CherryHQ/cherry-studio
|
|
||||||
`
|
|
||||||
section "OBS Studio"
|
|
||||||
refer `
|
|
||||||
官网 https://obsproject.com/
|
|
||||||
文档 https://obsproject.com/kb/quick-start-guide
|
|
||||||
源码 https://github.com/obsproject/obs-studio
|
|
||||||
`
|
|
||||||
section "community"
|
|
||||||
refer `
|
|
||||||
https://x.com/
|
|
||||||
https://discord.com/
|
|
||||||
https://telegram.org/
|
|
||||||
https://www.facebook.com/
|
|
||||||
https://www.youtube.com/
|
|
||||||
https://mail.google.com/
|
|
||||||
https://www.bilibili.com/
|
|
||||||
https://www.xiaohongshu.com/
|
|
||||||
https://www.douyin.com/
|
|
||||||
https://weibo.com/
|
|
||||||
`
|
`
|
@ -11,4 +11,4 @@ func (s server) List(m *ice.Message, arg ...string) {
|
|||||||
s.Hash.List(m, arg...)
|
s.Hash.List(m, arg...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.ChatModCmd(server{}) }
|
func init() { ice.Cmd("web.chat.ollama.server", server{}) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user