TTS
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {OpenAI as openAI} from 'openai';
|
||||
import {findByProp, objectMap, JSONSanitize, JSONAttemptParse} from '@ztimson/utils';
|
||||
import {Ai} from './ai.ts';
|
||||
import {AbortablePromise, Ai} from './ai.ts';
|
||||
import {LLMMessage, LLMRequest} from './llm.ts';
|
||||
import {AbortablePromise, LLMProvider} from './provider.ts';
|
||||
import {LLMProvider} from './provider.ts';
|
||||
|
||||
export class OpenAi extends LLMProvider {
|
||||
client!: openAI;
|
||||
@@ -116,6 +116,7 @@ export class OpenAi extends LLMProvider {
|
||||
history.push(resp.choices[0].message);
|
||||
const results = await Promise.all(toolCalls.map(async (toolCall: any) => {
|
||||
const tool = tools?.find(findByProp('name', toolCall.function.name));
|
||||
if(options.stream) options.stream({tool: toolCall.function.name});
|
||||
if(!tool) return {role: 'tool', tool_call_id: toolCall.id, content: '{"error": "Tool not found"}'};
|
||||
try {
|
||||
const args = JSONAttemptParse(toolCall.function.arguments, {});
|
||||
|
||||
Reference in New Issue
Block a user