open-index/open-npm huggingface dataset:
npm package: @juananpe/snippet-hint-command
Description: A snippet that provides a hint command to provide MongoDB query expressions based on natural language instructions
Latest version: 0.0.5

# Hint Command Snippet

This snippet adds a `hint` command to mongosh that provides helpful suggestions or recommendations for MongoDB-related tasks. The query results are generated using Groq API.

## Prerequisites

```
export GROQ_API_KEY=gsk_XXXXXXX
```

## Usage

After installing the snippet, you can use the `hint` command in your MongoDB shell like this:

```javascript
hint("very briefly, just the command, do not use markdown: in mongosh how to get the collections names of current db?");
```

This will output a possible solution to your query, such as `db.getCollectionNames()`.

## Installation

You can install this snippet using the `snippet` command in mongosh:

```javascript
snippet install hint-command
```

## License

This snippet is licensed under the Apache-2.0 license.
npm package: @juananpe/snippet-llm-command
Description: A snippet that provides an llm command to ask for MongoDB query expressions based on natural language instructions. Describe what MongoDB query you want to run and the llm command will answer you with a proposal based on Groq LLM API or any other local mo
Author: Juanan Pereira
Latest version: 0.0.7

# LLM Command Snippet

This snippet adds an `llm` command to mongosh that provides helpful suggestions or recommendations for MongoDB-related tasks. The query results are generated using Groq API by default, with an option to use other models via Ollama.

## Prerequisites

```
export GROQ_API_KEY=gsk_XXXXXXX
mongosh
config.set('snippetIndexSourceURLs', 'https://github.com/juananpe/mongosh-snippets/raw/main/index.bson.br;' + config.get('snippetIndexSourceURLs') )
```

## Usage

After installing the snippet, you can use the `llm` command in your MongoDB shell like this:

```javascript
llm("very briefly, just the command, do not use markdown: in mongosh how to get the collections names of current db?");
```

This will output a possible solution to your query, such as `db.getCollectionNames()`.

```javascript
llm("very briefly, just the command, do not use markdown: in mongosh replace all documents of a collection with property {'set':'llm102'} with the new value {'set':'llm101'} in current db?")
```

This will output a possible solution to your query, such as `db.collection.updateMany({ set: 'llm102' }, { $set: { set: 'llm101' } })`.

You can also specify a different model to use with an optional parameter:
```javascript 
llm("Your query here", { model: "phi3.5" });
```
This will use the specified model (in this case, 'phi3.5') via Ollama instead of the default Groq API.

## Models

By default, the `llm` command uses the Groq API with the 'llama-3.1-70b-versatile' model. You can use other models by specifying them in the optional parameter:

- Groq API (default): No need to specify, just use `llm("Your query")`.
- Ollama models: Specify the model name, e.g., `llm("Your query", { model: "gemini2" })` or `llm("Your query", { model: "phi3.5" })`.

Note: When using Ollama models, make sure you have Ollama running locally on the default port (11434).


## Installation

You can install this snippet using the `snippet` command in mongosh:

```javascript
snippet install llm-command
```

## Troubleshooting

If you get the error:
```
"Error: Cannot find module 'groq-sdk'"
```
then, go to your $USER/.mongodb/mongosh/snippets/node_modules/@juananpe/snippets-llm-command folder
and run `npm install`. Then close and open mongosh again.


## License

This snippet is licensed under the Apache-2.0 license.