Skip to content

Commit

Permalink
feat: integrated localai
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomeowww committed Jan 6, 2025
1 parent 7373db8 commit 9120bf2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/providers/src/providers/localai.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { ChatProvider, EmbedProvider, ModelProvider, ProviderOptions, ProviderResult } from '../types'

import { generateCRO } from '../utils/generate-cro'

export const createLocalAI = (userOptions?: ProviderOptions<false>):
/** @see {@link https://localai.io/model-compatibility/} */
ChatProvider<({} & string)>
& EmbedProvider<({} & string)>
& ModelProvider => {
const options: ProviderResult = {
...userOptions,
baseURL: userOptions?.baseURL ?? new URL('http://localhost:8080/v1/'),
}

const result = (model: string) => generateCRO(model, options)

return {
chat: result,
embed: result,
model: () => options,
}
}

export const localAI = createLocalAI()

0 comments on commit 9120bf2

Please sign in to comment.