How can I change the model of the OpenAI LLM which I am using for chatting with my database via Langchain

Everytime I run the following code with a different model like “text-davinci-003” instead of “gpt-3.5-turbo” I am receiving the following error.: InvalidRequestError: This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?

Here is my code:
from langchain import LLMMathChain, OpenAI, SerpAPIWrapper, SQLDatabase
from langchain_experimental.sql import SQLDatabaseChain
from langchain.agents import initialize_agent, Tool
from langchain.agents import AgentType
from langchain.chat_models import ChatOpenAI
from decouple import config

oak = openai_secret_key (witheld for security)
openai_api_key = oak

create LLM model

llm = ChatOpenAI(temperature=0, model=“babbage-002”, openai_api_key=openai_api_key)

create an LLM math tool

llm_math_chain = LLMMathChain.from_llm(llm=llm, verbose=True)

connect to our database

db = SQLDatabase.from_uri(“sqlite:///maids.db”)

create the database chain

db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True)

tools = [
Tool(
name=“Yellowsense_Database”,
func=db_chain.run,
description=“useful for when you need to answer questions about maids/cooks/nannies.”
)
]

creating the agent

agent = initialize_agent(
tools=tools, llm=llm, agent=AgentType.OPENAI_FUNCTIONS, verbose=True)

user_input = input(
“”“You can now chat with your database.
Please enter your question or type ‘quit’ to exit: “””
)

ask the LLM a question

agent.run(user_input) Please help and let me know what all models I can alternatively use for my gen ai chatbot to get the best results. I basically want it to recommend maids/cooks/nannies to me based on the info stored in an sql database

A post was merged into an existing topic: Error: InvalidRequestError: This is not a chat model and thus not supported in the v1/chat/completions endpoint