iamgreggarcia / codesherpa

A code interpreter and ChatGPT plugin.
MIT License
255 stars 34 forks source link

Feature Request: Support for Rust #6

Closed Dyllanjrusher closed 1 year ago

Dyllanjrusher commented 1 year ago

Howdy, How much of an undertaking do you think it'd be to do the same thing for rust? I think that'd be a nice addition to codesherpa.

iamgreggarcia commented 1 year ago

Hi @Dyllanjrusher,

Thanks for the interest! I definitely want to add support for multiple languages. I can add a build stage for Rust to the Dockerfile.

The next step is to enhance the localserver module, which runs locally using make dev (see here). The idea is to modify the /repl request body to accept a language argument. This would enable the support of multiple languages in a more generalized manner.

For example, instead of the current request body:

{
  "code": "import pandas as pd\nimport numpy as np\nnp.random.seed(0)\ndf = pd.DataFrame({'A': np.random.rand(100), 'B': np.random.rand(100)})\ndf['target'] = df['A'] + 2*df['B']\ndf.head()"
}

The new request body could look something like this:

{
  "code": "import pandas as pd\nimport numpy as np\nnp.random.seed(0)\ndf = pd.DataFrame({'A': np.random.rand(100), 'B': np.random.rand(100)})\ndf['target'] = df['A'] + 2*df['B']\ndf.head()",
  "language": "python310"
}

For Rust specifically:

{
  "code": "fn main() {\nprintln!(\"Hello, world!\");\n}",
  "language": "rust"
}

This adjustment aligns with my plan for the production version. I'm considering using a service like JDoodle for actual code execution as their API takes a similar request body.

Please note that the production version of codesherpa won't have persistence between API calls or ephemeral disk space. Adding this feature, while highly beneficial, is a significant challenge. But it would be a fun challenge!

Regarding the timeline, it's still under planning. Please subscribe to this issue for updates. I'll share a more detailed plan once it's ready.

iamgreggarcia commented 1 year ago

@Dyllanjrusher I added Rust as a supported language. You can read the updated Quickstart instructions to try it out!