Skip to content

web search done right

control api_base with env variables for frontend

Mikkel Denkerf8480ada944c
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a3e52a89..86822921 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -34,4 +34,4 @@ The process is simple and fast. Upon your first pull request, you will be prompt
* (Optional) run `just configure --alice` to download the weights for Alice (the AI assistant that can search on the web).
* (Optional) Install cargo-watch by running `cargo install cargo-watch`. This makes frontend development easier.
-After the non optional steps you can now run `just cargo test` and should see all tests passing. If you have installced `cargo-watch`, you should be able to run `just dev` to start the search server and launch the frontend at `0.0.0.0:3000`. You can add the `--alice` flag to enable Alice.
+After the non optional steps you can now run `just cargo test` and should see all tests passing. If you have installced `cargo-watch`, you should be able to run `just dev` to start the search server and launch the frontend at `0.0.0.0:8000`.
diff --git a/core/src/collector.rs b/core/src/collector.rs
index dd5bfd23..e5e38d50 100644
--- a/core/src/collector.rs
+++ b/core/src/collector.rs
@@ -206,7 +206,7 @@ struct ScoredDoc<T: Doc> {
impl<T: Doc> PartialOrd for ScoredDoc<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- self.adjusted_score.partial_cmp(&other.adjusted_score)
+ Some(self.cmp(other))
}
}
@@ -218,7 +218,7 @@ impl<T: Doc> PartialEq for ScoredDoc<T> {
impl<T: Doc> Ord for ScoredDoc<T> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
- self.partial_cmp(other).unwrap_or(std::cmp::Ordering::Equal)
+ self.adjusted_score.total_cmp(&other.adjusted_score)
}
}
diff --git a/core/src/main.rs b/core/src/main.rs
index f1cb20cb..c57410e2 100644
--- a/core/src/main.rs
+++ b/core/src/main.rs
@@ -82,7 +82,7 @@ enum Commands {
/// Deploy the search server.
SearchServer { config_path: String },
- /// Deploy the API. The API is a web server that serves the search UI and interacts with
+ /// Deploy the json http api. The api interacts with
/// the search servers, webgraph servers etc. to provide the necesarry functionality.
Api { config_path: String },
diff --git a/frontend/search/index.ts b/frontend/search/index.ts
index 31d65630..45064770 100644
--- a/frontend/search/index.ts
+++ b/frontend/search/index.ts
@@ -17,7 +17,7 @@ type Produces<P extends keyof paths, M extends keyof paths[P]> =
}
: never;
-export const API_BASE = "http://localhost:3000";
+const API_BASE = Deno.env.get("STRACT_API_BASE") ?? "http://localhost:3000";
export const send = <
P extends keyof paths,