maintainence love
This commit is contained in:
parent
61a9915846
commit
b1fe264355
@ -130,6 +130,7 @@ When creating content
|
||||
### Initialize folder
|
||||
|
||||
```kbot init```
|
||||
|
||||
# Command Line Parameters
|
||||
|
||||
This document describes all available command line parameters.
|
||||
|
||||
66
packages/osr-code-bot/dist/README.md
vendored
66
packages/osr-code-bot/dist/README.md
vendored
@ -1,4 +1,4 @@
|
||||
# @plastichub/code-bot
|
||||
# @plastichub/kbot
|
||||
|
||||
AI-powered command-line tool for code modifications and project management that supports multiple AI models and routers.
|
||||
|
||||
@ -42,7 +42,7 @@ KBot supports both OpenRouter and OpenAI APIs. You'll need at least one of these
|
||||
### Installation using Node NPM package manager
|
||||
|
||||
```bash
|
||||
npm install -g @plastichub/code-bot
|
||||
npm install -g @plastichub/kbot
|
||||
```
|
||||
|
||||
## Configuration
|
||||
@ -78,6 +78,9 @@ Create configuration at `$HOME/.osr/.config.json` (or export OSR_CONFIG with pat
|
||||
"serpapi": {
|
||||
"key": "your SerpAPI key (optional, used for web searches(places, google maps))"
|
||||
},
|
||||
"deepseek": {
|
||||
"key": "your SerpAPI key (optional, used for web searches(places, google maps))"
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
@ -106,6 +109,28 @@ When creating content
|
||||
- always add links
|
||||
- when sending emails, always add 'Best regards, [Your Name]'
|
||||
```
|
||||
## Commands
|
||||
|
||||
### Prompt
|
||||
|
||||
```kbot "create Astro minimal boilerplate, use starlight theme. Install dependencies via NPM tool"```
|
||||
|
||||
### Fetch latest models
|
||||
|
||||
```kbot fetch```
|
||||
|
||||
### Print examples
|
||||
|
||||
```kbot examples```
|
||||
|
||||
### Print extended help
|
||||
|
||||
```kbot help-md```
|
||||
|
||||
### Initialize folder
|
||||
|
||||
```kbot init```
|
||||
|
||||
# Command Line Parameters
|
||||
|
||||
This document describes all available command line parameters.
|
||||
@ -117,11 +142,18 @@ This document describes all available command line parameters.
|
||||
| `path` | Target directory | `.` | No |
|
||||
| `prompt` | The prompt. Supports file paths and environment variables | `./prompt.md` | No |
|
||||
| `output` | Optional output path for modified files (Tool mode only) | - | No |
|
||||
| `dst` | Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path. Used for "completion" mode | - | No |
|
||||
| `dst` | Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path. | - | No |
|
||||
| `model` | AI model to use for processing | `anthropic/claude-3.5-sonnet` | No |
|
||||
| `router` | Router to use: openai or openrouter | `openrouter` | No |
|
||||
| `mode` | Chat completion mode: "completion" (without tools) or "tools" | `tools` | No |
|
||||
|
||||
## Advanced Parameters
|
||||
|
||||
| Parameter | Description | Default | Required |
|
||||
|-----------|-------------|---------|----------|
|
||||
| `each` | Target directory | `.` | No |
|
||||
| `dry` | Dry run - only write out parameters without making API calls | `false` | No |
|
||||
|
||||
## File Selection & Tools
|
||||
|
||||
| Parameter | Description | Default | Required |
|
||||
@ -146,35 +178,7 @@ This document describes all available command line parameters.
|
||||
| `logLevel` | Logging level for the application (0-4) | `2` | No |
|
||||
| `logs` | Logging directory | `./.kbot` | No |
|
||||
| `dump` | Create a script | - | No |
|
||||
| `dry` | Dry run - only write out parameters without making API calls | `false` | No |
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
# Basic usage with default parameters
|
||||
kbot --prompt="What are the changes needed?"
|
||||
|
||||
# Specify model and router
|
||||
kbot --model="gpt-4" --router="openai" --prompt="Analyze this code"
|
||||
|
||||
# Process specific files
|
||||
kbot --include="src/*.ts" --include="package.json" --prompt="Check for security issues"
|
||||
|
||||
# Dry run with custom logging
|
||||
kbot --dry=true --logLevel=4 --prompt="Test run"
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Many path-based parameters support environment variables using the `${VARIABLE}` syntax:
|
||||
|
||||
- `${POLYMECH-ROOT}` - Root directory for Polymech
|
||||
- `${OSR-ROOT}` - Root directory for OSR
|
||||
|
||||
Example:
|
||||
```bash
|
||||
kbot --profile="${POLYMECH-ROOT}/custom-profile.json"
|
||||
```
|
||||
|
||||
# Working on Larger Directories
|
||||
|
||||
|
||||
4
packages/osr-code-bot/dist/package-lock.json
generated
vendored
4
packages/osr-code-bot/dist/package-lock.json
generated
vendored
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@plastichub/kbot",
|
||||
"version": "1.1.9",
|
||||
"version": "1.1.12",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@plastichub/kbot",
|
||||
"version": "1.1.9",
|
||||
"version": "1.1.12",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-emoji": "^2.2.0"
|
||||
|
||||
2
packages/osr-code-bot/dist/package.json
vendored
2
packages/osr-code-bot/dist/package.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@plastichub/kbot",
|
||||
"version": "1.1.9",
|
||||
"version": "1.1.12",
|
||||
"main": "main_node.js",
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,30 +1,6 @@
|
||||
{
|
||||
"timestamp": 1738438200064,
|
||||
"timestamp": 1739276098767,
|
||||
"models": [
|
||||
{
|
||||
"id": "gpt-4o-audio-preview-2024-10-01",
|
||||
"object": "model",
|
||||
"created": 1727389042,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-mini-audio-preview",
|
||||
"object": "model",
|
||||
"created": 1734387424,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-mini-audio-preview-2024-12-17",
|
||||
"object": "model",
|
||||
"created": 1734115920,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-mini-realtime-preview",
|
||||
"object": "model",
|
||||
"created": 1734387380,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "dall-e-2",
|
||||
"object": "model",
|
||||
@ -32,23 +8,17 @@
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-mini",
|
||||
"id": "o1-mini-2024-09-12",
|
||||
"object": "model",
|
||||
"created": 1721172741,
|
||||
"created": 1725648979,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-mini-2024-07-18",
|
||||
"id": "gpt-4o-mini-realtime-preview-2024-12-17",
|
||||
"object": "model",
|
||||
"created": 1721172717,
|
||||
"created": 1734112601,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo",
|
||||
"object": "model",
|
||||
"created": 1677610602,
|
||||
"owned_by": "openai"
|
||||
},
|
||||
{
|
||||
"id": "o1-preview-2024-09-12",
|
||||
"object": "model",
|
||||
@ -56,9 +26,9 @@
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo-0125",
|
||||
"id": "o1-mini",
|
||||
"object": "model",
|
||||
"created": 1706048358,
|
||||
"created": 1725649008,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
@ -68,15 +38,21 @@
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "text-embedding-ada-002",
|
||||
"id": "gpt-4o-mini-realtime-preview",
|
||||
"object": "model",
|
||||
"created": 1671217299,
|
||||
"owned_by": "openai-internal"
|
||||
"created": 1734387380,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "o1-mini-2024-09-12",
|
||||
"id": "gpt-4o-mini-audio-preview-2024-12-17",
|
||||
"object": "model",
|
||||
"created": 1725648979,
|
||||
"created": 1734115920,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "chatgpt-4o-latest",
|
||||
"object": "model",
|
||||
"created": 1723515131,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
@ -86,16 +62,22 @@
|
||||
"owned_by": "openai-internal"
|
||||
},
|
||||
{
|
||||
"id": "dall-e-3",
|
||||
"id": "gpt-4-turbo",
|
||||
"object": "model",
|
||||
"created": 1698785189,
|
||||
"created": 1712361441,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4",
|
||||
"id": "gpt-4-turbo-preview",
|
||||
"object": "model",
|
||||
"created": 1687882411,
|
||||
"owned_by": "openai"
|
||||
"created": 1706037777,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-mini-audio-preview",
|
||||
"object": "model",
|
||||
"created": 1734387424,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "babbage-002",
|
||||
@ -103,12 +85,6 @@
|
||||
"created": 1692634615,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4-1106-preview",
|
||||
"object": "model",
|
||||
"created": 1698957206,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "omni-moderation-latest",
|
||||
"object": "model",
|
||||
@ -128,15 +104,27 @@
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-2024-05-13",
|
||||
"id": "gpt-4o-audio-preview-2024-12-17",
|
||||
"object": "model",
|
||||
"created": 1715368132,
|
||||
"created": 1734034239,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-2024-08-06",
|
||||
"id": "gpt-4o-audio-preview",
|
||||
"object": "model",
|
||||
"created": 1722814719,
|
||||
"created": 1727460443,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "text-embedding-3-large",
|
||||
"object": "model",
|
||||
"created": 1705953180,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-2024-05-13",
|
||||
"object": "model",
|
||||
"created": 1715368132,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
@ -145,36 +133,6 @@
|
||||
"created": 1699046015,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o",
|
||||
"object": "model",
|
||||
"created": 1715367049,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo-instruct",
|
||||
"object": "model",
|
||||
"created": 1692901427,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo-instruct-0914",
|
||||
"object": "model",
|
||||
"created": 1694122472,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4-0613",
|
||||
"object": "model",
|
||||
"created": 1686588896,
|
||||
"owned_by": "openai"
|
||||
},
|
||||
{
|
||||
"id": "chatgpt-4o-latest",
|
||||
"object": "model",
|
||||
"created": 1723515131,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-2024-11-20",
|
||||
"object": "model",
|
||||
@ -182,9 +140,9 @@
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4-turbo",
|
||||
"id": "gpt-4-turbo-2024-04-09",
|
||||
"object": "model",
|
||||
"created": 1712361441,
|
||||
"created": 1712601677,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
@ -193,6 +151,12 @@
|
||||
"created": 1681940951,
|
||||
"owned_by": "openai-internal"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo-16k",
|
||||
"object": "model",
|
||||
"created": 1683758102,
|
||||
"owned_by": "openai-internal"
|
||||
},
|
||||
{
|
||||
"id": "tts-1-1106",
|
||||
"object": "model",
|
||||
@ -205,36 +169,6 @@
|
||||
"created": 1692634301,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4-turbo-preview",
|
||||
"object": "model",
|
||||
"created": 1706037777,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-mini-realtime-preview-2024-12-17",
|
||||
"object": "model",
|
||||
"created": 1734112601,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-audio-preview",
|
||||
"object": "model",
|
||||
"created": 1727460443,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "text-embedding-3-small",
|
||||
"object": "model",
|
||||
"created": 1705948997,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4-turbo-2024-04-09",
|
||||
"object": "model",
|
||||
"created": 1712601677,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo-1106",
|
||||
"object": "model",
|
||||
@ -242,27 +176,33 @@
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-realtime-preview-2024-10-01",
|
||||
"id": "gpt-4o-mini",
|
||||
"object": "model",
|
||||
"created": 1727131766,
|
||||
"created": 1721172741,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo-16k",
|
||||
"id": "gpt-3.5-turbo-instruct",
|
||||
"object": "model",
|
||||
"created": 1683758102,
|
||||
"owned_by": "openai-internal"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-audio-preview-2024-12-17",
|
||||
"object": "model",
|
||||
"created": 1734034239,
|
||||
"created": 1692901427,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "text-embedding-3-large",
|
||||
"id": "dall-e-3",
|
||||
"object": "model",
|
||||
"created": 1705953180,
|
||||
"created": 1698785189,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo-instruct-0914",
|
||||
"object": "model",
|
||||
"created": 1694122472,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo-0125",
|
||||
"object": "model",
|
||||
"created": 1706048358,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
@ -271,12 +211,30 @@
|
||||
"created": 1733945430,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-3.5-turbo",
|
||||
"object": "model",
|
||||
"created": 1677610602,
|
||||
"owned_by": "openai"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-realtime-preview",
|
||||
"object": "model",
|
||||
"created": 1727659998,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-mini-2024-07-18",
|
||||
"object": "model",
|
||||
"created": 1721172717,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "text-embedding-3-small",
|
||||
"object": "model",
|
||||
"created": 1705948997,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4-0125-preview",
|
||||
"object": "model",
|
||||
@ -284,9 +242,51 @@
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "o1-mini",
|
||||
"id": "gpt-4",
|
||||
"object": "model",
|
||||
"created": 1725649008,
|
||||
"created": 1687882411,
|
||||
"owned_by": "openai"
|
||||
},
|
||||
{
|
||||
"id": "text-embedding-ada-002",
|
||||
"object": "model",
|
||||
"created": 1671217299,
|
||||
"owned_by": "openai-internal"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4-1106-preview",
|
||||
"object": "model",
|
||||
"created": 1698957206,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-audio-preview-2024-10-01",
|
||||
"object": "model",
|
||||
"created": 1727389042,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-2024-08-06",
|
||||
"object": "model",
|
||||
"created": 1722814719,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o",
|
||||
"object": "model",
|
||||
"created": 1715367049,
|
||||
"owned_by": "system"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4-0613",
|
||||
"object": "model",
|
||||
"created": 1686588896,
|
||||
"owned_by": "openai"
|
||||
},
|
||||
{
|
||||
"id": "gpt-4o-realtime-preview-2024-10-01",
|
||||
"object": "model",
|
||||
"created": 1727131766,
|
||||
"owned_by": "system"
|
||||
}
|
||||
]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -26,7 +26,7 @@
|
||||
},
|
||||
"each": {
|
||||
"type": "string",
|
||||
"description": "Iterate over items, supported GLOB | Path to JSON File | array of strings (comma separated). To test different models, use --each=\"gpt-3.5-turbo,gpt-4o\", the actual string will exposed as variable `ITEM`, eg: --dst=${ITEM}-output.md"
|
||||
"description": "Iterate over items, supported: GLOB | Path to JSON File | array of strings (comma separated). To test different models, use --each=\"gpt-3.5-turbo,gpt-4o\", the actual string will exposed as variable `ITEM`, eg: --dst=\"${ITEM}-output.md\""
|
||||
},
|
||||
"disable": {
|
||||
"type": "array",
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
"ui:title": "Dst"
|
||||
},
|
||||
"each": {
|
||||
"ui:description": "Iterate over items, supported GLOB | Path to JSON File | array of strings (comma separated). To test different models, use --each=\"gpt-3.5-turbo,gpt-4o\", the actual string will exposed as variable `ITEM`, eg: --dst=${ITEM}-output.md",
|
||||
"ui:description": "Iterate over items, supported: GLOB | Path to JSON File | array of strings (comma separated). To test different models, use --each=\"gpt-3.5-turbo,gpt-4o\", the actual string will exposed as variable `ITEM`, eg: --dst=\"${ITEM}-output.md\"",
|
||||
"ui:title": "Each"
|
||||
},
|
||||
"disable": {
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
npm run webpack
|
||||
kbotd types
|
||||
kbotd fetch
|
||||
sh scripts/update-readme.sh
|
||||
cp README.md dist/README.md
|
||||
cd dist
|
||||
npm version patch
|
||||
npm publish
|
||||
cd ..
|
||||
git commit -m "maintainence love:)" .
|
||||
@ -3,58 +3,90 @@ import { logger } from './index'
|
||||
import { loadConfig } from './config'
|
||||
import { IKBotOptions } from './zod_types'
|
||||
|
||||
/**
|
||||
* Router types supported by the client
|
||||
*/
|
||||
type RouterType = 'openrouter' | 'openai' | 'deepseek' | 'huggingface';
|
||||
|
||||
/**
|
||||
* Default base URLs for different routers
|
||||
*/
|
||||
const ROUTER_BASE_URLS: Record<RouterType, string> = {
|
||||
openrouter: 'https://openrouter.ai/api/v1',
|
||||
openai: '', // OpenAI uses default URL
|
||||
deepseek: 'https://api.deepseek.com',
|
||||
huggingface: 'https://api-inference.huggingface.co'
|
||||
};
|
||||
|
||||
/**
|
||||
* Default models for different routers
|
||||
*/
|
||||
const DEFAULT_MODETS: Record<RouterType, string> = {
|
||||
openrouter: 'anthropic/claude-3.5-sonnet',
|
||||
openai: 'gpt-4o',
|
||||
deepseek: 'deepseek-chat',
|
||||
huggingface: 'meta-llama/2'
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an OpenAI client instance based on the provided options.
|
||||
* @param options - Configuration options for the client
|
||||
* @returns OpenAI client instance or undefined if configuration is invalid
|
||||
*/
|
||||
export const createClient = (options: IKBotOptions) => {
|
||||
// Load configuration from file
|
||||
const config = loadConfig(options)
|
||||
let apiKey: string = options.api_key
|
||||
if (!config) {
|
||||
logger.error(
|
||||
"Config not found in $HOME/.osr/config.json. " +
|
||||
"Optionally, export OSR_CONFIG with the path to the configuration file, "
|
||||
);
|
||||
return undefined
|
||||
return undefined;
|
||||
}
|
||||
const router = options.router ?? "openrouter"
|
||||
let baseURL = options.baseURL
|
||||
if (!options.baseURL) {
|
||||
|
||||
// Determine router to use (defaults to 'openrouter')
|
||||
const router: RouterType = (options.router ?? 'openrouter') as RouterType;
|
||||
|
||||
// Initialize API key and baseURL
|
||||
let apiKey = options.api_key;
|
||||
|
||||
// Set API key based on router if not provided in options
|
||||
if (!apiKey) {
|
||||
switch (router) {
|
||||
case "openrouter":
|
||||
apiKey = apiKey || config?.openrouter?.key;
|
||||
if (!options.baseURL) {
|
||||
baseURL = "https://openrouter.ai/api/v1"
|
||||
}
|
||||
case 'openrouter':
|
||||
apiKey = config?.openrouter?.key;
|
||||
break;
|
||||
case "openai":
|
||||
apiKey = apiKey || config?.openai?.key;
|
||||
case 'openai':
|
||||
apiKey = config?.openai?.key;
|
||||
break;
|
||||
case "deepseek":
|
||||
apiKey = apiKey || config?.deepseek?.key;
|
||||
if (!options.baseURL) {
|
||||
baseURL = "https://api.deepseek.com"
|
||||
}
|
||||
case 'deepseek':
|
||||
apiKey = config?.deepseek?.key;
|
||||
break;
|
||||
case 'huggingface':
|
||||
apiKey = config?.huggingface?.key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate API key
|
||||
if (!apiKey) {
|
||||
logger.error(`No ${router} key found. Please provide an "api_key", set it in the config, or pass it via JSON config.`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (router === "openrouter" && !options.model) {
|
||||
options.model = "anthropic/claude-3.5-sonnet"
|
||||
// Set default baseURL if not provided
|
||||
const baseURL = options.baseURL ?? ROUTER_BASE_URLS[router];
|
||||
|
||||
// Set default model if not provided
|
||||
if (!options.model) {
|
||||
options.model = DEFAULT_MODELS[router];
|
||||
}
|
||||
|
||||
if (router === "openai" && !options.model) {
|
||||
options.model = "gpt-4o"
|
||||
}
|
||||
logger.info(`Creating client with ${router} router, model ${options.model}, and API key ${apiKey} at ${baseURL}`);
|
||||
|
||||
if (router === "deepseek" && !options.model) {
|
||||
options.model = "deepseek-chat"
|
||||
}
|
||||
|
||||
logger.info(`Creating client with ${router} router, model ${options.model}, and API key ${apiKey} at ${baseURL}`)
|
||||
// Create and return the OpenAI client instance
|
||||
return new OpenAI({
|
||||
apiKey,
|
||||
baseURL,
|
||||
})
|
||||
});
|
||||
}
|
||||
@ -7,7 +7,7 @@ export interface IKBotOptions {
|
||||
output?: string | undefined;
|
||||
/** Optional destination path for the result, will substitute ${MODEL_NAME} and ${ROUTER} in the path. Optional, used for "completion" mode */
|
||||
dst?: string | undefined;
|
||||
/** Iterate over items, supported GLOB | Path to JSON File | array of strings (comma separated). To test different models, use --each="gpt-3.5-turbo,gpt-4o", the actual string will exposed as variable `ITEM`, eg: --dst=${ITEM}-output.md */
|
||||
/** Iterate over items, supported: GLOB | Path to JSON File | array of strings (comma separated). To test different models, use --each="gpt-3.5-turbo,gpt-4o", the actual string will exposed as variable `ITEM`, eg: --dst="${ITEM}-output.md" */
|
||||
each?: string | undefined;
|
||||
/** Disable tools categories, eg: --disable=fs,git,interact,terminal,search,web,email,user */
|
||||
disable?: string[];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user