OpenAI Platform

이소영 20 Reputation points
2025-03-17T09:25:24.58+00:00

I have a question about the OpenAI Platform.

[Service requirements to be implemented]

<Integrated search]>

: It should support everything from metadata management to filtering condition extraction from user queries.

  • text-to-sql

: It is necessary to convert user queries (NLQ) to SQL and provide answers.

  • Vector search (with metadata)

: It is necessary to search user queries (NLQ) based on metadata and content information included in the json file.

[Inquiry details]

I have a question about the vector store function.

  1. Whether to support conversion of natural language user queries (NLQ) → similarity search and metadata filtering conditions

: It does not provide a function to automatically generate natural language query content and filtering conditions from user queries,

but if natural language queries and filtering conditions are set, it is only possible to search with the conditions.

  1. Vector search mode

: 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).

I would like to ask if it is not supported, and if so, what search modes are provided.

  1. I would like to ask if it is possible to develop a service that meets the service requirements to be implemented in the OpenAI Platform.
  • I would like to ask if it is possible to support writing custom codes other than the functions provided by the OpenAI Platform.
  • I would like to ask if it is possible to write a tool as a custom code.
  • I would like to ask if it is possible to support branching and cyclic structures based on conditions like langGraph.
  • I would like to ask if it is possible to convert a user query (NLQ) to SQL.
  • I would like to ask about extracting filtering conditions based on metadata of a vector DB based on user query (NLQ), metadata, and Semantic Layer data.
  • I would like to ask about DB schema and semantic Layer management.
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,256 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Manas Mohanty 1,950 Reputation points Microsoft External Staff
    2025-03-17T12:34:58.7533333+00:00

    Hi 이소영

    Here are the answers to your questions.

    1. I would like to ask if it is possible to convert a user query (NLQ) to SQL.
    1. 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

    On Add you own data

    On File search with Assistant

    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

    1. 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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.