Skip to content

Commit 7cf4685

Browse files
author
Guantong
committed
Impl clone for OpenAI
1 parent 1269e5b commit 7cf4685

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openai.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
use serde::{Deserialize, Serialize};
12
use ureq::{Agent, AgentBuilder};
23

4+
#[derive(Debug, Serialize, Deserialize)]
35
pub struct Auth {
46
pub api_key: String,
57
pub organization: Option<String>,
68
}
9+
10+
impl Clone for Auth {
11+
fn clone(&self) -> Self {
12+
Self { api_key: self.api_key.clone(), organization: self.organization.clone() }
13+
}
14+
}
15+
716
#[allow(dead_code)]
817
impl Auth {
918
pub fn new(api_key: &str) -> Auth {
@@ -17,12 +26,19 @@ impl Auth {
1726
}
1827
}
1928

29+
#[derive(Debug)]
2030
pub struct OpenAI {
2131
pub auth: Auth,
2232
pub api_url: String,
2333
pub(crate) agent: Agent,
2434
}
2535

36+
impl Clone for OpenAI {
37+
fn clone(&self) -> Self {
38+
Self { auth: self.auth.clone(), api_url: self.api_url.clone(), agent: self.agent.clone() }
39+
}
40+
}
41+
2642
#[allow(dead_code)]
2743
impl OpenAI {
2844
pub fn new(auth: Auth, api_url: &str) -> OpenAI {

0 commit comments

Comments
 (0)