Add README and make model configurable
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
# slm
|
||||||
|
|
||||||
|
A simple command-line tool to interact with an LLM API.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The tool reads its configuration from `~/.config/slm/config.toml`.
|
||||||
|
|
||||||
|
### Config File Format
|
||||||
|
|
||||||
|
```toml
|
||||||
|
api_key = "your_api_key_here"
|
||||||
|
server_url = "https://your-api-server.com/v1/chat/completions"
|
||||||
|
model = "nvidia/Gemma-4-31B-IT-NVFP4"
|
||||||
|
```
|
||||||
|
|
||||||
|
| Field | Description |
|
||||||
|
| :--- | :--- |
|
||||||
|
| `api_key` | Your API authentication key. |
|
||||||
|
| `server_url` | The full URL to the chat completions endpoint. |
|
||||||
|
| `model` | The identifier of the model to use. |
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
By default, `slm` reads from standard input and sends it to the configured model.
|
||||||
|
|
||||||
|
### Basic Example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "Hello, how are you?" | slm
|
||||||
|
```
|
||||||
|
|
||||||
|
### With a Prompt
|
||||||
|
|
||||||
|
You can append a specific prompt to the input using the `-p` or `--prompt` argument. This is useful for giving the model a persona or specific instructions.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "the capital of France" | slm -p "Answer in one word."
|
||||||
|
```
|
||||||
|
|
||||||
|
## Arguments
|
||||||
|
|
||||||
|
| Argument | Short | Description |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `--prompt <TEXT>` | `-p` | Optional prompt to append to the content read from stdin. |
|
||||||
+2
-1
@@ -15,6 +15,7 @@ struct Args {
|
|||||||
struct Config {
|
struct Config {
|
||||||
api_key: String,
|
api_key: String,
|
||||||
server_url: String,
|
server_url: String,
|
||||||
|
model: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
@@ -70,7 +71,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
// Construct the API request
|
// Construct the API request
|
||||||
let request_body = ChatRequest {
|
let request_body = ChatRequest {
|
||||||
model: "nvidia/Gemma-4-31B-IT-NVFP4".to_string(), // Default model
|
model: config.model.clone(),
|
||||||
messages: vec![Message {
|
messages: vec![Message {
|
||||||
role: "user".to_string(),
|
role: "user".to_string(),
|
||||||
content: final_content,
|
content: final_content,
|
||||||
|
|||||||
Reference in New Issue
Block a user