ajaxdavis's picture
Publish Donto-Qwen3.8-27B V15 adapter, model card, checkpoints, evaluations, sources, and evidence
2b28792 verified
Raw History Blame Contribute Delete
1.88 kB
#!/usr/bin/env python3
"""Forced-tool example for a running Donto-Qwen vLLM endpoint."""
from typing import Union
from openai import OpenAI
from pydantic import BaseModel, ConfigDict, Field
class Fact(BaseModel):
model_config = ConfigDict(extra="forbid")
s: str
p: str
o: Union[str, int, float, bool]
c: float = Field(ge=0.0, le=1.0)
h: bool
class Submission(BaseModel):
model_config = ConfigDict(extra="forbid")
facts: list[Fact] = Field(max_length=64)
more_supported_facts: bool
TOOLS = [
{
"type": "function",
"function": {
"name": "submit_facts",
"description": "Submit validated Donto extraction facts.",
"parameters": Submission.model_json_schema(),
},
}
]
SOURCE = """Ari reported that the primary system failed, while the reserve
system remained available. The panel postponed deployment until an independent
check was complete. Vera said the postponement wasted money, but Ari argued that
it protected staff."""
PROMPT = f"""Extract every atomic proposition directly supported by SOURCE.
Preserve attribution, contrast, modality, and negation. Use stable ex:kebab-case
entities, concise camelCase predicates, h:false for direct facts, and no prose.
SOURCE:
{SOURCE}
"""
client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="unused")
response = client.chat.completions.create(
model="donto-qwen",
messages=[{"role": "user", "content": PROMPT}],
tools=TOOLS,
tool_choice={"type": "function", "function": {"name": "submit_facts"}},
temperature=0,
max_tokens=1024,
extra_body={"chat_template_kwargs": {"enable_thinking": False, "preserve_thinking": False}},
)
call = response.choices[0].message.tool_calls[0]
submission = Submission.model_validate_json(call.function.arguments)
print(submission.model_dump_json(indent=2))