Query builder using LangChain, LangSmith using gpt-4o-mini LLM
Open AI model gpt-4o-mini is one my favourite because of it's low cost and less effective time to get the job done. Below code is to analyze question/query and transform them into meaning full SQL statement through LangSmith and LangChain. I'm not using Pydantic directly here and let the Lang team to handle the query builder part. One simple quetion - how many employee do we have? Let's see, how the below code act and what exactly SQL is able to generate: import os from langchain_openai import ChatOpenAI from langchain_core.prompts import ChatPromptTemplate from typing_extensions import Annotated, TypedDict from langchain_community.utilities import SQLDatabase from langchain_community.tools.sql_database.tool import QuerySQLDatabaseTool from langgraph.graph import START, StateGraph os.environ[ "LANGSMITH_TRACING" ] = "true" os.environ[ "LANGSMITH_API_KEY" ] = "Your key" if not os.environ.get( "OPENAI_API_KEY" ...