Skip to content

Commit

Permalink
added api_key and other possible models
Browse files Browse the repository at this point in the history
  • Loading branch information
Koeng101 committed Mar 4, 2024
1 parent 9b7a4aa commit 025b9fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions api/api/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ func chatHandler(w http.ResponseWriter, r *http.Request) {
}
defer conn.Close()

client := openai.NewClient(os.Getenv("OPENAI_API_KEY"))
apiKey := os.Getenv("API_KEY")
baseUrl := os.Getenv("BASE_URL")
model := os.Getenv("MODEL")
config := openai.DefaultConfig(apiKey)
if baseUrl != "" {
config.BaseURL = baseUrl
}
client := openai.NewClientWithConfig(config)
for {
messageType, p, err := conn.ReadMessage()
if err != nil {
Expand All @@ -77,7 +84,7 @@ func chatHandler(w http.ResponseWriter, r *http.Request) {
stream, err := client.CreateChatCompletionStream(
context.Background(),
openai.ChatCompletionRequest{
Model: openai.GPT3Dot5Turbo,
Model: model,
Messages: messages,
Stream: true,
},
Expand Down
2 changes: 1 addition & 1 deletion api/api/ai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestAiFastaParse(t *testing.T) {
apiKey := os.Getenv("OPENAI_API_KEY")
apiKey := os.Getenv("API_KEY")
if apiKey == "" {
return
}
Expand Down

0 comments on commit 025b9fc

Please sign in to comment.