-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from mutablelogic/v1
Added streaming outputs to client
- Loading branch information
Showing
29 changed files
with
800 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
// Package imports | ||
"github.com/mutablelogic/go-client/pkg/client" | ||
"github.com/mutablelogic/go-client/pkg/ollama" | ||
) | ||
|
||
///////////////////////////////////////////////////////////////////// | ||
// REGISTER FUNCTIONS | ||
|
||
func OllamaFlags(flags *Flags) { | ||
flags.String("ollama-endpoint", "${OLLAMA_ENDPOINT}", "Ollama endpoint url") | ||
} | ||
|
||
func OllamaRegister(cmd []Client, opts []client.ClientOpt, flags *Flags) ([]Client, error) { | ||
ollama, err := ollama.New(flags.GetString("ollama-endpoint"), opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Register commands | ||
cmd = append(cmd, Client{ | ||
ns: "ollama", | ||
cmd: []Command{ | ||
{Name: "models", Description: "List local models", MinArgs: 2, MaxArgs: 2, Fn: ollamaListModels(ollama, flags)}, | ||
}, | ||
}) | ||
|
||
// Return success | ||
return cmd, nil | ||
} | ||
|
||
///////////////////////////////////////////////////////////////////// | ||
// API CALL FUNCTIONS | ||
|
||
func ollamaListModels(client *ollama.Client, flags *Flags) CommandFn { | ||
return func() error { | ||
if models, err := client.ListModels(); err != nil { | ||
return err | ||
} else { | ||
return flags.Write(models) | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,27 @@ | ||
/* | ||
client impleemts a generic REST API client which can be used for creating | ||
gateway-specific clients | ||
Implements a generic REST API client which can be used for creating | ||
gateway-specific clients. Basic usage: | ||
package main | ||
import ( | ||
client "github.com/mutablelogic/go-client/pkg/client" | ||
) | ||
func main() { | ||
// Create a new client | ||
c := client.New(client.OptEndpoint("https://api.example.com/api/v1")) | ||
// Send a GET request, populating a struct with the response | ||
var response struct { | ||
Message string `json:"message"` | ||
} | ||
if err := c.Do(nil, &response, OptPath("test")); err != nil { | ||
// Handle error | ||
} | ||
// Print the response | ||
fmt.Println(response.Message) | ||
} | ||
*/ | ||
package client |
Oops, something went wrong.