You have commented down your llm instance in the given above code.
Is this intentional ?
Try using Settings
from llama_index.core import Settings
Settings.llm = llm # your azure instance
Settings.embed_model = embed_model # your embedding mode instance
Hi @WhiteFang_Jr ,
Yes, it was intentional, I tried adding above code, but same response.
llm = AzureOpenAI(
engine="controltower", model="gpt-35-turbo", temperature=0.0
)
embed_model=OpenAIEmbedding(model_name="gpt-35-turbo")
Settings.llm = llm # your azure instance
Settings.embed_model = embed_model # your embedding mode instance
obj_index = ObjectIndex.from_objects(
table_schema_objs,
table_node_mapping,
VectorStoreIndex,
llm=llm
)
Ah I see the problem.
You have used azure openai for llm and normal openai for embedding
Plus you have defined wrong name in embedding model.
Either use full azure or full openai
@WhiteFang_Jr I tried using complete Azure.
import os
import openai
from llama_index.core import SQLDatabase
from openai import AzureOpenAI
from llama_index.llms.azure_openai import AzureOpenAI
from langchain_openai import AzureOpenAIEmbeddings
llm = AzureOpenAI(
engine="controltower", model="gpt-35-turbo", temperature=0.0
)
embed_model=AzureOpenAIEmbeddings(model="gpt-35-turbo", azure_endpoint="
https://ccllmopenai.openai.azure.com/")
Settings.llm = llm # your azure instance
Settings.embed_model = embed_model # your embedding mode instance
obj_index = ObjectIndex.from_objects(
table_schema_objs,
table_node_mapping,
VectorStoreIndex,
llm=llm
)
Still facing issues, I tried model with gpt-4o, gpt-35-turbo, gpt-4.
can you please suggest what should be the model for NLtoSQL.
You are still putting an incorrect model name in embedding.
Do the following and try once
pip install llama-index-embeddings-azure-openai
Then import it like this
from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding
Settings.embed_model = AzureOpenAIEmbedding()
In the embedding model you are passing llm model name which is why you might be getting the error.
now I am getting below error:
Retrying llama_index.embeddings.openai.base.get_embeddings in 3.913704518450162 seconds as it raised APIConnectionError: Connection error..
raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.
The above exception was the direct cause of the following exception:
File "/Users/kiran-rayabandi/.pyenv/versions/3.9.2/lib/python3.9/site-packages/openai/_base_client.py", line 986, in _request
raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.
I changed the embedding model to text-embedding-ada-002, it worked.
but I am connecting to SQL, to process natural language to SQL
obj_index = ObjectIndex.from_objects(
table_schema_objs,
table_node_mapping,
VectorStoreIndex,
llm=llm
)
query_engine = SQLTableRetrieverQueryEngine(
sql_database, obj_index.as_retriever(similarity_top_k=1)
)
print(query_engine)
response = query_engine.query("Show me the inventory")
response.metadata["result"]
facing below error
ValueError: Unknown model 'text-embedding-ada-002'. Please provide a valid OpenAI model name in: gpt-4, gpt-4-32k, gpt-4-1106-preview, gpt-4-0125-preview, gpt-4-turbo-preview, gpt-4-vision-preview, gpt-4-1106-vision-preview, gpt-4-turbo-2024-04-09, gpt-4-turbo, gpt-4o, gpt-4o-2024-05-13, gpt-4-0613, gpt-4-32k-0613, gpt-4-0314, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-3.5-turbo-0125, gpt-3.5-turbo-1106, gpt-3.5-turbo-0613, gpt-3.5-turbo-16k-0613, gpt-3.5-turbo-0301, text-davinci-003, text-davinci-002, gpt-3.5-turbo-instruct, text-ada-001, text-babbage-001, text-curie-001, ada, babbage, curie, davinci, gpt-35-turbo-16k, gpt-35-turbo, gpt-35-turbo-0125, gpt-35-turbo-1106, gpt-35-turbo-0613, gpt-35-turbo-16k-0613
with embedded model, query is not working
If you look at the error, you are choosing wrong model name
yes, but if I choose gpt-35-turbo-16k,gpt-4 or any other getting below error
ValueError: 'gpt-35-turbo-16k' is not a valid OpenAIEmbeddingModelType
if it is NL to SQL should we not be using the embedded model?
These model names are for llm
They are not for embedding purpose
Error I got using text-embedding-ada-002
ValueError: Unknown model 'text-embedding-ada-002'. Please provide a valid OpenAI model name in: gpt-4, gpt-4-32k, gpt-4-1106-preview, gpt-4-0125-preview, gpt-4-turbo-preview, gpt-4-vision-preview, gpt-4-1106-vision-preview, gpt-4-turbo-2024-04-09, gpt-4-turbo, gpt-4o, gpt-4o-2024-05-13, gpt-4-0613, gpt-4-32k-0613, gpt-4-0314, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-3.5-turbo-0125, gpt-3.5-turbo-1106, gpt-3.5-turbo-0613, gpt-3.5-turbo-16k-0613, gpt-3.5-turbo-0301, text-davinci-003, text-davinci-002, gpt-3.5-turbo-instruct, text-ada-001, text-babbage-001, text-curie-001, ada, babbage, curie, davinci, gpt-35-turbo-16k, gpt-35-turbo, gpt-35-turbo-0125, gpt-35-turbo-1106, gpt-35-turbo-0613, gpt-35-turbo-16k-0613
These are options it accepst
_QUERY_MODE_MODEL_DICT = {
(OAEM.SIMILARITY_MODE, "davinci"): OAEMM.TEXT_SIMILARITY_DAVINCI,
(OAEM.SIMILARITY_MODE, "curie"): OAEMM.TEXT_SIMILARITY_CURIE,
(OAEM.SIMILARITY_MODE, "babbage"): OAEMM.TEXT_SIMILARITY_BABBAGE,
(OAEM.SIMILARITY_MODE, "ada"): OAEMM.TEXT_SIMILARITY_ADA,
(OAEM.SIMILARITY_MODE, "text-embedding-ada-002"): OAEMM.TEXT_EMBED_ADA_002,
(OAEM.SIMILARITY_MODE, "text-embedding-3-small"): OAEMM.TEXT_EMBED_3_SMALL,
(OAEM.SIMILARITY_MODE, "text-embedding-3-large"): OAEMM.TEXT_EMBED_3_LARGE,
(OAEM.TEXT_SEARCH_MODE, "davinci"): OAEMM.TEXT_SEARCH_DAVINCI_QUERY,
(OAEM.TEXT_SEARCH_MODE, "curie"): OAEMM.TEXT_SEARCH_CURIE_QUERY,
(OAEM.TEXT_SEARCH_MODE, "babbage"): OAEMM.TEXT_SEARCH_BABBAGE_QUERY,
(OAEM.TEXT_SEARCH_MODE, "ada"): OAEMM.TEXT_SEARCH_ADA_QUERY,
(OAEM.TEXT_SEARCH_MODE, "text-embedding-ada-002"): OAEMM.TEXT_EMBED_ADA_002,
(OAEM.TEXT_SEARCH_MODE, "text-embedding-3-large"): OAEMM.TEXT_EMBED_3_LARGE,
(OAEM.TEXT_SEARCH_MODE, "text-embedding-3-small"): OAEMM.TEXT_EMBED_3_SMALL,
}
but I am unable to craete them on the Azure Open AI
I am not sure hot to handle it
Please let me if you can connect on a call?
You'll have to create an instance of embedding model on azure first
I did created deployments in the azure open ai
These are llms, you'll have to add a embedding model
I might have not created it
This page has some info on how to deploy embedding model
let me do that and update you
another error
openai.BadRequestError: Error code: 400 - {'error': {'code': 'OperationNotSupported', 'message': 'The embeddings operation does not work with the specified model, gpt-35-turbo-16k. Please choose different model and try again. You can learn more about which models can be used with each operation here:
https://go.microsoft.com/fwlink/?linkid=2197993.'}}Can you share your full code as I think you are still putting the wrong model name for embedding
HI @WhiteFang_Jr
I am able to fix it
thanks for helping me out