feat: add self-mention filtering to prevent reply loops
docs: update default model and examples in README
This commit is contained in:
parent
eca01e8427
commit
1411a9164b
@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Version 0.2.0 - 2025-12-20
|
||||||
|
|
||||||
|
Adds self-mention filtering to prevent reply loops in the MentionBot. Updates the README with the new default model and revised examples.
|
||||||
|
|
||||||
|
**Changes:** 2 files, 30 lines
|
||||||
|
**Languages:** Markdown (9 lines), Other (21 lines)
|
||||||
|
|
||||||
## Version 0.1.0 - 2025-12-20
|
## Version 0.1.0 - 2025-12-20
|
||||||
|
|
||||||
Adds persistent state management for mention processing, ensuring continuity across application restarts.
|
Adds persistent state management for mention processing, ensuring continuity across application restarts.
|
||||||
|
|||||||
@ -170,7 +170,7 @@ grokii spam -u USERNAME -p PASSWORD -c --debug -l spam.log
|
|||||||
|
|
||||||
| Option | Description | Default |
|
| Option | Description | Default |
|
||||||
|--------|-------------|---------|
|
|--------|-------------|---------|
|
||||||
| `--model` | OpenRouter model identifier | `x-ai/grok-3-fast-beta` |
|
| `--model` | OpenRouter model identifier | `x-ai/grok-code-fast-1` |
|
||||||
| `--system-prompt` | Custom AI personality prompt | Built-in |
|
| `--system-prompt` | Custom AI personality prompt | Built-in |
|
||||||
| `--max-tokens` | Maximum response length | `500` |
|
| `--max-tokens` | Maximum response length | `500` |
|
||||||
| `--temperature` | AI creativity (0.0-2.0) | `0.7` |
|
| `--temperature` | AI creativity (0.0-2.0) | `0.7` |
|
||||||
@ -200,6 +200,7 @@ Core mention-response logic:
|
|||||||
- Extracts question text by removing bot @mention
|
- Extracts question text by removing bot @mention
|
||||||
- Builds context from rant and recent comments
|
- Builds context from rant and recent comments
|
||||||
- Coordinates with OpenRouterClient for AI response
|
- Coordinates with OpenRouterClient for AI response
|
||||||
|
- Filters self-mentions from AI responses to prevent self-reply loops
|
||||||
- Posts formatted reply via devRant API
|
- Posts formatted reply via devRant API
|
||||||
|
|
||||||
#### OpenRouterClient.swift
|
#### OpenRouterClient.swift
|
||||||
@ -236,20 +237,20 @@ Async-safe logging:
|
|||||||
|
|
||||||
### Default Model
|
### Default Model
|
||||||
|
|
||||||
Grokii uses `x-ai/grok-3-fast-beta` by default - xAI's fast inference model optimized for quick, accurate responses.
|
Grokii uses `x-ai/grok-code-fast-1` by default - xAI's fast inference model optimized for quick, accurate responses.
|
||||||
|
|
||||||
### Alternative Models
|
### Alternative Models
|
||||||
|
|
||||||
Any OpenRouter-supported model can be used:
|
Any OpenRouter-supported model can be used:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
grokii chat -u USER -p PASS --model "anthropic/claude-3.5-sonnet"
|
grokii chat -u USER -p PASS --model "anthropic/claude-4.5-sonnet"
|
||||||
|
|
||||||
grokii chat -u USER -p PASS --model "openai/gpt-4o"
|
grokii chat -u USER -p PASS --model "openai/gpt-4o"
|
||||||
|
|
||||||
grokii chat -u USER -p PASS --model "meta-llama/llama-3.1-70b-instruct"
|
grokii chat -u USER -p PASS --model "meta-llama/llama-3.1-70b-instruct"
|
||||||
|
|
||||||
grokii chat -u USER -p PASS --model "google/gemini-pro-1.5"
|
grokii chat -u USER -p PASS --model "google/gemini-pro-2.5"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Temperature Settings
|
### Temperature Settings
|
||||||
|
|||||||
@ -201,8 +201,27 @@ actor MentionBot {
|
|||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func filterSelfMentions(from text: String) -> String {
|
||||||
|
guard let pattern = try? NSRegularExpression(
|
||||||
|
pattern: "@\(NSRegularExpression.escapedPattern(for: botUsername))",
|
||||||
|
options: [.caseInsensitive]
|
||||||
|
) else {
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
let range = NSRange(text.startIndex..., in: text)
|
||||||
|
return pattern.stringByReplacingMatches(
|
||||||
|
in: text,
|
||||||
|
options: [],
|
||||||
|
range: range,
|
||||||
|
withTemplate: ""
|
||||||
|
).replacingOccurrences(of: " ", with: " ")
|
||||||
|
.trimmingCharacters(in: .whitespaces)
|
||||||
|
}
|
||||||
|
|
||||||
private func postReply(rantId: Int, replyTo: String, response: String) async {
|
private func postReply(rantId: Int, replyTo: String, response: String) async {
|
||||||
let reply = "@\(replyTo) \(response)"
|
let filteredResponse = filterSelfMentions(from: response)
|
||||||
|
let reply = "@\(replyTo) \(filteredResponse)"
|
||||||
|
|
||||||
guard !dryRun else {
|
guard !dryRun else {
|
||||||
await logger.info("DRY RUN: Would post reply to rant \(rantId):\n\(reply)")
|
await logger.info("DRY RUN: Would post reply to rant \(rantId):\n\(reply)")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user