Skip to content

Commit

Permalink
reverse conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoedecke committed Sep 23, 2024
1 parent dbdebc4 commit d1b69de
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,21 @@ const server = createServer(async (request, response) => {
const event = createReferencesEvent([sseData]);
response.write(event);

// We should keep all optional parameters out of this call, so it can work for any model (in case we've
// just run the execute-model tool).
if (!["o1-mini", "o1-preview"].includes(args.model)) {
stream = await modelsAPI.inference.chat.completions.create({
model: functionCallRes.model,
messages: functionCallRes.messages,
stream: true
});
} else {
// for non-streaming models, we need to still stream the response back
if (["o1-mini", "o1-preview"].includes(args.model)) {
// for non-streaming models, we need to still stream the response back, so we build the stream ourselves
stream = (async function*() {
const result = await modelsAPI.inference.chat.completions.create({
model: functionCallRes.model,
messages: functionCallRes.messages
});
yield result;
})();
} else {
stream = await modelsAPI.inference.chat.completions.create({
model: functionCallRes.model,
messages: functionCallRes.messages,
stream: true
});
}
} else {
stream = await capiClient.chat.completions.create({
Expand Down

0 comments on commit d1b69de

Please sign in to comment.