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

Refactor Model Providers to Use Shared Proxy Package + validation for OpenAI like providers #332

Merged
merged 31 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6d259c1
init refactor
sanjay920 Jan 10, 2025
f52d1e9
update openai proxy
sanjay920 Jan 10, 2025
3512a7e
update
sanjay920 Jan 10, 2025
5475b2c
remove old deepseek validate
sanjay920 Jan 10, 2025
02a3dfd
remove old openai server code
sanjay920 Jan 10, 2025
e5ace54
update deepseek go.mod
sanjay920 Jan 10, 2025
1cc140b
remove deepseek server.go
sanjay920 Jan 10, 2025
c327c30
update
sanjay920 Jan 10, 2025
d45d840
update deepseek
sanjay920 Jan 10, 2025
11b012e
rewrite groq model provider
sanjay920 Jan 10, 2025
3404988
refactor xai
sanjay920 Jan 10, 2025
1792a96
validate for openai model provider
sanjay920 Jan 10, 2025
c826378
refactor ollama
sanjay920 Jan 10, 2025
106271a
refactor vllm
sanjay920 Jan 10, 2025
eec948e
refactor: move URL cleaning to vLLM and Ollama providers
sanjay920 Jan 10, 2025
bd18b7e
use slog for logging
sanjay920 Jan 14, 2025
c9a1c30
use json.NewDecoder
sanjay920 Jan 15, 2025
a3598b2
update downstream model logging
sanjay920 Jan 15, 2025
5557ad2
small updates
sanjay920 Jan 17, 2025
ff532c9
Update openai-model-provider/proxy/validate.go
sanjay920 Jan 16, 2025
527758c
Update openai-model-provider/proxy/rewrite.go
sanjay920 Jan 17, 2025
a909798
Update openai-model-provider/proxy/proxy.go
sanjay920 Jan 17, 2025
cde620a
Update openai-model-provider/proxy/proxy.go
sanjay920 Jan 17, 2025
ba81c8f
update ollama go.mod
sanjay920 Jan 17, 2025
a81781a
update openai proxy
sanjay920 Jan 17, 2025
a87d2c3
refactor: consolidate model provider validation and move types to api…
sanjay920 Jan 17, 2025
321c10e
refactor: simplify model provider validation
sanjay920 Jan 17, 2025
a29fe21
update validate
sanjay920 Jan 17, 2025
f2c78f5
Run use replace and run go mod tidy
thedadams Jan 17, 2025
8cfb6bd
Use json decoder for validate
thedadams Jan 17, 2025
92c1400
fix ci
thedadams Jan 17, 2025
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
21 changes: 13 additions & 8 deletions .github/workflows/package-tools.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Build Docker Image
name: Package tools

on:
pull_request:
branches:
- main
paths-ignore:
- docs/**

jobs:
build:
Expand All @@ -15,9 +13,16 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: github.com/obot-platform/obot
repository: obot-platform/obot

- name: Make packages
run: make package-tools
env:
TOOL_REGISTRY_REPOS: github.com/${{ github.repository }}@${{ github.sha }}
- name: Setup Depot
uses: depot/setup-action@v1

- name: Build Docker Image
uses: depot/build-push-action@v1
with:
project: bbqjs4tj1g
context: .
platforms: linux/amd64
build-args: |
TOOL_REGISTRY_REPOS=github.com/${{ github.event.pull_request.head.repo.full_name }}@${{ github.event.pull_request.head.sha }}
4 changes: 3 additions & 1 deletion deepseek-model-provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ module github.com/obot-platform/tools/deepseek-model-provider

go 1.23.4

require github.com/gptscript-ai/chat-completion-client v0.0.0-20241127005108-02b41e1cd02e
replace github.com/obot-platform/tools/openai-model-provider => ../openai-model-provider

require github.com/obot-platform/tools/openai-model-provider v0.0.0
2 changes: 0 additions & 2 deletions deepseek-model-provider/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
github.com/gptscript-ai/chat-completion-client v0.0.0-20241127005108-02b41e1cd02e h1:Nj9709xPbjAPLOsdR/Ik4zaJfpU4O6AEP/R6o9h30CE=
github.com/gptscript-ai/chat-completion-client v0.0.0-20241127005108-02b41e1cd02e/go.mod h1:7P/o6/IWa1KqsntVf68hSnLKuu3+xuqm6lYhch1w4jo=
30 changes: 16 additions & 14 deletions deepseek-model-provider/main.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
package main

import (
"fmt"
"os"

"github.com/obot-platform/tools/deepseek-model-provider/server"
"github.com/obot-platform/tools/deepseek-model-provider/validate"
"github.com/obot-platform/tools/openai-model-provider/proxy"
)

func main() {
apiKey := os.Getenv("OBOT_DEEPSEEK_MODEL_PROVIDER_API_KEY")
if apiKey == "" {
validate.PrintError("OBOT_DEEPSEEK_MODEL_PROVIDER_API_KEY environment variable not set")
fmt.Fprintln(os.Stderr, "OBOT_DEEPSEEK_MODEL_PROVIDER_API_KEY environment variable not set")
os.Exit(1)
}

args := os.Args[1:]
if len(args) == 1 && args[0] == "validate" {
if err := validate.Run(apiKey); err != nil {
validate.PrintError(err.Error())
os.Exit(1)
}
os.Exit(0)
cfg := &proxy.Config{
APIKey: apiKey,
Port: os.Getenv("PORT"),
UpstreamHost: "api.deepseek.com",
UseTLS: true,
RewriteModelsFn: proxy.RewriteAllModelsWithUsage("llm"),
Name: "DeepSeek",
}

port := os.Getenv("PORT")
if port == "" {
port = "8000"
if len(os.Args) > 1 && os.Args[1] == "validate" {
if err := cfg.Validate("/tools/deepseek-model-provider/validate"); err != nil {
os.Exit(1)
}
return
}

if err := server.Run(apiKey, port); err != nil {
if err := proxy.Run(cfg); err != nil {
panic(err)
}
}
106 changes: 0 additions & 106 deletions deepseek-model-provider/server/server.go

This file was deleted.

105 changes: 0 additions & 105 deletions deepseek-model-provider/validate/validate.go

This file was deleted.

7 changes: 7 additions & 0 deletions groq-model-provider/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/obot-platform/tools/groq-model-provider

go 1.23.4

replace github.com/obot-platform/tools/openai-model-provider => ../openai-model-provider

require github.com/obot-platform/tools/openai-model-provider v0.0.0
Empty file added groq-model-provider/go.sum
Empty file.
37 changes: 37 additions & 0 deletions groq-model-provider/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"fmt"
"os"

"github.com/obot-platform/tools/openai-model-provider/proxy"
)

func main() {
apiKey := os.Getenv("OBOT_GROQ_MODEL_PROVIDER_API_KEY")
if apiKey == "" {
fmt.Fprintln(os.Stderr, "OBOT_GROQ_MODEL_PROVIDER_API_KEY environment variable not set")
os.Exit(1)
}

cfg := &proxy.Config{
APIKey: apiKey,
Port: os.Getenv("PORT"),
UpstreamHost: "api.groq.com",
UseTLS: true,
RewriteModelsFn: proxy.RewriteAllModelsWithUsage("llm"),
PathPrefix: "/openai",
Name: "Groq",
}

if len(os.Args) > 1 && os.Args[1] == "validate" {
if err := cfg.Validate("/tools/groq-model-provider/validate"); err != nil {
os.Exit(1)
}
return
}

if err := proxy.Run(cfg); err != nil {
panic(err)
}
}
Loading