Skip to main content

Additional Features

For the Qwen3 model, additional features are available that extend LLM functionality and provide more usage options. Usage examples may differ slightly from official OpenAI documentation and are provided below.

Tools

Getting a response from LLM in the form of a predefined data schema.

Пример для ChatOpenAI

from langchain_openai import ChatOpenAI
from pydantic import BaseModel

class User(BaseModel):
name: str
age: int

message = "Hello, I'm John and I'm 25 years old"
url = "http://localhost:5000/v1/"

client = ChatOpenAI(
model="Compressa-LLM",
api_key="TOKEN_1",
base_url=url,
)
struct_model = client.with_structured_output(User, method="function_calling")

response = struct_model.invoke([
{"role": "system", "content": "/think" },
{"role": "user", "content": message },
], tool_choice="auto", extra_body={"chat_template_kwargs": {"thinking": False}})
print(response.name, response.age)

Пример для ChatQwen

client = ChatQwen(
model="Compressa-LLM",
api_key="TOKEN_1",
api_base=url,
enable_thinking=False,
)

Guidance

The official Guidance library as of fall 2025 does not support working with OpenAI-like clients. You can use the modified library from our repository.

pip uninstall guidance
pip install git+https://github.com/compressa-ai/compressa-guidance.git
pip show guidance

Version Version: 0.3.0rc0 should be displayed

Usage Examples

Regular Expressions

email_generator = model(
model=compressa,
base_url=url,
api_key=key
)

with system():
email_generator += "You are a useful assistant. Don't use any other text than the answer."
with user():
email_generator += "Generate a valid email address."
with assistant():
email_generator += gen("lm_email", regex=r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", temperature=0.0)