Skip to content

Commit

Permalink
fix openai option. (#469)
Browse files Browse the repository at this point in the history
Signed-off-by: my-vegetable-has-exploded <[email protected]>
  • Loading branch information
my-vegetable-has-exploded committed Apr 20, 2024
1 parent 06137e1 commit eaa3093
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gucs/embedding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use pgrx::{GucContext, GucFlags, GucRegistry, GucSetting};
use std::ffi::CStr;

pub fn openai_options() -> OpenAIOptions {
let base_url = guc_string_parse(&OPENAI_BASE_URL, "vectors.openai_base");
let base_url = guc_string_parse(&OPENAI_BASE_URL, "vectors.openai_base_url");
let api_key = guc_string_parse(&OPENAI_API_KEY, "vectors.openai_api_key");
OpenAIOptions { base_url, api_key }
}
Expand All @@ -13,7 +13,7 @@ static OPENAI_API_KEY: GucSetting<Option<&'static CStr>> =
GucSetting::<Option<&'static CStr>>::new(None);

static OPENAI_BASE_URL: GucSetting<Option<&'static CStr>> =
GucSetting::<Option<&'static CStr>>::new(Some(c"https://api.openai.com/v1/"));
GucSetting::<Option<&'static CStr>>::new(Some(c"https://api.openai.com/v1"));

pub unsafe fn init() {
GucRegistry::define_string_guc(
Expand Down
18 changes: 18 additions & 0 deletions tests/sqllogictest/openai_options.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
statement ok
SET search_path TO pg_temp, vectors;

statement ok
SET vectors.openai_base_url TO 'https://api.moonshot.cn/v1';

statement ok
SET vectors.openai_api_key TO 'fake_key';

query ?
SHOW vectors.openai_base_url;
----
https://api.moonshot.cn/v1

query ?
SHOW vectors.openai_api_key;
----
fake_key

0 comments on commit eaa3093

Please sign in to comment.