fix: add model parameter to LlamaCppClient requests
This commit is contained in:
@@ -24,6 +24,7 @@ describe('LlamaCppClient', () => {
|
|||||||
|
|
||||||
const client = new LlamaCppClient({
|
const client = new LlamaCppClient({
|
||||||
endpoint: 'http://localhost:8080',
|
endpoint: 'http://localhost:8080',
|
||||||
|
model: 'test-model',
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await client.chat({
|
const response = await client.chat({
|
||||||
@@ -64,6 +65,7 @@ describe('LlamaCppClient', () => {
|
|||||||
|
|
||||||
const client = new LlamaCppClient({
|
const client = new LlamaCppClient({
|
||||||
endpoint: 'http://localhost:8080',
|
endpoint: 'http://localhost:8080',
|
||||||
|
model: 'test-model',
|
||||||
});
|
});
|
||||||
|
|
||||||
const events: ChatStreamEvent[] = [];
|
const events: ChatStreamEvent[] = [];
|
||||||
@@ -87,6 +89,7 @@ describe('LlamaCppClient', () => {
|
|||||||
|
|
||||||
const client = new LlamaCppClient({
|
const client = new LlamaCppClient({
|
||||||
endpoint: 'http://localhost:8080',
|
endpoint: 'http://localhost:8080',
|
||||||
|
model: 'test-model',
|
||||||
});
|
});
|
||||||
|
|
||||||
await expect(client.chat({
|
await expect(client.chat({
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { ChatRequest, ChatResponse, ChatStreamEvent, ModelClient } from '..
|
|||||||
|
|
||||||
export interface LlamaCppClientConfig {
|
export interface LlamaCppClientConfig {
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
|
model: string;
|
||||||
authToken?: string;
|
authToken?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,10 +23,12 @@ interface LlamaCppStreamChunk {
|
|||||||
|
|
||||||
export class LlamaCppClient implements ModelClient {
|
export class LlamaCppClient implements ModelClient {
|
||||||
private endpoint: string;
|
private endpoint: string;
|
||||||
|
private model: string;
|
||||||
private authToken?: string;
|
private authToken?: string;
|
||||||
|
|
||||||
constructor(config: LlamaCppClientConfig) {
|
constructor(config: LlamaCppClientConfig) {
|
||||||
this.endpoint = config.endpoint.replace(/\/$/, '');
|
this.endpoint = config.endpoint.replace(/\/$/, '');
|
||||||
|
this.model = config.model;
|
||||||
this.authToken = config.authToken;
|
this.authToken = config.authToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +57,7 @@ export class LlamaCppClient implements ModelClient {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers,
|
headers,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
model: this.model,
|
||||||
messages,
|
messages,
|
||||||
max_tokens: request.maxTokens ?? 2048,
|
max_tokens: request.maxTokens ?? 2048,
|
||||||
}),
|
}),
|
||||||
@@ -106,6 +110,7 @@ export class LlamaCppClient implements ModelClient {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers,
|
headers,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
model: this.model,
|
||||||
messages,
|
messages,
|
||||||
max_tokens: request.maxTokens ?? 2048,
|
max_tokens: request.maxTokens ?? 2048,
|
||||||
stream: true,
|
stream: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user