Command line interface interaction method and device, storage medium and program

By using the natural language processing model through intelligent assistance applications, command and code suggestions in the command line interface are generated, which solves the problem of low efficiency and accuracy of user interaction with the command line interface and realizes efficient interaction in the form of natural language.

CN120653333APending Publication Date: 2025-09-16ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410288485.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-13
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

The use of existing command line interfaces requires users to have detailed command knowledge and syntax proficiency, resulting in low interaction efficiency and accuracy. Users are prone to operation failures due to memory or input errors.

Method used

Provides an intelligent assistance application that understands user intentions through a natural language processing model, generates and displays command or code suggestions, and allows users to input their operation intentions in natural language, reducing the requirement for proficiency in commands and codes.

Benefits of technology

It improves the accuracy and efficiency of user interaction with the command line interface, simplifies the operation process, reduces the user's memory burden of commands and codes, and enhances the convenience and accuracy of interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653333A_ABST
    Figure CN120653333A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a command line interface interaction method and device, a storage medium and a program, and the method comprises the steps: receiving a user request in a natural language form input by a user, generating a cue word based on the user request, and inputting the cue word into a natural language processing model, answer information in a natural language form output by the natural language processing model is obtained, the answer information is displayed on the command line interface, and the answer information comprises at least one of a command used for responding to the user request, a code and natural language content. The intelligent assistance application program understands the user request based on the natural language processing model and provides accurate codes or command suggestions for the user to select and use, the user does not need to master all command and code use methods in advance, implementation is easy, and the accuracy and efficiency of interaction between the user and the command line interface can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a command line interface interaction method, device, storage medium and program. Background Art

[0002] The command-line interface (CLI) was a widely used user interface before the rise of the graphical user interface (GUI). It's typically used to control operating systems, configure software, and perform various tasks and services. It's also widely used in servers. A CLI allows users to interact with applications through pre-defined commands. For example, a user might enter the command "date" to invoke a time-query application and obtain the current time.

[0003] However, the use of existing command line interfaces usually requires users to have detailed command knowledge and grammatical proficiency, that is, to be able to master the various commands that can be used and their usage. This places high demands on users. Even experienced users often fail to operate due to memory or input errors, resulting in low efficiency and accuracy in user interaction with the command line interface. Summary of the Invention

[0004] Embodiments of the present invention provide a command line interface interaction method, device, storage medium, and program to improve the accuracy and efficiency of user interaction with the command line interface.

[0005] In a first aspect, an embodiment of the present invention provides a command line interface interaction method, the method comprising:

[0006] receiving a user request in a natural language input form by the user;

[0007] generating a prompt word based on the user request, and inputting the prompt word into a natural language processing model, wherein the natural language processing model has learned basic commands supported by the command line interface;

[0008] Obtaining answer information in a natural language format output by the natural language processing model, wherein the answer information includes at least one of a command, a code, and a natural language content for responding to the user request;

[0009] The answer information is displayed on the command line interface.

[0010] In a second aspect, an embodiment of the present invention provides a command line interface interaction device, the device comprising:

[0011] A receiving module, configured to receive a user request in a natural language input by a user;

[0012] a processing module configured to generate a prompt word based on the user request, input the prompt word into a natural language processing model, and obtain a natural language response information output by the natural language processing model, the response information including at least one of a command, code, and natural language content for responding to the user request, wherein the natural language processing model has learned basic commands supported by the command line interface;

[0013] The output module is used to display the answer information on the command line interface.

[0014] In a third aspect, an embodiment of the present invention provides an electronic device comprising: a memory, a processor, and a communication interface; wherein, the memory stores executable code, and when the executable code is executed by the processor, the processor can at least implement the command line interface interaction method described in the first aspect.

[0015] In a fourth aspect, an embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the command line interface interaction method described in the first aspect.

[0016] In a fifth aspect, an embodiment of the present invention provides a computer program product, which includes a computer application program, and when the computer program product is executed by a processor of an electronic device, enables the processor to at least implement the command line interface interaction method described in the first aspect.

[0017] In the command line interface interaction solution provided by an embodiment of the present invention, an application (referred to as an intelligent assistance application for ease of description) is provided to assist users in entering commands and codes in the command line interface. The user can call the intelligent assistance application in the command line interface and enter text content indicating their operation intention in natural language as a user request. The intelligent assistance application then generates a prompt word based on the user request, inputs the prompt word into a natural language processing model (such as a large language model), and obtains natural language response information output by the natural language processing model. The natural language processing model has already learned the basic commands supported by the command line interface, that is, the natural language processing model already knows the functions of these commands. Based on this, the natural language processing model can determine the appropriate command or generate the corresponding code or other response content as the response information after understanding the user intention through the prompt word. After obtaining the natural language response information fed back by the natural language processing model, it can be output to the command line interface for display. In this way, the user can obtain information such as the command and code that meets their operation intention through the response information, and thus can enter the command and code to be executed in the command line interface. In this solution, the intelligent assistance application understands user requests based on a natural language processing model and provides accurate code or command suggestions for users to choose from. Users do not need to master all the commands and code usage methods in advance. The implementation is simple and can improve the accuracy and efficiency of user interaction with the command line interface. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0019] Figure 1 A flowchart of a command line interface interaction method provided by an embodiment of the present invention;

[0020] Figure 2 A schematic diagram of the functional architecture of an intelligent assistance application provided by an embodiment of the present invention;

[0021] Figure 3 A flowchart of a command line interface interaction method provided by an embodiment of the present invention;

[0022] Figure 4 A schematic diagram of the interaction process between a user and an intelligent assistance application provided by an embodiment of the present invention;

[0023] Figure 5A schematic diagram of the interaction process between a user and an intelligent assistance application provided by an embodiment of the present invention;

[0024] Figure 6 A schematic diagram of the interaction process between a user and an intelligent assistance application provided by an embodiment of the present invention;

[0025] Figure 7 A schematic diagram of the interaction process between a user and an intelligent assistance application provided by an embodiment of the present invention;

[0026] Figure 8 A schematic diagram of the structure of a command line interface interaction device provided by an embodiment of the present invention;

[0027] Figure 9 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0028] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0029] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0030] The following describes some embodiments of the present invention in detail with reference to the accompanying drawings. The following embodiments and features thereof may be combined with one another unless they conflict with each other. Furthermore, the sequence of steps in the following method embodiments is provided for illustrative purposes only and is not intended to be a strict limitation.

[0031] First, the meanings of some concepts involved in the embodiments of the present invention are explained.

[0032] A command-line interface (CLI) is a user interface. Users enter commands through the keyboard, which are then passed to the operating system or other applications for execution. It serves as a tool for users to operate applications or the operating system. A command-line interface typically lacks graphical elements such as buttons or icons, but instead uses plain text. A command-line interface typically includes a terminal emulator, such as the Windows command prompt (cmd) or the Linux terminal.

[0033] Terminal emulators: These simulate traditional text terminals within a graphical user interface (GUI). Terminal emulators are typically used to interact with the operating system's command-line interface (CLI). They allow users to control the computer by typing text commands, providing an interface for inputting commands and viewing output. They emulate the functionality of traditional hardware terminals (such as teletypes and later computer terminals), allowing users to interact with the computer through keyboard input and screen output.

[0034] An interpreter (shell) is the operating system's interpreter for processing user commands. It receives commands from a terminal emulator, executes them, and sends the output back to the terminal emulator for the user to display. Common shells include, but are not limited to, bash and zsh. These shells are configured to support a set of basic commands by default. Users enter these commands in the command interface, which invokes the shell to execute them, thereby performing operations on objects such as the operating system and applications.

[0035] In summary, opening the CLI is equivalent to opening a terminal emulator, which, by default, runs a shell to execute command line operations. When a user enters commands in the CLI (or terminal emulator), the terminal emulator passes the commands to the shell, which executes the commands and outputs the results to the terminal emulator, which then displays them in the CLI.

[0036] Pipes: In command-line interfaces, pipes allow users to pass the output of one command directly into the input of another, creating complex chains of commands to perform multi-step operations. In any shell, you can use the "|" symbol to connect two commands. The shell will pipe the input and output of the two processes together, allowing inter-process communication.

[0037] Natural Language Processing (NLP): is a branch of artificial intelligence and linguistics that aims to enable computers to understand, interpret and generate human language.

[0038] Large language model: refers to a natural language processing model trained by large-scale text data, which can generate coherent text, understand semantic relationships, and complete natural language understanding tasks.

[0039] Prompt words: In natural language processing tasks, specific prompt words or keywords are used to assist natural language processing models in making predictions or generating text. Prompt words provide more accurate context and help models generate more reasonable and accurate results.

[0040] Python: It is an interpreted, object-oriented, high-level programming language with dynamic data types.

[0041] In the command line interface interaction solution provided by an embodiment of the present invention, an application (for ease of description, referred to as an intelligent assistance application) is provided to assist users in entering commands and codes in the command line interface. The intelligent assistance application understands the user's operating intentions based on a natural language processing model and provides accurate code or command suggestions for the user to choose and use. The user does not need to master the usage methods of all commands and codes in advance. The implementation is simple and can improve the accuracy and efficiency of the user's interaction with the command line interface. The intelligent assistance application is installed in a computer device that performs program, operating system, etc. operations through the command line interface. The working process of the intelligent assistance application is described below in conjunction with the following embodiments.

[0042] Figure 1 A flowchart of a command line interface interaction method provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method may include the following steps:

[0043] 101. Receive a user request in natural language input by a user.

[0044] 102. Generate prompt words based on the user request and input the prompt words into the natural language processing model. The natural language processing model has learned the basic commands supported by the command line interface.

[0045] 103. Obtain answer information in natural language format output by the natural language processing model, where the answer information includes at least one of a command, a code, and a natural language content for responding to the user request.

[0046] 104. Display the answer information on the command line interface.

[0047] The user can call the intelligent assistance application in the command line interface and input text content indicating their operation intention in natural language as a user request. In actual applications, the user can interact with the intelligent assistance application by using the name of the intelligent assistance application as a keyword. In this article, it is assumed that the name of the intelligent assistance application is: xyz. Therefore, the format of the user calling the intelligent assistance application to input the user request in natural language can be: xyz "user request in natural language". Alternatively, it can also be: a series of upstream commands | xyz "user request in natural language". As mentioned above, "|" represents a pipeline, which means that the execution result of the upstream command is used as the input parameter of the user request.

[0048] To make it easier to understand, here are a few examples:

[0049] 1. xyz "How to view the total size of each folder in the current directory"

[0050] 2. cat setup.py|xyz "What is the function of this code?"

[0051] 3. ps aux|grep python|xyz "What do these python processes do?"

[0052] 4. xyz "Write a quick sort and give a test case"

[0053] 5. xyz "What day is today?"

[0054] In Example 2, "cat setup.py" represents a piece of code. The phrase "What does this code do?" refers to this piece of code, serving as the input parameter for the user request "What does this code do?" Similarly, in Example 3, "ps aux" and "grep python" represent two processes, serving as input parameters for the user request "What do these Python processes do?"

[0055] In addition, in an optional embodiment, after the user calls the intelligent assistance application by entering the name of the intelligent assistance application in the command line interface, another interface may pop up, and the user can enter the above-mentioned user request in the other interface. The user request entered by the user can be associated and displayed in the command line interface, and the answer information corresponding to the user request is subsequently displayed in the command line interface.

[0056] As can be seen from the above examples, on the one hand, the user request entered by the user in the command line interface is a statement entered in natural language form that indicates the user's operation intention. On the other hand, the context information associated with the user request can also be introduced into the command line interface in a pipeline manner. In actual applications, the context information includes but is not limited to code, commands, and other configuration information.

[0057] In actual applications, when a user enters a user request using the keyword "xyz" in the command line interface, the shell can recognize this keyword, thereby clearly indicating that the intelligent assistance application needs to be invoked, and thus transmit the user input to the intelligent assistance application. It is understandable that after the intelligent assistance application is installed on the computer device, the intelligent assistance application's identifier, such as its name, can be configured as a keyword and registered in the basic command set recognized by the shell. Thus, the keyword serves as a command: a command that instructs the invocation of its corresponding intelligent assistance application. The user request and the upstream command passed through the pipeline will be transmitted as input parameters to the invoked intelligent assistance application.

[0058] Therefore, after receiving a user request, the intelligent assistance application uses the natural language processing model to obtain the corresponding response information. Specifically, the intelligent assistance application first generates a prompt word based on the user request, inputs the prompt word into the natural language processing model, and then obtains the natural language response information output by the natural language processing model.

[0059] In an optional embodiment, the intelligent assistance application may generate a prompt word based on the user request and auxiliary information, wherein the auxiliary information includes at least one of the following:

[0060] The upstream command passed in through the pipeline associated with the user request;

[0061] A set tool library, the tool library includes description information of multiple user-defined tools, and the multiple user-defined tools include at least one of the following: commands, codes, and applications;

[0062] Historical commands entered by users through the command line interface.

[0063] That is to say, when the user enters a user request, an upstream command is also passed in through the pipeline. The prompt word can also include the upstream command, so that the natural language processing model can understand the user's operation intention more accurately.

[0064] In addition, in actual applications, the commands entered successively by the user in the command line interface may have a certain degree of correlation, similar to the scenario of multiple rounds of dialogue. Therefore, the commands entered within a set time before the current user request can be used as historical commands and also spliced ​​into the prompt words, so that the natural language processing model can understand the user's operation intention more accurately.

[0065] In addition, users can customize tools to add to the tool library based on their needs. These tools include, but are not limited to, user-defined commands, code, and user-installed applications. Examples of these applications include search engines, graphic design programs, and video editing programs. Users can customize the tool library based on their needs, and the tool prompts can also include descriptions of these tools, which mainly explain the tool's function and how to use it (such as which parameters to enter).

[0066] It is understandable that user-defined commands and codes are different from the basic commands supported by the terminal emulator corresponding to the command line interface, which is equivalent to the user expanding the scope of basic commands according to actual usage needs.

[0067] In actual applications, a prompt word template can be set in advance, in which the above-mentioned tool library information is set, and input items of contextual information such as user requests, upstream commands, and historical commands are also set, so that the user request entered by the current user and the related upstream commands and historical commands are spliced ​​into the corresponding positions in the prompt word template to obtain the prompt words input into the natural language processing model.

[0068] After receiving the prompt word, the natural language processing model parses the user request and understands the user's intention based on the contextual information such as upstream commands and historical commands. Then, based on the learned basic commands and the tool information in the tool library, it generates answer information in natural language that the user can understand. The answer information may contain the executable commands or codes expected by the user.

[0069] In actual applications, the natural language processing model has already used the above basic commands as training data in the pre-training stage to allow the natural language processing model to learn. During the training stage, at least the natural language processing model can output basic commands that meet the user's intentions based on the functions of the known basic commands in response to user requests. In the model inference stage, since the natural language processing model has not learned the user-defined tool library information, the tool library information is used as a prompt to inform the natural language processing model so that it can output answer information that meets the user's intentions based on the tool library information. The commands, codes, etc. contained in the answer information may include call information for certain tools. Among them, basic commands refer to commands other than user-defined commands in the tool library.

[0070] In practice, the response information output by the natural language processing model includes at least one of commands, code, and natural language content in response to the user's request. In other words, the response information may contain some commands, a piece of code, or it may contain only natural language content, without commands or code. For example, in the example of multiple user requests above, the response information in Examples 2 and 3 only contains natural language content to answer the question of what the code does and what the various processes do.

[0071] In the embodiment of the present invention, the natural language processing model includes but is not limited to a large language model, and may also be a recurrent neural network model, a long short-term memory neural network model, and the like.

[0072] After obtaining the answer information output by the natural language processing model, the intelligent assistance application can display the answer information in the command line interface, so that the user can see the answer information in natural language form through the command line interface. If the answer information contains the command or code that the user expects to execute, the user can enter the corresponding command or code to execute the command or code to obtain the corresponding execution result, which is output in the command line interface.

[0073] In the above solution, natural language interaction with the user can be achieved in the command line interface: the intelligent assistance application understands the user's intention based on the natural language processing model and provides accurate code or command suggestions to achieve the ability to interact with the user through natural language. The user can directly enter natural language descriptions in the command line interface without the user having to master all the commands and code usage methods in advance. The implementation is simple and can improve the accuracy and efficiency of the user's interaction with the command line interface. In addition, auxiliary information such as code and commands input based on the pipeline serves as the above context information, which can assist the natural language processing model in understanding the user's intention more accurately. Moreover, based on the user-defined tool library, when the answer information output by the natural language processing model contains a command or code that calls a user-defined tool, the corresponding tool can be directly called to help complete the user request, simplifying the user's operation behavior and improving processing efficiency.

[0074] The above describes how the intelligent assistance application interacts with the user in the command line interface through natural language to provide corresponding answers to user requests. Figure 2 The functional architecture of the smart assistance application is shown.

[0075] like Figure 2 As shown in the , the intelligent assistance application mainly includes the following six functional modules:

[0076] (1) Information Scheduling and Interaction Module: This module is responsible for handling user interactions, receiving user requests in natural language format entered through the command line interface, providing necessary interface prompts and feedback, and forwarding user input to other processing modules. It is also responsible for presenting processing results (such as response information and command and code execution results) to the user, ensuring that communication between the user and the intelligent assistance application is timely and clear. As mentioned above, users mainly interact with the intelligent command line assistance system through the keyword xyz, the name of the intelligent assistance application, but this is not limited to this.

[0077] (2) Prompt word assembly module: The prompt word assembly module dynamically encapsulates prompt words that are conducive to the understanding of the natural language processing model based on the user request input by the current user and auxiliary information such as upstream commands and tool library information passed in by the pipeline, and then submits them to the natural language processing model for reasoning and output of answer information.

[0078] (3) Natural Language Processing Model: Based on the prompt word, it parses the user's input request and identifies the user's intent, generating a natural language response that the user can understand. The response may contain the executable command line instructions or code snippets that the user desires. The intelligent assistance application can configure the interface information for calling the natural language processing model to call the natural language processing model deployed locally or remotely.

[0079] (4) Command executor: This module is responsible for executing the commands (i.e., command line instructions) contained in the response information generated by the natural language processing model, and returning the execution results to the user through the information scheduling and interaction module (i.e., outputting them to the command line interface).

[0080] (5) Code executor: This module is responsible for executing complex codes (such as Python code snippets or scripts). When the answer information generated by the natural language processing model contains code, the code executor will be responsible for running the code, provide detailed execution logs, and return the execution results to the user through the information scheduling and interaction module.

[0081] (6) Tool Library: This module provides callable tool options for the code executor and command executor based on the configuration file provided by the user. The configuration file can be a plain text file in JSON or YAML format, which defines the name, function, parameters, and calling syntax of the available tools. The relevant tool description information will be integrated into the prompt word in the prompt word assembly module. If the user does not provide the relevant configuration file, the intelligent assistance application can provide some default tool information.

[0082] Figure 3 A flowchart of a command line interface interaction method provided by an embodiment of the present invention is shown in FIG. Figure 3As shown, the following steps may be included:

[0083] 301. Receive a user request in natural language input by a user through a command line interface.

[0084] 302. Generate prompt words based on the user request and input the prompt words into the natural language processing model. The natural language processing model has learned basic commands supported by the command line interface.

[0085] 303. Obtain answer information in natural language format output by the natural language processing model, and display the answer information on a command line interface, wherein the answer information includes at least one of a command, a code, and a natural language content for responding to the user request.

[0086] 304. Identify whether the reply information includes a command and / or a code according to the first format corresponding to the command and the second format corresponding to the code.

[0087] If it does not contain code or command, then it ends.

[0088] 305. If it is recognized that the answer information contains commands and / or codes, the commands or codes contained in the answer information are output in the command line interface, and query information is output, where the query information is used to ask the user whether to execute the commands or codes contained in the answer information.

[0089] 306. Based on the instruction information input by the user for instructing to execute the target command or target code in the answer information, execute the target command or target code, and display the execution result in the command line interface.

[0090] In this embodiment, in order to further improve the user's operational convenience, the intelligent assistance application, after outputting the answer information output by the natural language processing model to the command line interface, also guides the user to enter the target command or target code to be executed in the command line interface through simple input operations through multiple rounds of interaction with the user.

[0091] As mentioned above, the answer information output by the natural language processing model can include at least one of a command, a code, and a natural language content. In order to be able to identify the different types of information content contained in the answer information, the prompt word input to the natural language processing model can optionally also include a first prompt information and a second prompt information. The first prompt information is used to inform the natural language processing model to output the command in a first format, and the second prompt information is used to inform the natural language processing model to output the code in a second format. The first format and the second format will be illustrated below with reference to the accompanying drawings. Based on the prompt word, the natural language processing model will use the first format to output the command and the second format to output the code.

[0092] Therefore, after obtaining the answer information from the natural language processing model, the intelligent assistance application (such as the information scheduling and interaction module mentioned above) identifies whether the answer information contains commands and codes according to the first format and the second format.

[0093] Since the intelligent assistance application (such as the information scheduling and interaction module mentioned above) has completely output the answer information to the command line interface for display after obtaining the answer information from the natural language processing model, when it is determined that the answer information does not contain commands and codes, that is, the answer information only contains natural language content at this time, then the interaction with the user can be stopped.

[0094] For ease of understanding, combined Figure 4 This indicates that the answer information only contains natural language content. Figure 4 The example shown in the following is: setup.py|xyz "What does this code do?" Figure 4 As shown in , when the intelligent assistance application outputs the answer information, it is also introduced with the keyword "xyz" and the format is [xyz]: answer information.

[0095] When the response information is identified as containing at least one of a command or code, a subsequent interactive process with the user begins. In simple terms, the purpose of this interactive process is to guide the user to select the target command or code to be executed from the commands and codes contained in the response information by simply entering simple characters, then execute the target command or code to obtain the corresponding execution result, which is then displayed in the command line interface.

[0096] In this embodiment, because the code generated by the natural language processing model may contain errors, the probability of errors in executing the code is often higher than that of commands. Therefore, commands can be prioritized over codes. Based on this, when the response information is identified as containing both commands and codes according to the first and second formats, interaction with the user can be prioritized only for the commands, guiding the user to select the target command to be executed. If the user confirms that they do not select either command, interaction with the user can be conducted again for the code to determine whether the user selects the code for execution.

[0097] Based on this, in an optional embodiment, if it is recognized that the answer information contains a command or a command and a code, the following interactive process is executed: a first recognition result and a first inquiry message are output in the command line interface, wherein the first recognition result contains each command in the answer information and the label of each command, and the first inquiry message is used to inquire the user about the label of the command to be executed; in response to the user's input of the label of the target command, a second inquiry message is output in the command line interface to inquire whether to confirm the execution of the target command, and the target command is highlighted in the second inquiry message; based on the instruction information input by the user to instruct the execution of the target command, the target command is executed, and the execution result is displayed in the command line interface.

[0098] That is, when the reply contains N (N≥1) commands, the N commands will be numbered in the description of the first recognition result: 1, 2, ..., that is, the description of the first recognition result lists the commands identified from the reply. The description format of the first recognition result can be: [xyz] The following commands are found:

[0099] Afterwards, the user is asked to select a command from the command number range [1, N]. The description format of the first inquiry message can be: [xyz] Please select the command to execute, select from [1, N]. Reply "no" or "n" to cancel, and reply "retry" or "r" to generate a new answer.

[0100] Afterwards, based on the first query information, the user can enter the number of the selected target command, or, if there is no command to be executed, can reply "n" or "r".

[0101] Among them, if the answer information contains a code in addition to the command, if the user replies no, the intelligent assistance application can also interact with the user based on the code to determine whether the user executes the code. The interaction process is described below.

[0102] In an optional embodiment, as mentioned above, the first inquiry information is also used to inquire whether the user needs to regenerate the answer information, that is, it includes the content "Reply "r" to regenerate the answer." Therefore, if the user replies with the instruction information to regenerate the answer information: r, the prompt word is re-input into the natural language processing model to obtain the answer information re-output by the natural language processing model. It can be seen from the principle of the natural language processing model when performing text prediction that the re-output answer information is different from the original output answer information, so the regenerated answer information may contain more accurate codes and commands that symbolize the user's needs. The processing process of the regenerated answer information is the same as the processing process of the original output answer information, which will not be repeated here.

[0103] Assume that the user selects a command from [1,N], that is, the user enters the label of a command in the command line interface, such as "1", then the command with this label is used as the target command. At this time, the second inquiry information in the following description format can also be entered: [xyz] Confirm to execute the command [...]? Reply y / n. Among them, y means confirm to execute, and n means not to execute. Among them, [...] is the highlighted target command, for example, the target command is displayed in different fonts and colors. Since the display style of each command in the first recognition result is the same, and is consistent with the display style of the content in other interfaces such as the answer information, the user may accidentally enter the wrong number or not see the target command clearly when entering the label of the target command. Directly highlighting the target command in the second inquiry information can make the user more clear about the command he chooses to execute and prevent input errors.

[0104] If the user replies with y, the target command will be automatically executed, and the execution result will be output to the command line interface.

[0105] To understand the above interaction process, Figure 5 Example description. Figure 5 The example in the above text is: xyz "How to view the total size of each folder in the current directory". Figure 5 As shown in , the various information output by the intelligent assistance application when interacting with the user is also introduced by the keyword "xyz", and the answer information and various recognition results and query information are as follows: Figure 4 As shown in the mark. Figure 5 In the example shown, the reply information includes a command and a code. Since the command has a higher priority than the code, the first recognition result only describes the discovered command.

[0106] like Figure 5 As shown in , in the above interaction process, the user only needs to enter a few simple characters in the command line interface, such as digital labels, y, r, n, etc., which is highly convenient to operate.

[0107] In another optional embodiment, if it is identified that the answer information contains code but not commands, the following interactive process is executed: a second recognition result and a third inquiry message are output in the command line interface, wherein the code contained in the answer information is highlighted in the second recognition result, and the third inquiry message is used to ask the user whether to execute the code.

[0108] If it is identified that the answer information contains multiple codes but no commands, the multiple codes are merged, and a second recognition result corresponding to the merged result is output in the command line interface.

[0109] In real-world applications, natural language processing models typically generate only one piece of code corresponding to a user request. If multiple pieces of code are generated, the first piece may actually implement a certain function (algorithm), while the remaining pieces may serve as test cases. Once the user confirms the execution of the first piece of code, there's no way to return to execute the test cases. Therefore, multiple code segments are consolidated: if multiple pieces of code are generated, all are merged into one piece.

[0110] The description format of the second recognition result can be: [xyz] found the following python code:

[0111] The description format of the third inquiry message may be: [xyz] Are you sure to execute the above code? Reply y / n, reply r, or retry to generate a new answer.

[0112] If the user replies with "y," the code is executed and the results are displayed on the command line interface. If the user replies with "n," the process ends. If the user replies with "r," a new answer is generated.

[0113] To understand the above interaction process, Figure 6 Example description. Figure 6 The example in the figure is as follows: xyz "write a quick sort and give a test case". Figure 6 As shown in .

[0114] in addition, Figure 7 The following shows the situation when the user replies r.

[0115] In summary, after the intelligent assistance application outputs the natural language processing model's response information, including code and commands, to the command line interface, it will proactively ask the user whether to execute the command directly. Only after the user enters "y" to confirm will the relevant command or code be executed, and the execution results will be presented to the user in real time. If the user responds "n" to choose not to execute any suggested commands or codes, the intelligent assistance application will remain in standby mode and will not perform any unauthorized operations, ensuring the security of the user's terminal.

[0116] The following describes in detail the command line interface interaction device of one or more embodiments of the present invention. Those skilled in the art will understand that these devices can be constructed by using commercially available hardware components and configuring them according to the steps taught in this solution.

[0117] Figure 8 A schematic diagram of the structure of a command line interface interaction device provided by an embodiment of the present invention, wherein the command line interface interaction device is applied to a server, such as Figure 8As shown, the device includes: a receiving module 11, a processing module 12, and an output module 13.

[0118] The receiving module 11 is configured to receive a user request in natural language input by a user through a command line interface.

[0119] A processing module 12 is used to generate a prompt word based on the user request, input the prompt word into a natural language processing model, and obtain answer information in natural language form output by the natural language processing model, wherein the answer information includes at least one of a command, code, and natural language content for responding to the user request, and the natural language processing model has learned the basic commands supported by the command line interface.

[0120] The output module 13 is configured to display the answer information on the command line interface.

[0121] Figure 8 The device shown can execute the steps in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments and will not be repeated here.

[0122] In one possible design, the above Figure 8 The structure of the device shown can be realized as an electronic device. Figure 9 As shown, the electronic device may include: a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable code, which, when executed by the processor 21, enables the processor 21 to at least implement the command line interface interaction method provided in the aforementioned embodiment.

[0123] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the command line interface interaction method provided in the aforementioned embodiment.

[0124] An embodiment of the present invention provides a computer program product, which includes a computer application (i.e., the above-mentioned intelligent assistance application). When the computer program product is executed by a processor of an electronic device, the processor can at least implement the command line interface interaction method provided in the above-mentioned embodiment.

[0125] The device embodiments described above are merely illustrative, wherein the network elements described as separate components may or may not be physically separate. Some or all of these modules may be selected based on actual needs to achieve the objectives of this embodiment. Persons of ordinary skill in the art can understand and implement these embodiments without inventive effort.

[0126] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by a combination of hardware and software. Based on this understanding, the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A command line interface interaction method, characterized in that: The method comprises: receiving a user request in a natural language input form by the user; generating a prompt word based on the user request, and inputting the prompt word into a natural language processing model, wherein the natural language processing model has learned basic commands supported by the command line interface; Obtaining answer information in a natural language format output by the natural language processing model, wherein the answer information includes at least one of a command, a code, and a natural language content for responding to the user request; The answer information is displayed on the command line interface.

2. The method according to claim 1, characterized in that Generating a prompt word based on the user request includes: Generate a prompt word based on the user request and auxiliary information, wherein the auxiliary information includes at least one of the following: An upstream command associated with the user request, the upstream command being input through a pipeline; A set tool library, wherein the tool library includes description information of a plurality of user-defined tools, wherein the plurality of user-defined tools include at least one of the following: a command, a code, and an application; The historical commands entered by the user through the command line interface.

3. The method according to claim 1, characterized in that The method further comprises: Identifying whether the response information includes a command and / or a code; If it is recognized that the answer information contains a command and / or code, the command or code contained in the answer information is output in the command line interface, and a query message is output, wherein the query message is used to inquire the user whether to execute the command or code contained in the answer information; executing the target command or target code in the answer information based on the instruction information input by the user for instructing the execution of the target command or target code; The execution result is displayed in the command line interface.

4. The method according to claim 3, characterized in that The identifying whether the answer information includes a command and / or a code includes: According to the first format corresponding to the command and the second format corresponding to the code, it is identified whether the reply information includes the command and / or the code.

5. The method according to claim 4, characterized in that The prompt word includes first prompt information and second prompt information, the first prompt information is used to inform the natural language processing model to output commands in the first format, and the second prompt information is used to inform the natural language processing model to output codes in the second format.

6. The method according to claim 3, characterized in that If it is recognized that the answer information contains a command and / or code, the command or code contained in the answer information is output in the command line interface, and the query information is output, including: If it is recognized that the answer information contains a command or a command and a code, outputting a first recognition result and a first inquiry message in the command line interface, wherein the first recognition result includes each command and the number of each command in the answer information, and the first inquiry message is used to inquire the user about the number of the command selected for execution; In response to the user inputting a label of a target command, second inquiry information for inquiring whether to confirm execution of the target command is output in the command line interface, and the target command is highlighted in the second inquiry information.

7. The method according to claim 3, characterized in that If it is recognized that the answer information contains a command and / or code, the command or code contained in the answer information is output in the command line interface, and the query information is output, including: If it is identified that the answer information contains code but no command, a second recognition result and a third inquiry message are output in the command line interface, wherein the code contained in the answer information is highlighted in the second recognition result, and the third inquiry message is used to ask the user whether to execute the code.

8. The method according to claim 7, characterized in that If it is recognized that the answer information contains a code but does not contain a command, outputting a second recognition result in the command line interface includes: If it is identified that the answer information contains multiple codes but no commands, the multiple codes are merged, and a second recognition result corresponding to the merged result is output in the command line interface.

9. The method according to claim 3, characterized in that The inquiry information is further used to inquire the user whether to regenerate answer information; the method further includes: In response to the instruction information input by the user to regenerate the answer information, the prompt word is re-input into the natural language processing model to obtain the answer information re-output by the natural language processing model, and the re-output answer information is different from the originally output answer information.

10. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the command line interface interaction method according to any one of claims 1 to 9.

11. A non-transitory machine-readable storage medium, characterized in that The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the command line interface interaction method according to any one of claims 1 to 9.

12. A computer program product, characterized in that include: A computer application, when executed by a processor of an electronic device, causes the processor to execute the command line interface interaction method according to any one of claims 1 to 9.