ITADN

Refactoring of AI Assistant Code

#8Closedwilliamcotton 创建于 2024-07-31
W
williamcottoncommented
The current approach for integrating with multiple AI Assistants looks like this: ```ts const updatedChatHistory = [ ...store.chatHistory, contextMessage, ...outputMessages, newMessage, ]; await AiAssistants.run(store, electronApi, updatedChatHistory); ``` It seems as if a better interface would be to have `AiAssistants.run` return a `ChatCompletionMessageParam[]` instead of passing in and operating on `updatedChatHistory` as a reference. This would make the functionality of the code more apparent in the future. The `AiAssistants.run` function would still need to be called in the same order but then we could do something like: ```ts const updatedAssistedChatHistory = await AiAssistants.run(store, electronApi, updatedChatHistory); try { const response = await electronApi.chatCompletionsCreate( updatedAssistedChatHistory ); ``` Please refactor the code to support this more functional and immutable approach.
关闭于 2024-08-01 0 条评论