-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for decoding response with brotli
- Loading branch information
Showing
8 changed files
with
96 additions
and
17 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
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 |
---|---|---|
@@ -1,17 +1,21 @@ | ||
package main | ||
package router | ||
|
||
import ( | ||
"github.com/gorilla/mux" | ||
|
||
"github.com/pluralsh/console/go/ai-proxy/api" | ||
"github.com/pluralsh/console/go/ai-proxy/api/ollama" | ||
"github.com/pluralsh/console/go/ai-proxy/proxy" | ||
) | ||
|
||
func register(provider api.Provider, host string, token string) { | ||
func register(router *mux.Router, provider api.Provider, host string, token string) { | ||
p, err := proxy.NewOllamaTranslationProxy(provider, host, token) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
router.Use() | ||
|
||
// Register all Ollama API routes that should be proxied. | ||
router.HandleFunc(ollama.EndpointChat, p.Proxy()) | ||
} |
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,18 @@ | ||
package router | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gorilla/mux" | ||
|
||
"github.com/pluralsh/console/go/ai-proxy/args" | ||
) | ||
|
||
func NewRouter() http.Handler { | ||
router := mux.NewRouter() | ||
|
||
// Registers all routes under /api group | ||
register(router, args.Provider(), args.ProviderHost(), args.ProviderToken()) | ||
|
||
return router | ||
} |
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,31 @@ | ||
package router_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestOpenAIProxy(t *testing.T) { | ||
//applicationHandler := router.NewRouter() | ||
// | ||
//ts := httptest.NewServer(applicationHandler) | ||
//defer ts.Close() | ||
// | ||
//res, err := http.Get(ts.URL) | ||
// | ||
//if err != nil { | ||
// t.Fatalf("%s", err) | ||
//} | ||
// | ||
//defer res.Body.Close() | ||
//greeting, err := ioutil.ReadAll(res.Body) | ||
// | ||
//if err != nil { | ||
// log.Fatalf("%s", err) | ||
//} | ||
// | ||
//want := []byte("Hello World!") | ||
// | ||
//if !bytes.Equal(want, greeting) { | ||
// t.Errorf("Expected greeting %s; got %s", want, greeting) | ||
//} | ||
} |