-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLM isn't still following pydantic format for SQL #1906
Comments
Hey @Emekaborisama ! How are you setting up your LM and which LM is it? What is the pydantic element here? I don't see one. Is it I don't really see much of DSPy in the example code above. This is more or less a hand-written prompt. |
Hi @okhat Thanks alot for your response. really appreciate just updated the code. interesting. How would you do this differently? |
Have you tried adding a pydantic validator for sql? class SQLValidator(BaseModel):
sql_statement: str
@validator('sql_statement')
def validate_sql(cls, v):
if not isinstance(v, str):
raise ValueError('SQL statement must be a string')
try:
parsed = sqlparse.parse(v)
if not parsed:
raise ValueError('Empty SQL statement')
return v
except Exception as e:
raise ValueError(f'Invalid SQL syntax: {str(e)}') |
yes, i did |
I have made several attempts, but the inconsistency is concerning. Is there another way to ensure the LLM adheres to the guided pedantic format in Dspy?
The text was updated successfully, but these errors were encountered: