Replies: 3 comments 1 reply
-
See: https://github.com/vllm-project/vllm/blob/v0.6.0/vllm/engine/arg_utils.py#L276 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @AkshataDM from pydantic import BaseModel
import json
from openai import OpenAI
class AnswerFormat(BaseModel):
name: str
lastname: str
age: int
client = OpenAI(
base_url="http://...../v1",
api_key="token",
)
user_prompt = "......"
completion = client.chat.completions.create(
model="yourmodelhere",
messages=[
{"role": "user", "content": user_prompt}
],
extra_body={
"guided_json": AnswerFormat.model_json_schema()
}
)
result = json.loads(completion.choices[0].message.content) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Has anyone looked into getting structured output from a model hosted using vllm? Would like some pointers on implementing this if anyone has any suggestions.
Beta Was this translation helpful? Give feedback.
All reactions