File tree Expand file tree Collapse file tree 5 files changed +70
-0
lines changed Expand file tree Collapse file tree 5 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ <h2>Home</h2>
33< ul >
44 < li > < a href ="/form "> Form</ a > </ li >
55 < li > < a href ="/ollama "> Ollama</ a > </ li >
6+ < li > < a href ="/ollama-tools "> Ollama Tools</ a > </ li >
67 < li > < a href ="/kanban "> Kanban</ a > </ li >
78 < li > < a href ="/canvas "> Canvas</ a > </ li >
89 < li > < a href ="/dynamic-layout "> Dynamic Layout</ a > </ li >
Original file line number Diff line number Diff line change 1+ : host {
2+ dis play: grid;
3+ width: 100%;
4+ height: 100%;
5+ overflow: hidden;
6+ }
Original file line number Diff line number Diff line change 1+ < h2 > Ollama Tool Calling</ h2 >
2+ < div class ="container "> </ div >
3+ < button data-action ="callFunction "> Call Function</ button >
Original file line number Diff line number Diff line change 1+ import { OllamaModule } from "./../../src/modules/ollama.js" ;
2+
3+ const tools = [
4+ {
5+ "type" : "function" ,
6+ "function" : {
7+ "name" : "example_function" ,
8+ "description" : "This is an example function" ,
9+ "parameters" : [
10+ {
11+ "type" : "object" ,
12+ "properties" : {
13+ "option" : {
14+ "type" : "string" ,
15+ "description" : "The value to return" ,
16+ "enum" : [ "option1" , "option2" ]
17+ }
18+ }
19+ }
20+ ] ,
21+ }
22+ }
23+ ]
24+
25+ export default class OllamaToolsView extends HTMLElement {
26+ static tag = "ollama-tools-view" ;
27+
28+ #onClickHandler = this . #onClick. bind ( this ) ;
29+
30+ constructor ( ) {
31+ super ( ) ;
32+ this . attachShadow ( { mode : "open" } ) ;
33+ }
34+
35+ async connectedCallback ( ) {
36+ this . shadowRoot . innerHTML = await api . call ( "component" , "load_html" , {
37+ url : import . meta. url ,
38+ } ) ;
39+
40+ this . addEventListener ( "click" , this . #onClickHandler) ;
41+ }
42+
43+ async disconnectedCallback ( ) {
44+ this . removeEventListener ( "click" , this . #onClickHandler) ;
45+ }
46+
47+ #onClick( event ) {
48+ const target = event . composedPath ( ) [ 0 ] ;
49+ if ( target . dataset . action != null ) {
50+ this [ target . dataset . action ] . call ( this , event ) ;
51+ }
52+ }
53+
54+ callFunction ( event ) {
55+ alert ( "click" )
56+ }
57+ }
58+
59+ customElements . define ( OllamaToolsView . tag , OllamaToolsView ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const GENERATE_OPTIONAL_ARGS = Object.freeze([
2121 "raw" ,
2222 "keep_alive" ,
2323] ) ;
24+
2425const CHAT_OPTIONAL_ARGS = Object . freeze ( [
2526 "tools" ,
2627 "role" ,
You can’t perform that action at this time.
0 commit comments