Updated Install Engines page with correct commands

This commit is contained in:
Ashley 2025-01-14 17:32:03 +07:00
parent 1cf9e0ec24
commit 389d83eeea

View File

@ -97,50 +97,63 @@ Let's say you have a custom API with this format:
} }
``` ```
Here's how to set it up in Jan: **Here's how to set it up in Jan:**
``` ```
Engine Name: Custom LLM Engine Name: Custom LLM
API URL: https://api.customllm.com
API Key: your_api_key_here API Key: your_api_key_here
Header template: your header template here
Transform request template: your transform request template here
Transform response template: your transform response template here
``` ```
**Conversion Functions:** 1. Header template
> - Request: Convert from Jan's OpenAI-style format to your API's format ```
> - Response: Convert from your API's format back to OpenAI-style format "Authorization: Bearer {{api_key}}"
```
1. Request Format Conversion: 2. Transform request template:
```javascript Convert from Jan's OpenAI-style format to your API's format
function convertRequest(janRequest) { ```
return { "chat_completions": {
prompt: janRequest.messages[janRequest.messages.length - 1].content, "url": "https://api.custom_endpoint.com/v1/messages",
max_length: janRequest.max_tokens || 100, "template": "{
temperature: janRequest.temperature || 0.7 {% for key, value in input_request %}
} {% if key == "messages" %}
"prompt": "{{ last(input_request.messages).content }}"
{% else if key == "max_tokens" or key == "temperature" %}
"{{ key }}": {{ tojson(value) }}
{% endif %}
{% endfor %}
}"
} }
``` ```
2. Response Format Conversion:
```javascript 3. Transform response template
function convertResponse(apiResponse) { Convert from your API's format back to OpenAI-style format
return { ```
choices: [{ "chat_completions": {
message: { "template": "{
role: "assistant", {
content: apiResponse.generated_text "choices": [{
"message": {
"role": "assistant",
"content": "{{ input_request.generated_text }}"
} }
}], }],
usage: { "usage": {
total_tokens: apiResponse.tokens_used "total_tokens": {{ input_request.tokens_used }}
} }
} }
}"
} }
``` ```
**Expected Formats:** **Expected Formats:**
1. Jan's Request Format 1. Jan's Request Format
```javascript ```
{ {
"messages": [ "messages": [
{"role": "user", "content": "What is AI?"} {"role": "user", "content": "What is AI?"}
@ -151,7 +164,7 @@ function convertResponse(apiResponse) {
``` ```
2. Jan's Expected Response Format 2. Jan's Expected Response Format
```javascript ```
{ {
"choices": [{ "choices": [{
"message": { "message": {