Skip to content

Commit 8e46d9b

Browse files
author
reidliu41
committed
update simplified_sql_grammar
Signed-off-by: reidliu41 <reid201711@gmail.com>
1 parent ba0e21d commit 8e46d9b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

examples/online_serving/openai_chat_completion_structured_outputs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ def guided_json_completion(client: OpenAI, model: str):
7979
# Guided decoding by Grammar
8080
def guided_grammar_completion(client: OpenAI, model: str):
8181
simplified_sql_grammar = """
82-
?start: select_statement
82+
root ::= select_statement
8383
84-
?select_statement: "SELECT " column_list " FROM " table_name
84+
select_statement ::= "SELECT " column " from " table " where " condition
8585
86-
?column_list: column_name ("," column_name)*
86+
column ::= "col_1 " | "col_2 "
8787
88-
?table_name: identifier
88+
table ::= "table_1 " | "table_2 "
8989
90-
?column_name: identifier
90+
condition ::= column "= " number
9191
92-
?identifier: /[a-zA-Z_][a-zA-Z0-9_]*/
92+
number ::= "1 " | "2 "
9393
"""
9494

9595
prompt = ("Generate an SQL query to show the 'username' and 'email'"

examples/online_serving/openai_chat_completion_structured_outputs_with_reasoning.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ def guided_car_json_completion(client: OpenAI, model: str):
102102
# Guided decoding by Grammar
103103
def guided_grammar_completion(client: OpenAI, model: str):
104104
simplified_sql_grammar = """
105-
?start: select_statement
105+
root ::= select_statement
106106
107-
?select_statement: "SELECT " column_list " FROM " table_name
107+
select_statement ::= "SELECT " column " from " table " where " condition
108108
109-
?column_list: column_name ("," column_name)*
109+
column ::= "col_1 " | "col_2 "
110110
111-
?table_name: identifier
111+
table ::= "table_1 " | "table_2 "
112112
113-
?column_name: identifier
113+
condition ::= column "= " number
114114
115-
?identifier: /[a-zA-Z_][a-zA-Z0-9_]*/
115+
number ::= "1 " | "2 "
116116
"""
117117

118118
# This may be very slow https://github.com/vllm-project/vllm/issues/12122

0 commit comments

Comments
 (0)