File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ go get github.com/wangle201210/text2sql
1919
2020### 基本用法
2121
22+ export OPENAI_API_KEY="sk-****** "
23+ export OPENAI_MODEL_NAME="gpt-4o-mini"
24+ export OPENAI_BASE_URL="https://api.openai.com/v1 "
25+
2226``` go
2327package main
2428
Original file line number Diff line number Diff line change @@ -10,6 +10,14 @@ import (
1010)
1111
1212func createOpenAIChatModel (ctx context.Context ) model.ChatModel {
13+ m := os .Getenv ("OPENAI_MODEL_NAME" )
14+ if m == "" {
15+ log .Fatalf ("请在环境变量中设置你的 OPENAI_MODEL_NAME" )
16+ }
17+ apikey := os .Getenv ("OPENAI_API_KEY" )
18+ if apikey == "" {
19+ log .Fatalf ("请在环境变量中设置你的 OPENAI_API_KEY" )
20+ }
1321 chatModel , err := openai .NewChatModel (ctx , & openai.ChatModelConfig {
1422 Model : os .Getenv ("OPENAI_MODEL_NAME" ),
1523 APIKey : os .Getenv ("OPENAI_API_KEY" ),
You can’t perform that action at this time.
0 commit comments