Files
propella-1-4b/inference_example.py
ModelHub XC 272f8486d6 初始化项目,由ModelHub XC社区提供模型
Model: ellamind/propella-1-4b
Source: Original Platform
2026-05-18 09:38:58 +08:00

27 lines
774 B
Python

from openai import OpenAI
from propella import (
create_messages,
AnnotationResponse,
get_annotation_response_schema,
)
document = "Hi, its me Max."
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="ellamind/propella-1-4b",
messages=create_messages(document),
response_format={
"type": "json_schema",
"json_schema": {
"name": "AnnotationResponse",
"schema": get_annotation_response_schema(flatten=True, compact_whitespace=True),
"strict": True,
}
},
)
response_content = response.choices[0].message.content
result = AnnotationResponse.model_validate_json(response_content)
print(result.model_dump_json(indent=4))