Hi 이소영
Here are the answers to your questions.
- I would like to ask if it is possible to convert a user query (NLQ) to SQL.
- Yes, it is possible generate SQL codes from NLQ queries (accuracy higher with GPT 4o and 4o mini). You can also connect a SQL data base through Lang chain to interact with it.
2.It is necessary to search user queries (NLQ) based on metadata and content information included in the Json file
2.You can include the Json file in file as context with add your own data feature or file search feature in code interpreter from assistant. You can use below query.
Sample query - Could you refer the attached file and give SQL code to "your desired output"
Reference
3.Whether Vector store function to support conversion of natural language user queries (NLQ) → similarity search and metadata filtering conditions
Vector store will only contain data in vectorized form. Agent can look into that and generate SQL query with context received. You can select the metadata key field searchable, retrievable and filterable while creating the indexes.
4.I would like to ask if it is possible to write a tool as a custom code.
You can use function feature from assistant to use custom codes (use Api calls or python libraries )as tools
Reference - Function calling in Assistants
- When a user query is made, there seems to be no way to set the search mode (vector search, full-text search, hybrid search, semantic search).
You can create indexes with different type of search mode Vector search, Full-text search and hybrid search, semantic search and prompt user with sample query for respective search once a search model is selected. It has to be done programmatically though not possible through UI.
6.if it is possible to support branching and cyclic structures based on conditions like langGraph.
You can use if else statement to do branching of query. You can also use structured output to give outputs in desired format.
from azure.ai.openai import OpenAIClient
from azure.identity import DefaultAzureCredential
# Initialize the OpenAI client
client = OpenAIClient(endpoint="https://your-endpoint.openai.azure.com/", credential=DefaultAzureCredential())
# Define the branching logic
def process_query(query):
if "sales" in query:
return generate_sales_sql(query)
elif "inventory" in query:
return generate_inventory_sql(query)
else:
return "Unsupported query type"
# Function to generate SQL for sales queries
def generate_sales_sql(query):
# Custom logic to convert NLQ to SQL for sales
return "SELECT * FROM sales WHERE ..."
# Function to generate SQL for inventory queries
def generate_inventory_sql(query):
# Custom logic to convert NLQ to SQL for inventory
return "SELECT * FROM inventory WHERE ..."
# Example query
user_query = "Show me the sales data for last month"
sql_query = process_query(user_query)
print(sql_query)
7.about DB schema and semantic Layer management.
You can filter and truncate your existing SQL database to new one as per your business need and change the Semantic indexing accordingly
Hope it addresses all your query.
Thank you