Compare commits

..

3 Commits

Author SHA1 Message Date
github-actions[bot]
fee604682b Update version to v1.4.189 and commit 2025-05-19 21:39:14 +00:00
Eugen Eisler
941ccabd92 Merge pull request #1473 from roumy/add_authent_ollama
add authentification for ollama instance
2025-05-19 23:37:45 +02:00
pr
1291b35b63 add authentification for ollama instance 2025-05-19 11:01:47 +02:00
3 changed files with 22 additions and 5 deletions

View File

@@ -1 +1 @@
"1.4.188"
"1.4.189"

View File

@@ -15,6 +15,8 @@ import (
"github.com/danielmiessler/fabric/plugins"
)
const defaultBaseUrl = "http://localhost:11434"
func NewClient() (ret *Client) {
vendorName := "Ollama"
ret = &Client{}
@@ -26,7 +28,10 @@ func NewClient() (ret *Client) {
}
ret.ApiUrl = ret.AddSetupQuestionCustom("API URL", true,
"Enter your Ollama URL (as a reminder, it is usually http://localhost:1234/v1')")
"Enter your Ollama URL (as a reminder, it is usually http://localhost:11434')")
ret.ApiUrl.Value = defaultBaseUrl
ret.ApiKey = ret.PluginBase.AddSetupQuestion("API key", false)
ret.ApiKey.Value = ""
return
}
@@ -34,18 +39,30 @@ func NewClient() (ret *Client) {
type Client struct {
*plugins.PluginBase
ApiUrl *plugins.SetupQuestion
ApiKey *plugins.SetupQuestion
apiUrl *url.URL
client *ollamaapi.Client
}
type transport_sec struct {
underlyingTransport http.RoundTripper
ApiKey *plugins.SetupQuestion
}
func (t *transport_sec) RoundTrip(req *http.Request) (*http.Response, error) {
if t.ApiKey.Value != "" {
req.Header.Add("Authorization", "Bearer "+t.ApiKey.Value)
}
return t.underlyingTransport.RoundTrip(req)
}
func (o *Client) configure() (err error) {
if o.apiUrl, err = url.Parse(o.ApiUrl.Value); err != nil {
fmt.Printf("cannot parse URL: %s: %v\n", o.ApiUrl.Value, err)
return
}
o.client = ollamaapi.NewClient(o.apiUrl, &http.Client{Timeout: 1200000 * time.Millisecond})
o.client = ollamaapi.NewClient(o.apiUrl, &http.Client{Timeout: 1200000 * time.Millisecond, Transport: &transport_sec{underlyingTransport: http.DefaultTransport, ApiKey: o.ApiKey}})
return
}

View File

@@ -1,3 +1,3 @@
package main
var version = "v1.4.188"
var version = "v1.4.189"