Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions config.example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"openaiAPIKey": "sk-************************************************",
"openaiAPIEndpoint": "https://api.openai.com/v1",
"botToken": "8888888888:***********************************",
"conversationLimit": 16,
"databasePath": "/telegpt/data/telegpt.sqlite",
Expand Down
6 changes: 6 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ pub struct Config {
/// JSON key: `openaiAPIKey`
#[serde(rename = "openaiAPIKey")]
pub openai_api_key: String,

/// The API Endpoint to be used.
/// JSON key: `openaiAPIEndpoint`
#[serde(rename = "openaiAPIEndpoint")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to add a default value here, since most people probably won't change the endpoint.

pub openai_api_endpoint: String,

/// The token of your Telegram bot.
/// JSON key: `botToken`
#[serde(rename = "botToken")]
Expand Down
4 changes: 3 additions & 1 deletion src/modules/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ impl Module for OpenAI {
let config: Arc<SharedConfig> = dep_map.get();

let openai_client = OpenAIClient {
client: Client::new().with_api_key(&config.openai_api_key),
client: Client::new()
.with_api_key(&config.openai_api_key)
.with_api_base(&config.openai_api_endpoint),
config: config.as_ref().clone(),
};
dep_map.insert(openai_client);
Expand Down