Rawi (راوي) Documentation | Examples
About the Examples in the Rawi CLI Documentation
Section titled “About the Examples in the Rawi CLI Documentation”The Rawi CLI documentation uses consistent formatting conventions for all command-line examples:
- Prompt – The Linux shell prompt is shown as
$
. For Windows-specific commands,C:\>
is used. Do not type the prompt character when entering commands. - Directory – If a command must be run from a specific directory, the directory path is shown before the prompt.
- User Input – Commands you type are shown as user input.
- Replaceable Text – Variable text (such as file names, profile names, or API keys) is shown in italic or
<angle brackets>
. Replace these with your own values. - Output – Output from Rawi or the shell is shown below the command, formatted as computer output.
Example: Configuring a Provider
Section titled “Example: Configuring a Provider”Enter the following command to start interactive configuration:
$ rawi configure? Provider: openai? Model: gpt-4o? API Key: <your-openai-api-key>? Profile name: workConfiguration saved to ~/.rawi/credentials
Example: Running a Command and Viewing Output
Section titled “Example: Running a Command and Viewing Output”This example shows how to ask a question and view the response:
$ rawi ask "What is TypeScript?"✔ Result:TypeScript is a superset of JavaScript that adds optional static typing. This means it builds on JavaScript, adding features to it but remaining compatible, and its key improvement is the introduction of types.
Here's a breakdown of what that means:
* **Superset of JavaScript:** All valid JavaScript code is also valid TypeScript code. You can gradually introduce TypeScript into existing JavaScript projects without rewriting everything at once.
* **Optional Static Typing:** TypeScript allows you to specify the *types* of variables, function parameters, and return values. This is called "static typing" because the type checking happens at *compile time*, before the code runs in a browser or Node.js. This is optional; you can still write JavaScript-style code without specifying types, though the benefits of typing are lost.
* **Benefits of Static Typing:** * **Early Error Detection:** The compiler catches type errors before runtime, preventing many bugs that would otherwise only surface during testing or in production. * **Improved Code Readability and Maintainability:** Type annotations make code easier to understand and maintain, especially in large projects. They act as documentation built directly into the code. * **Enhanced Code Refactoring:** With types, refactoring is safer and easier because the compiler can warn you of potential type-related issues. * **Better Tooling:** TypeScript enables better code completion, auto-suggestions, and other features in code editors and IDEs. * **Object-Oriented Programming (OOP) Features:** TypeScript provides support for classes, interfaces, inheritance, and other OOP features commonly found in statically-typed languages.
In essence, TypeScript allows you to write JavaScript in a way that's more robust, maintainable, and easier to collaborate on, especially for larger and more complex projects. The compiler then translates the TypeScript code into plain JavaScript, which can be run by any JavaScript engine.
Example: Using Replaceable Text
Section titled “Example: Using Replaceable Text”Replace <profile>
with your desired profile name:
$ rawi ask "Summarize this code" --profile <profile>
Example: Piping Input
Section titled “Example: Piping Input”You can pipe files or command output into Rawi:
$ cat app.js | rawi ask "Review this code for security issues"
Tip: For more usage patterns and advanced examples, see the Usage Examples and FAQ.