Skip to content
Merged
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
3 changes: 3 additions & 0 deletions docs/ask.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ business> /ask business "What do I do, I can't make money???? HELP!"
| Agent | Aliases | Model |
| ---------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `business` | `saas`, `strategist` | Profullstack's [saas-business-strategist-agent](https://huggingface.co/profullstack/saas-business-strategist-agent): Qwen2.5-0.5B-Instruct with a LoRA trained on the c0mpute network ([GGUF](https://huggingface.co/profullstack/saas-business-strategist-agent-GGUF)) |
| `legal` | `lawyer`, `law`, `not-a-lawyer` | Profullstack's [not-a-lawyer-agent](https://huggingface.co/profullstack/not-a-lawyer-agent): legal research, trained on the c0mpute network from rssamplifier law topics and pit.world ([GGUF](https://huggingface.co/profullstack/not-a-lawyer-agent-GGUF)). Not a lawyer, not legal advice |

An agent with a `disclaimer` prints it under every answer and returns it in `--json`, the API and MCP results.

The list lives at [w3bs.org/agents.json](/agents.json) and the CLI reads it on each run, so a new agent needs no new `w3bs`. A copy is built into the binary for when w3bs.org cannot be reached. Each agent is one object:

Expand Down
15 changes: 15 additions & 0 deletions fixtures/agents.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
"grounding": { "search": "pit.world", "query_suffix": "startup revenue", "results": 3 },
"max_tokens": 350,
"temperature": 0.2
},
{
"name": "legal",
"aliases": ["lawyer", "law", "not-a-lawyer"],
"title": "Legal research (not a lawyer)",
"by": "Profullstack",
"model": "hf.co/profullstack/not-a-lawyer-agent-GGUF:latest",
"base_model": "Qwen/Qwen2.5-0.5B-Instruct",
"huggingface": "https://huggingface.co/profullstack/not-a-lawyer-agent",
"gguf": "https://huggingface.co/profullstack/not-a-lawyer-agent-GGUF",
"system": "You are not-a-lawyer-agent, a legal research assistant. You are not a lawyer and this is not legal advice. Explain the law in plain English, name the jurisdiction a rule comes from, cite the sources you were given, and say when someone should talk to a licensed attorney.",
"disclaimer": "Not a lawyer. Not legal advice. Legal research from public sources; laws vary by jurisdiction, so check with a licensed attorney before acting.",
"grounding": { "search": "pit.world", "query_suffix": "law", "results": 3 },
"max_tokens": 350,
"temperature": 0.2
}
]
}
8 changes: 4 additions & 4 deletions package-manager/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "3"
members = ["crates/w3bs-schema", "crates/w3bs-core", "crates/w3bs-cli", "crates/w3bs-publish"]

[workspace.package]
version = "0.1.20"
version = "0.1.21"
edition = "2024"
license = "MIT OR Apache-2.0"
repository = "https://github.com/profullstack/w3bs.org"
Expand Down
35 changes: 31 additions & 4 deletions package-manager/crates/w3bs-cli/src/ask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub struct Agent {
pub huggingface: String,
pub gguf: String,
pub system: String,
/// Shown under every answer (legal and tax agents: "not a lawyer, not advice").
pub disclaimer: String,
pub search: bool,
pub query_suffix: String,
pub results: usize,
Expand All @@ -58,6 +60,7 @@ impl Agent {
by: st("by"),
huggingface: st("huggingface"),
gguf: st("gguf"),
disclaimer: st("disclaimer"),
search: g["search"].as_str().is_some_and(|s| !s.is_empty()),
query_suffix: g["query_suffix"].as_str().unwrap_or_default().trim().to_owned(),
results: g["results"].as_u64().unwrap_or(3).clamp(1, 8) as usize,
Expand All @@ -70,8 +73,12 @@ impl Agent {
}

pub fn summary(&self) -> Value {
json!({ "name": self.name, "aliases": self.aliases, "title": self.title, "by": self.by, "model": self.model,
"huggingface": self.huggingface, "gguf": self.gguf, "grounding": if self.search { "pit.world" } else { "none" } })
let mut v = json!({ "name": self.name, "aliases": self.aliases, "title": self.title, "by": self.by, "model": self.model,
"huggingface": self.huggingface, "gguf": self.gguf, "grounding": if self.search { "pit.world" } else { "none" } });
if !self.disclaimer.is_empty() {
v["disclaimer"] = json!(self.disclaimer);
}
v
}
}

Expand Down Expand Up @@ -443,7 +450,7 @@ pub async fn ask(req: Request<'_>, on_token: &mut dyn FnMut(&str), on_status: &m
final_text = text;
break;
}
Ok(json!({
let mut out = json!({
"agent": agent.name,
"title": agent.title,
"model": agent.model,
Expand All @@ -458,7 +465,11 @@ pub async fn ask(req: Request<'_>, on_token: &mut dyn FnMut(&str), on_status: &m
"latency_ms": started.elapsed().as_millis() as u64,
"first_token_ms": first_token.map(|t| t as u64),
"warnings": warnings,
}))
});
if !agent.disclaimer.is_empty() {
out["disclaimer"] = json!(agent.disclaimer);
}
Ok(out)
}

fn s(v: &Value) -> String {
Expand All @@ -474,6 +485,9 @@ pub fn print_footer(d: &Value) {
println!(" [{}] {}\n {}", x["n"], x["title"].as_str().unwrap_or_default(), x["url"].as_str().unwrap_or_default());
}
}
if let Some(note) = d["disclaimer"].as_str().filter(|n| !n.is_empty()) {
println!("\n{note}");
}
let secs = |k: &str| d[k].as_u64().map(|ms| format!("{:.1} s", ms as f64 / 1000.0));
let first = secs("first_token_ms").map(|t| format!(", first token {t}")).unwrap_or_default();
eprintln!(
Expand Down Expand Up @@ -646,6 +660,19 @@ mod tests {
assert_eq!(find(&a, alias).unwrap().name, "business", "{alias}");
}
assert!(find(&a, "nobody").is_none());
assert!(b.disclaimer.is_empty() && b.summary().get("disclaimer").is_none());
}

#[test]
fn builtin_registry_has_the_legal_agent_with_a_disclaimer() {
let a = agents();
for (alias, name, repo, note) in [("lawyer", "legal", "not-a-lawyer-agent", "Not a lawyer."), ("@Not-A-Lawyer", "legal", "not-a-lawyer-agent", "Not a lawyer.")] {
let ag = find(&a, alias).unwrap();
assert_eq!(ag.name, name);
assert_eq!(ag.model, format!("hf.co/profullstack/{repo}-GGUF:latest"));
assert!(ag.disclaimer.starts_with(note), "{}", ag.disclaimer);
assert_eq!(ag.summary()["disclaimer"], ag.disclaimer.as_str());
}
}

#[test]
Expand Down
3 changes: 3 additions & 0 deletions src/ask.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function agents(registry = REGISTRY) {
huggingface: a.huggingface ?? '',
gguf: a.gguf ?? '',
system: a.system,
disclaimer: a.disclaimer ?? '',
search: Boolean(a.grounding?.search),
querySuffix: a.grounding?.query_suffix ?? '',
results: Math.min(Math.max(Number(a.grounding?.results) || 3, 1), 8),
Expand All @@ -38,6 +39,7 @@ export const publicAgent = (a) => ({
model: a.model,
huggingface: a.huggingface,
gguf: a.gguf,
...(a.disclaimer ? { disclaimer: a.disclaimer } : {}),
grounding: a.search ? 'pit.world' : 'none',
});

Expand Down Expand Up @@ -275,6 +277,7 @@ export async function ask(
model: agent.model,
question: q,
answer,
...(agent.disclaimer ? { disclaimer: agent.disclaimer } : {}),
sources: sources.map((s, i) => ({ n: i + 1, title: s.title, url: s.url })),
node,
transport: 'infernet',
Expand Down
3 changes: 3 additions & 0 deletions test/ask.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ test('the registry, aliases, query, sources, prompt and SSE framing', () => {
assert.equal(b.model, 'hf.co/profullstack/saas-business-strategist-agent-GGUF:latest');
assert.equal(findAgent('@Strategist', list).name, 'business');
assert.equal(findAgent('nobody', list), null);
assert.equal(b.disclaimer, '');
assert.equal(findAgent('lawyer', list).model, 'hf.co/profullstack/not-a-lawyer-agent-GGUF:latest');
assert.match(findAgent('legal', list).disclaimer, /^Not a lawyer\. Not legal advice\./);
assert.equal(searchQuery("I can't make money???? HELP!", 'startup revenue'), "I can't make money? HELP! startup revenue");
const s = pickSources(
{
Expand Down
Loading