🐛 fix lm studio bug when empty messages are sent
This commit is contained in:
parent
38151b84ad
commit
8b9e99a8a1
1 changed files with 10 additions and 4 deletions
|
|
@ -178,6 +178,15 @@ class OpenAI extends BaseLLM {
|
|||
return;
|
||||
}
|
||||
|
||||
let body = {
|
||||
...this._convertArgs(options, messages),
|
||||
stream: true,
|
||||
};
|
||||
// Empty messages cause an error in LM Studio
|
||||
body.messages = body.messages.map((m) => ({
|
||||
...m,
|
||||
content: m.content === "" ? " " : m.content,
|
||||
})) as any;
|
||||
const response = await this.fetch(this._getChatUrl(), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
@ -185,10 +194,7 @@ class OpenAI extends BaseLLM {
|
|||
Authorization: `Bearer ${this.apiKey}`,
|
||||
"api-key": this.apiKey || "", // For Azure
|
||||
},
|
||||
body: JSON.stringify({
|
||||
...this._convertArgs(options, messages),
|
||||
stream: true,
|
||||
}),
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
for await (const value of streamSse(response)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue