diff --git a/README.md b/README.md index 68e5a87..5e7f840 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,23 @@ -# ContextOS -ContextOS 通过集群化、模块化、自动化的方式,只用一个 20M 大小的程序文件,就可以在各种设备上,一键启动完整的云计算服务与云研发环境。 +# ollama-story +基于 ContextOS 开发的 ollama 部署工具与应用界面。 -## 源码安装 -### 克隆编译 +## 安装 ContextOS +首先安装 ContextOS https://shylinux.com + +## 安装 ollama-story +打开 ContextOS 的应用商店,下载 20250208-ollama-story。 ```sh -git clone https://shylinux.com/x/ContextOS -cd ContextOS; source etc/miss.sh +open http://localhost:9020/c/store?debug=true#2025-ContextOS ``` -### 启动服务 +## 使用 ollama-story +打开 web.chat.ollama.chat 的应用。 ```sh -ish_miss_serve +open http://localhost:9020/s/20250208-ollama-story/c/web.chat.ollama.chat?debug=true ``` -### 访问网页 +## 查看 ollama-story +打开 web.chat.ollama.chat 的源码。 ```sh -open http://localhost:9020 -``` \ No newline at end of file +open http://localhost:9020/s/20250208-ollama-story/c/vimer?path=src/&file=client/chat.go&line=1&debug=true#src/:client/chat.go:24 +``` diff --git a/go.mod b/go.mod index 77bc5ab..2748cf0 100644 --- a/go.mod +++ b/go.mod @@ -7,3 +7,5 @@ require ( shylinux.com/x/icebergs v1.9.61 shylinux.com/x/toolkits v1.0.16 ) + +require github.com/gomarkdown/markdown v0.0.0-20250207164621-7a1f277a159e // indirect diff --git a/go.sum b/go.sum index cabdfa4..2deb181 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/gomarkdown/markdown v0.0.0-20250207164621-7a1f277a159e h1:ESHlT0RVZphh4JGBz49I5R6nTdC8Qyc08vU25GQHzzQ= +github.com/gomarkdown/markdown v0.0.0-20250207164621-7a1f277a159e/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA= 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-qrcode v0.0.3 h1:RMo+Vidbgq3HatLBj7DDXcTbTLFUwzis5K7TqBkD38U= diff --git a/src/client/chat.go b/src/client/chat.go index 1829909..2a53b75 100644 --- a/src/client/chat.go +++ b/src/client/chat.go @@ -9,19 +9,20 @@ import ( ) type chat struct { - list string `name:"list name auto" help:"大模型对话"` + client client + list string `name:"list list" help:"大模型对话"` } func (s chat) Request(m *ice.Message, arg ...string) { - m.Optionv(web.SPIDE_STREAM, func(text string) { web.PushNoticeGrow(m.Message, text) }) + m.Optionv(web.SPIDE_STREAM, func(text string) { web.PushNoticeGrow(m.Message, m.Option("which"), text) }) m.Cmdy(web.SPIDE, ice.DEV, web.SPIDE_STREAM, http.MethodPost, "http://localhost:11434/api/chat", - web.SPIDE_DATA, kit.Format(kit.Dict("model", "deepseek-r1", "stream", true, + 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) { - m.Display("").DisplayCSS("") + m.Cmdy(s.client).Display("").DisplayCSS("") } -func init() { ice.CodeModCmd(chat{}) } +func init() { ice.Cmd("web.chat.ollama.chat", chat{}) } diff --git a/src/client/chat.js b/src/client/chat.js index 8a1464e..f86c340 100644 --- a/src/client/chat.js +++ b/src/client/chat.js @@ -1,18 +1,19 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { + can.db.model = msg.Append("NAME") can.ui = can.page.Append(can, can._output, [ - {view: "message"}, - {view: "request", list: [ - {type: "textarea", onkeydown: function(event) { - if (event.key == "Enter") { + {view: chat.MESSAGE}, + {view: chat.REQUEST, list: [ + {type: html.TEXTAREA, onkeydown: function(event) { + if (event.key == code.ENTER) { can.onaction.request(event, can, event.target.value), event.target.value = "", can.onkeymap.prevent(event) } }}, ]}, ]) - can.ui.response = can.page.Append(can, can.ui.message, [{view: "response", list: [{text: "有什么问题尽管问吧!"}]}])._target + can.ui.response = can.page.Append(can, can.ui.message, [{view: chat.RESPONSE, list: [{text: "有什么问题尽管问吧!"}]}])._target }, - _grow: function(can, msg, text) { var data = JSON.parse(text) + _grow: function(can, msg, which, text) { var data = JSON.parse(text) can.page.Append(can, can.ui.response, [{text: data.message.content}]), can.ui.message.scrollBy(0, 1000) }, layout: function(can) { @@ -21,8 +22,9 @@ Volcanos(chat.ONIMPORT, { }) Volcanos(chat.ONACTION, { request: function(event, can, text) { - can.page.Append(can, can.ui.message, [{view: "request", list: [{text: text}]}]) - can.ui.response = can.page.Append(can, can.ui.message, [{view: "response"}])._target - can.runAction(event, "request", [text], function(msg) {}) + can.page.Append(can, can.ui.message, [{view: chat.REQUEST, list: [{text: text}]}]) + can.ui.response = can.page.Append(can, can.ui.message, [{view: chat.RESPONSE}])._target + can.request(event, {which: "respone", model: can.db.model}) + can.runAction(event, chat.REQUEST, [text], function(msg) {}) }, }) \ No newline at end of file diff --git a/src/client/client.go b/src/client/client.go index 58bc7b2..e149f5e 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -11,13 +11,14 @@ type client struct { func (s client) List(m *ice.Message, arg ...string) { if len(arg) == 0 { - m.SplitIndex(s.cmdx(m, "list")) - } else if len(arg) == 1 { - m.Echo(s.cmdx(m, "show", arg[0])) + m.SplitIndex(s.cmdx(m, ice.LIST)) + } else { + m.Echo(s.cmdx(m, ice.SHOW, arg[0])) } } -func (s client) cmdx(m *ice.Message, arg ...string) string { - return m.Cmdx(cli.SYSTEM, "ollama", arg) -} func init() { ice.Cmd("web.chat.ollama.client", client{}) } + +func (s client) cmdx(m *ice.Message, arg ...string) string { + return m.Cmdx(cli.SYSTEM, "ollama", arg) +} diff --git a/src/main.go b/src/main.go index 414747c..3c99ab9 100644 --- a/src/main.go +++ b/src/main.go @@ -1,7 +1,10 @@ package main -import "shylinux.com/x/ice" -import _ "shylinux.com/x/ollama-story/src/server" -import _ "shylinux.com/x/ollama-story/src/client" +import ( + "shylinux.com/x/ice" + _ "shylinux.com/x/icebergs/misc/md" + _ "shylinux.com/x/ollama-story/src/client" + _ "shylinux.com/x/ollama-story/src/server" +) func main() { print(ice.Run()) } diff --git a/src/main.png b/src/main.png new file mode 100644 index 0000000..8cd2cf1 Binary files /dev/null and b/src/main.png differ diff --git a/src/main.shy b/src/main.shy index ce54b52..354d6f6 100644 --- a/src/main.shy +++ b/src/main.shy @@ -1,53 +1,12 @@ -title "ContextOS" - -chapter "实践" -label ` -code wiki chat team mall -linux nginx docker redis mysql -bash git golang vim tmux +title "ollama-story" +refer ` +官网 https://ollama.com/ +源码 https://github.com/ollama/ollama +模型 https://ollama.com/library/deepseek-r1 ` - -chapter "理论" -label `集群化 模块化 自动化` - -chapter "项目" -label ` -matrix release program -intshell icebergs volcanos -contexts toolkits learning -` - -section "火山架" -field "趋势图" web.code.git.trends args `volcanos` -field "架构图" web.code.git.spides args `volcanos` - -section "冰山架" -field "趋势图" web.code.git.trends args `icebergs` -field "架构图" web.code.git.spides args `icebergs` -label ` -ctx mdb web aaa -lex yac ssh gdb -tcp nfs cli log -` -chain ` -web - code - wiki - chart - chat - macos - oauth - location - team - mall -` -label ` -websocket webview qrcode xterm ssh git -vim bash tmux alpha input lex yac -node java coder github chrome -wx lark wework -` compact true - -section "神农架" -field "趋势图" web.code.git.trends args `intshell` -field "架构图" web.code.git.spides args `intshell` \ No newline at end of file +chapter "DeepSeek" +refer ` +官网 https://www.deepseek.com/ +简介 https://blog.csdn.net/qq_40999403/article/details/139320266 +帖子 https://bbs.shylinux.com/forum.php?mod=viewthread&tid=6&page=1&extra=#pid23 +` \ No newline at end of file diff --git a/src/server/server.go b/src/server/server.go index 5563ca0..31fdfc2 100644 --- a/src/server/server.go +++ b/src/server/server.go @@ -4,8 +4,7 @@ import "shylinux.com/x/ice" type server struct { ice.Hash - - list string `name:"list hash auto" help:"server"` + list string `name:"list hash auto" help:"大模型"` } func (s server) List(m *ice.Message, arg ...string) { diff --git a/src/server/server.shy b/src/server/server.shy deleted file mode 100644 index 17d8091..0000000 --- a/src/server/server.shy +++ /dev/null @@ -1,6 +0,0 @@ -title "ollama" -refer ` -官网 https://ollama.com/ -源码 https://github.com/ollama/ollama -简介 https://blog.csdn.net/qq_40999403/article/details/139320266 -` \ No newline at end of file