| [User] | ||
| Show me how to calculate Fibonacci in JavaScript. | ||
| [Assistent] | ||
| Here is one way of calculating Fibonacci in JavaScript: | ||
| // Create a function to calculate Fibonacci | ||
| function fibo(n) { | ||
| // Declare an array | ||
| let arr = [0, 1]; | ||
| // Add the previous two numbers in the array | ||
| // and push to new array | ||
| for (let i = 2; i < n + 1; i++){ | ||
| arr.push(arr[i - 2] + arr[i -1]) | ||
| } | ||
| // Return the last number of the array | ||
| return arr[n] | ||
| } | ||
| console.log(fibo(7)); // 13, answer is 13 | ||
| [User] | ||
| Can you convert this in Rust? | ||
| [Assistent] | ||
| Sure, here is a way of calculating Fibonacci in Rust: | ||
| // Create a function to calculate Fibonacci | ||
| fn fibonacci(n: u32) -> u32 { | ||
| // Use an if statement | ||
| // to return the first | ||
| // two numbers of series | ||
| if n == 0 { | ||
| 0 | ||
| } else if n == 1 { | ||
| 1 | ||
| } else { | ||
| fibonacci(n - 1) + fibonacci(n - 2) | ||
| } | ||
| } | ||
| // Print the last number of the array | ||
| println!("{}", fibonacci(7));// 13, test passed |
+3
-3
@@ -15,3 +15,3 @@ #!/usr/bin/env node | ||
| await fs.promises.mkdir('.superchat', { recursive: true }) | ||
| await fs.promises.mkdir('.codepal', { recursive: true }) | ||
@@ -25,3 +25,3 @@ const conversation = new Conversation({ | ||
| for (const file of [process.argv[2], path.join('.superchat', process.argv[2]), path.join('.superchat', process.argv[2] + '.md')]) { | ||
| for (const file of [process.argv[2], path.join('.codepal', process.argv[2]), path.join('.codepal', process.argv[2] + '.md')]) { | ||
| try { | ||
@@ -43,3 +43,3 @@ conversationPath = file | ||
| } else { | ||
| conversationPath = path.join('.superchat', `${uuidv4()}.md`) | ||
| conversationPath = path.join('.codepal', `${uuidv4()}.md`) | ||
| } | ||
@@ -46,0 +46,0 @@ |
+1
-1
| { | ||
| "name": "codepal", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
+24
-4
| # CodePal | ||
| CodePal is a command line tool with a chat interface that helps developers write code. It is built on top of GPT-3 and ChatGPT, and provides a convenient and intuitive way for developers to write code quickly and efficiently. | ||
| CodePal is a command line tool with a chat interface that helps developers write code. It is built on top of GPT-3 and ChatGPT (which is a work in progress), and provides a convenient and intuitive way for developers to write code quickly and efficiently. | ||
@@ -8,3 +8,3 @@ ## Features | ||
| - Chat-based interface that allows for natural, conversational code writing | ||
| - Built on top of GPT-3 and ChatGPT, providing state-of-the-art natural language processing capabilities | ||
| - Built on top of GPT-3 and ChatGPT (soon), providing state-of-the-art natural language processing capabilities | ||
| - Easy to use and customize to your personal coding style | ||
@@ -22,4 +22,10 @@ | ||
| To use CodePal, navigate to the directory where you want to write your code and run the following command: | ||
| Before using CodePal, you will need to set up an environment variable with your OpenAI credentials. This can be done by adding the following line to a `.env` file in your project directory: | ||
| ``` | ||
| OPENAI_API_KEY=YOUR_API_KEY_HERE | ||
| ``` | ||
| Once you've set up the environment variable, you can use CodePal by navigating to the directory where you want to write your code and running the following command: | ||
| ```sh | ||
@@ -29,6 +35,20 @@ codepal | ||
| This will start the CodePal chat interface, where you can write your code using natural language. CodePal will provide suggestions and code completion as you go, making it easy to write code quickly and efficiently. | ||
| This will start the CodePal chat interface, where you can write your code using natural language. CodePal will save your chat history in a directory called `.codepal` in your current working folder. To continue a previous chat session, you can provide the path to the chat history file, like this: | ||
| ```sh | ||
| codepal .codepal/b1a7e548-da06-48be-9844-50f9b9c9436b.md | ||
| ``` | ||
| Alternatively, you can just provide the filename (without the path), like this: | ||
| ```sh | ||
| codepal b1a7e548-da06-48be-9844-50f9b9c9436b | ||
| ``` | ||
| In this case, CodePal will automatically look for the chat history file in the `.codepal` directory of your current working folder. | ||
| The command line tool will also be made aware of git in the coming weeks/days, allowing for even more convenient code writing. | ||
| ## License | ||
| CodePal is licensed under the [MIT license](LICENSE). |
| [User] | ||
| Show me how to calculate Fibonacci in JavaScript. | ||
| [Assistent] | ||
| Here is one way of calculating Fibonacci in JavaScript: | ||
| // Create a function to calculate Fibonacci | ||
| function fibo(n) { | ||
| // Declare an array | ||
| let arr = [0, 1]; | ||
| // Add the previous two numbers in the array | ||
| // and push to new array | ||
| for (let i = 2; i < n + 1; i++){ | ||
| arr.push(arr[i - 2] + arr[i -1]) | ||
| } | ||
| // Return the last number of the array | ||
| return arr[n] | ||
| } | ||
| console.log(fibo(7)); // 13, answer is 13 | ||
| [User] | ||
| Can you convert this in Rust? | ||
| [Assistent] | ||
| Sure, here is a way of calculating Fibonacci in Rust: | ||
| // Create a function to calculate Fibonacci | ||
| fn fibonacci(n: u32) -> u32 { | ||
| // Use an if statement | ||
| // to return the first | ||
| // two numbers of series | ||
| if n == 0 { | ||
| 0 | ||
| } else if n == 1 { | ||
| 1 | ||
| } else { | ||
| fibonacci(n - 1) + fibonacci(n - 2) | ||
| } | ||
| } | ||
| // Print the last number of the array | ||
| println!("{}", fibonacci(7));// 13, test passed |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
8325
11.66%52
62.5%