Skip to content

Commit

Permalink
Fix for new models
Browse files Browse the repository at this point in the history
  • Loading branch information
tristandostaler authored Sep 24, 2024
1 parent 01bba3f commit 221e4dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
24 changes: 16 additions & 8 deletions src/hooks/useSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,25 @@ const useSubmit = () => {
if (typeof curr === 'string') {
partial += curr;
} else {
if (curr.choices[0].delta.function_call?.name) {
fnName += curr.choices[0].delta.function_call?.name;
if (!isFunctionCall) {
isFunctionCall = true;
output += " Plugin call requested. Loading..."
var content = undefined;
if(curr.choices[0].delta) {
if (curr.choices[0].delta.function_call?.name) {
fnName += curr.choices[0].delta.function_call?.name;
if (!isFunctionCall) {
isFunctionCall = true;
output += " Plugin call requested. Loading..."
}
}
if (curr.choices[0].delta.function_call?.arguments) {
fnArgs += curr.choices[0].delta.function_call?.arguments;
}

content = curr.choices[0].delta.content
}
if (curr.choices[0].delta.function_call?.arguments) {
fnArgs += curr.choices[0].delta.function_call?.arguments;
if(curr.choices[0].message) {
content = curr.choices[0].message.content
}
const content = curr.choices[0].delta.content;

if (content) output += content;
}
return output;
Expand Down
7 changes: 6 additions & 1 deletion src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ export interface EventSourceDataInterface {
export type EventSourceData = EventSourceDataInterface | '[DONE]';

export interface EventSourceDataChoices {
delta: {
delta?: {
content?: string;
function_call?: {
name: string;
arguments: string;
}
role?: string;
};
message?: {
role: string;
content: string;
refusal?: {};
}
finish_reason?: string;
index: number;
}
Expand Down

0 comments on commit 221e4dc

Please sign in to comment.