Skip to content

Commit

Permalink
Merge pull request #445 from yongman/support-team-account
Browse files Browse the repository at this point in the history
Add header and cookie to support team account
  • Loading branch information
0x676e67 authored Jan 21, 2024
2 parents 13b950e + 7928b02 commit 2209119
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/openai/src/serve/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ pub(crate) fn header_convert(
origin: &'static str,
) -> Result<HeaderMap, ResponseError> {
let mut headers = HeaderMap::new();
let mut cookies = Vec::new();

// Support for team accounts.
// The chat will be sent to the team account if the header is present, otherwise
// it will be sent to the personal account.
h.get("Chatgpt-Account-Id").map(|h| {
headers.insert("Chatgpt-Account-Id", h.clone());
cookies.push(format!("{}={}", "_account", h.to_str().unwrap()));
});

h.get("Access-Control-Request-Headers")
.map(|h| headers.insert("Access-Control-Request-Headers", h.clone()));
Expand Down Expand Up @@ -76,8 +85,6 @@ pub(crate) fn header_convert(
headers.insert(header::ORIGIN, header::HeaderValue::from_static(origin));
headers.insert(header::REFERER, header::HeaderValue::from_static(origin));

let mut cookies = Vec::new();

jar.iter()
.filter(|c| {
let name = c.name().to_lowercase();
Expand Down

0 comments on commit 2209119

Please sign in to comment.