📊Univer Go: Perfectly combining AI with spreadsheets to extract database data in one second

·

4 min read

Become your exclusive data processing assistant:

Hello 👋! I would like to recommend a smart template developed based on the Univer Go platform - Load Database, which is a powerful assistant for data processing! It deeply integrates the Phidata API and has the ability to intelligently access AI services. Through the form of questions and answers, it can understand the user's intentions, automatically generate corresponding query SQL statements, and query the database through these SQL statements, and finally return accurate data. Whether it is data analysis, data integration, or data screening, Load Database can quickly extract the data you need. In addition, its seamless integration with Univer Sheet not only significantly improves work efficiency, but also effectively reduces integration costs.

In Univer Go's operation interface, you can quickly extract the data you need from the database by running the AI Data Enrichment script with just one click. Not only that, Univer Go also gives you the ability to deeply customize the script, so that the tool in your hand can really be used for your own benefit. Whether you are dealing with complex business processes or turning creative work ideas into reality, it can accurately match your diverse needs and achieve your goals efficiently and easily.

Click to watch the automated office video that’s tailored for you, making your work more efficient and relaxing!: youtu.be/vlmFisF3DtE?si=lumYW4xvSllvIA09

Univer Go is a highly customizable spreadsheet tool that can build a spreadsheet with performance and functionality comparable to Excel based on user needs. It supports flexible functional expansion, covering basic data processing, complex import and export operations, and collaborative functions, while providing customization space for UI/UX design to help create an easy-to-use interactive interface.

In addition, Univer Go integrates advanced AI technologies and comes with powerful script writing and execution tools. It supports developers in creating and running automation scripts, connecting to databases, managing data reading and writing, and developing custom applications. Whether you're a beginner or a professional developer, its simple operation logic and rich feature support make it easy to get started.

Experience link: Univer Go

Implement Load Database :

  1. Client script custom interaction components
 const AIChat = ui.createAIChat().setCustomStyles({'height': document.body.offsetHeight - 30})
    .setSenderPromptsProps({
        items: [
            {
                key: 'clear',
                description: 'Clear Chat',
            },
        ]
    })
    .setModulesShow({
        welcome: true,
        placeholderPrompts: true,
        senderPrompts: true,
    })
    .setWelcomeProps({
        extra: space
    })
  1. The python server script provides AI interactive services and accesses the GPT API to return results based on the prompt words and cell data
# Predefined prompts
def sql_system_prompt():
    return """
You are a SQL translation expert, you always translate the user's language into executable SELECT statements.

## The following is the database schema:
<schema>
{ddl}
</schema>

## Examples:
Ask: Find all albums?
You answer: SELECT * FROM album;

Ask: Invoices in USA, sorted by total.
You answer: SELECT * FROM invoice WHERE billing_country = 'USA' ORDER BY total;

Ask: Customers located in France.
You answer: SELECT * FROM customer WHERE country = 'France';

## NOTES:
1. Be sure to output an executable SELECT without any explanation or preamble, without any code block or markdown (such as ```sql).
2. If the user asks for a table that doesn't exist, you should say "Table not found".
3. If you don't know the answer, you should say "I don't know".
""".format(ddl=get_ddl())

# Access the ai service api to obtain the sql statement
def sql_agent(query: str):
    gpt_agent = Agent(
        name="SQL Agent",
        system_prompt=sql_system_prompt(),
        model=model,
    )
    resp: RunResponse = gpt_agent.run(query)
    answer = resp.content
    if resp.messages[-1].role == "assistant":
        answer = resp.messages[-1].content
    return answer
  1. The client script calls and executes the python script to obtain database data
   const resp = await univerAPI.runOnServer('db', 'ask_sql_agent', query);
   Logger.log('load database:', resp);

Ready-made templates for quick use!

  1. Please download Univer Go first, find Load Database in the template, and click to use it.

    1. Download Link: Univer Go

  2. Enter Workspace and wait for the dependency installation to complete

    The code editor on the right supports AI assisted writing. For details, please refer to this article:

    Univer Go Launches AI-Powered API Writing Assistance

  3. Adjust the code, preview the table, and run the code

  1. Click the AI button in the lower right corner of the preview table

  1. You can use popular topics to interact or enter current needs

  1. Wait for the return message after sending

  1. If the SQL query is successful, you can choose to "create a new sheet and insert data" or "insert into the current sheet"

  1. Here I click "Insert into current sheet" to see the data displayed

  1. The above simple steps can help you quickly extract the data you need from the database! Log in to Univer Go now to explore a variety of customized functions and start a new experience of efficient office!
Â