Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.5 #22

Merged
merged 34 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7e34af2
Merge pull request #21 from Gyarbij/main
Gyarbij Jul 20, 2024
1b94f50
Update .gitignore
Gyarbij Jul 20, 2024
636f1e3
- Added support for Azure AI Studio.
Gyarbij Jul 25, 2024
677cac0
chore: Update Dockerfile to handle missing .env file during build
Gyarbij Jul 25, 2024
f33da9e
chore: Update Dockerfile to handle missing .env file during build
Gyarbij Jul 25, 2024
2167f20
chore: Update Dockerfile to use golang 1.22.5 and handle missing .env…
Gyarbij Jul 25, 2024
5361d6b
chore: Update Dockerfile to handle missing .env file during build
Gyarbij Jul 25, 2024
f03d593
chore: Update Dockerfile to handle missing .env file during build
Gyarbij Jul 25, 2024
3b98ce4
chore: Initialize ServerlessDeploymentKeys map and handle serverless …
Gyarbij Jul 25, 2024
e4b6d56
chore: Refactor HandleToken function to handle serverless deployments…
Gyarbij Jul 25, 2024
4d8a5cd
chore: Add serverless deployments to the models list
Gyarbij Jul 25, 2024
fa089a8
Added a ServerlessDeploymentInfo map to store information about serve…
Gyarbij Jul 25, 2024
9233ce3
Removed the parsing of AZURE_AI_STUDIO_DEPLOYMENTS from main.go, now …
Gyarbij Jul 25, 2024
b42e8ce
chore: Update go.mod to include github.com/joho/godotenv v1.5.1
Gyarbij Jul 25, 2024
e3d29f4
remove unused import _info
Gyarbij Jul 25, 2024
4f5c828
chore: Refactor HandleToken function to handle serverless auth and im…
Gyarbij Jul 25, 2024
cb1279c
chore: Refactor HandleToken function to handle serverless deployments…
Gyarbij Jul 25, 2024
7dd79bd
handle serverless deployments url correctly
Gyarbij Jul 25, 2024
fbde5f4
introduce a "isServerless" boolean flag to track whether the current …
Gyarbij Jul 25, 2024
3d320b8
Introduce "isServerless" flag to track serverless deployments and han…
Gyarbij Jul 25, 2024
1aa7eae
remove cargo
Gyarbij Jul 25, 2024
3651c8f
azoa
Gyarbij Jul 25, 2024
0b2f729
Refactor proxyRequest function to handle response writing and error h…
Gyarbij Jul 25, 2024
93f4b9f
fix: azure proxy serverless api auth
Gyarbij Jul 25, 2024
98cff09
chore: Refactor HandleToken function to handle serverless deployments…
Gyarbij Jul 25, 2024
3e7adf1
fkry
Gyarbij Jul 25, 2024
b2b726e
Refactor proxyRequest function to handle response writing and error h…
Gyarbij Jul 25, 2024
cc51b44
fkery
Gyarbij Jul 25, 2024
8122f0a
fuck model mapper temp
Gyarbij Jul 25, 2024
cb00f3a
f
Gyarbij Jul 25, 2024
00b971d
FU
Gyarbij Jul 25, 2024
679a07e
feat: Add Azure OAI proxy service configuration, docker compose examp…
Gyarbij Jul 25, 2024
f183631
Updated README.md
Gyarbij Jul 25, 2024
0e798a1
chore: Remove commented out log statement in makeDirector function fo…
Gyarbij Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "cargo" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
21 changes: 21 additions & 0 deletions .github/workflows/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
azure-oai-proxy:
# env_file: .env
image: 'gyarbij/azure-oai-proxy:latest'
# container_name: azure-oai-proxy
# Alternatively, use GitHub Container Registry:
# image: 'ghcr.io/gyarbij/azure-oai-proxy:latest'
restart: always
environment:
- AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
# - AZURE_OPENAI_PROXY_ADDRESS=0.0.0.0:11437
# - AZURE_OPENAI_PROXY_MODE=azure
# - AZURE_OPENAI_APIVERSION=2024-06-01
# - AZURE_OPENAI_MODEL_MAPPER=gpt-3.5-turbo=gpt-35-turbo,gpt-4=gpt-4-turbo
# - AZURE_AI_STUDIO_DEPLOYMENTS=mistral-large-2407=Mistral-large2:swedencentral,llama-3.1-405B=Meta-Llama-3-1-405B-Instruct:northcentralus,llama-3.1-70B=Llama-31-70B:swedencentral
# - AZURE_OPENAI_KEY_MISTRAL-LARGE-2407=your-api-key-1
# - AZURE_OPENAI_KEY_LLAMA-3.1-8B=your-api-key-2
# - AZURE_OPENAI_KEY_LLAMA-3.1-70B=your-api-key-3
ports:
- '11437:11437'
# Uncomment the following line to use an .env file:
30 changes: 29 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,32 @@
# Dependency directories (remove the comment below to include it)
# vendor/

.idea
.idea

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM golang:1.22.5 AS builder
WORKDIR /build
COPY . .
RUN go get github.com/joho/godotenv
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o azure-oai-proxy .

FROM gcr.io/distroless/base-debian12
Expand Down
208 changes: 112 additions & 96 deletions README.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
AZURE_OPENAI_APIVERSION=2024-06-01
AZURE_OPENAI_ENDPOINT=https://your-azure-openai-resource.openai.azure.com/
AZURE_OPENAI_API_KEY=your-azure-openai-api-key
AZURE_OPENAI_MODEL_MAPPER=gpt-3.5-turbo=gpt-35-turbo,gpt-4=gpt-4-0613
AZURE_AI_STUDIO_DEPLOYMENTS=mistral-large=Mistral-large2:swedencentral,llama-3=Meta-Llama-31-405B-Instruct:northcentralus
AZURE_OPENAI_PROXY_ADDRESS=0.0.0.0:11437
AZURE_OPENAI_PROXY_MODE=azure
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22.4

require (
github.com/gin-gonic/gin v1.10.0
github.com/joho/godotenv v1.5.1
github.com/tidwall/gjson v1.17.1
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
Expand Down
33 changes: 33 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"log"
"net/http"
"os"
"strings"

"github.com/gin-gonic/gin"
"github.com/gyarbij/azure-oai-proxy/pkg/azure"
"github.com/gyarbij/azure-oai-proxy/pkg/openai"
"github.com/joho/godotenv"
)

var (
Expand Down Expand Up @@ -49,6 +51,11 @@ type Deprecation struct {
}

func init() {
// Load .env file if it exists
if err := godotenv.Load(); err != nil {
log.Println("No .env file found")
}

gin.SetMode(gin.ReleaseMode)
if v := os.Getenv("AZURE_OPENAI_PROXY_ADDRESS"); v != "" {
Address = v
Expand All @@ -58,6 +65,16 @@ func init() {
}
log.Printf("loading azure openai proxy address: %s", Address)
log.Printf("loading azure openai proxy mode: %s", ProxyMode)

// Load Azure OpenAI Model Mapper
if v := os.Getenv("AZURE_OPENAI_MODEL_MAPPER"); v != "" {
for _, pair := range strings.Split(v, ",") {
info := strings.Split(pair, "=")
if len(info) == 2 {
azure.AzureOpenAIModelMapper[info[0]] = info[1]
}
}
}
}

func main() {
Expand Down Expand Up @@ -109,6 +126,22 @@ func handleGetModels(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to fetch deployed models"})
return
}

// Add serverless deployments to the models list
for deploymentName := range azure.ServerlessDeploymentInfo {
models = append(models, Model{
ID: deploymentName,
Object: "model",
Capabilities: Capabilities{
Completion: true,
ChatCompletion: true,
Inference: true,
},
LifecycleStatus: "active",
Status: "ready",
})
}

result := ModelList{
Object: "list",
Data: models,
Expand Down
Loading