Skip to content

Commit ec8d50e

Browse files
Removing server setting for api key (use headers) (#4)
1 parent 482a77d commit ec8d50e

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ struct Args {
3434
#[derive(Subcommand, Debug)]
3535
enum Commands {
3636
Serve {
37-
#[arg(short, long)]
38-
key: Option<String>,
3937
#[arg(short, long)]
4038
content_endpoint: Option<String>,
4139
#[arg(short, long)]
@@ -117,7 +115,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
117115
let args = Args::parse();
118116
match args.command {
119117
Commands::Serve {
120-
key,
121118
content_endpoint,
122119
directory,
123120
port,
@@ -127,7 +124,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
127124
directory,
128125
port,
129126
size,
130-
key_or_env(key),
131127
content_endpoint_or_env(content_endpoint),
132128
)
133129
.await?

src/server.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ pub struct QueryResult {
256256

257257
pub struct Service {
258258
content_endpoint: Option<String>,
259-
api_key: String,
260259
path: PathBuf,
261260
vector_store: VectorStore,
262261
pending: Mutex<HashSet<String>>,
@@ -370,16 +369,10 @@ impl Service {
370369
s
371370
}
372371

373-
fn new<P: Into<PathBuf>>(
374-
path: P,
375-
num_bufs: usize,
376-
key: String,
377-
content_endpoint: Option<String>,
378-
) -> Self {
372+
fn new<P: Into<PathBuf>>(path: P, num_bufs: usize, content_endpoint: Option<String>) -> Self {
379373
let path = path.into();
380374
Service {
381375
content_endpoint,
382-
api_key: key,
383376
path: path.clone(),
384377
vector_store: VectorStore::new(path, num_bufs),
385378
pending: Mutex::new(HashSet::new()),
@@ -691,7 +684,7 @@ impl Service {
691684
count: usize,
692685
) -> Result<Response<Body>, ResponseError> {
693686
let api_key = api_key?;
694-
let vec = Box::new((embeddings_for(&self.api_key, &[q]).await.unwrap())[0]);
687+
let vec = Box::new((embeddings_for(&api_key, &[q]).await.unwrap())[0]);
695688
let qp = Point::Mem { vec };
696689
let index_id = create_index_name(&domain, &commit);
697690
// if None, then return 404
@@ -735,11 +728,10 @@ pub async fn serve<P: Into<PathBuf>>(
735728
directory: P,
736729
port: u16,
737730
num_bufs: usize,
738-
key: String,
739731
content_endpoint: Option<String>,
740732
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
741733
let addr = SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), port);
742-
let service = Arc::new(Service::new(directory, num_bufs, key, content_endpoint));
734+
let service = Arc::new(Service::new(directory, num_bufs, content_endpoint));
743735
let make_svc = make_service_fn(move |_conn| {
744736
let s = service.clone();
745737
async {

0 commit comments

Comments
 (0)