...
This commit is contained in:
@@ -6,12 +6,13 @@ import incubaid.herolib.clients.openai
|
||||
import os
|
||||
import incubaid.herolib.core.playcmds
|
||||
|
||||
// models see https://console.groq.com/docs/models
|
||||
|
||||
playcmds.run(
|
||||
heroscript: '
|
||||
!!openai.configure name:"qroq"
|
||||
!!openai.configure name:"groq"
|
||||
url:"https://api.groq.com/openai/v1"
|
||||
model_default:"gpt-oss-120b"
|
||||
model_default:"openai/gpt-oss-120b"
|
||||
'
|
||||
reset: true
|
||||
)!
|
||||
@@ -25,4 +26,3 @@ response := client.chat_completion(
|
||||
)!
|
||||
|
||||
println(response.result)
|
||||
|
||||
|
||||
@@ -363,31 +363,6 @@ fn main() ! {
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration Details
|
||||
|
||||
Refer to `openai_model.v` for implementation details:
|
||||
|
||||
- **API Key Fallback Chain**: `api_key` → `AIKEY` → `OPENROUTER_API_KEY` / `GROQKEY`
|
||||
- **URL Fallback**: Defaults to OpenRouter if not specified
|
||||
- **Model Fallback**: Uses `AIMODEL` environment variable if not set
|
||||
- **Validation**: Ensures API key is present before returning client
|
||||
|
||||
## Error Handling
|
||||
|
||||
```v
|
||||
mut client := openai.get() or {
|
||||
eprintln('Failed to initialize client: ${err}')
|
||||
return
|
||||
}
|
||||
|
||||
response := client.chat_completion(
|
||||
message: 'Hello'
|
||||
) or {
|
||||
eprintln('API request failed: ${err}')
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
## Supported Providers
|
||||
|
||||
- **OpenAI** - `https://api.openai.com/v1`
|
||||
|
||||
Reference in New Issue
Block a user