-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from miurla/provider
Refactor AI model usage
- Loading branch information
Showing
8 changed files
with
36 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
import { type ClassValue, clsx } from 'clsx' | ||
import { twMerge } from 'tailwind-merge' | ||
import { OpenAI } from '@ai-sdk/openai' | ||
import { createGoogleGenerativeAI } from '@ai-sdk/google' | ||
import { createAnthropic } from '@ai-sdk/anthropic' | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)) | ||
} | ||
|
||
export function getModel() { | ||
// Currently does not work with Google or Anthropic | ||
// if (process.env.GOOGLE_GENERATIVE_AI_API_KEY) { | ||
// const google = createGoogleGenerativeAI() | ||
// return google('models/gemini-1.5-pro-latest') | ||
// } | ||
|
||
// if (process.env.ANTHROPIC_API_KEY) { | ||
// const anthropic = createAnthropic() | ||
// return anthropic('claude-3-haiku-20240307') | ||
// } | ||
|
||
const openai = new OpenAI({ | ||
baseUrl: process.env.OPENAI_API_BASE, // optional base URL for proxies etc. | ||
apiKey: process.env.OPENAI_API_KEY, // optional API key, default to env property OPENAI_API_KEY | ||
organization: '' // optional organization | ||
}) | ||
return openai.chat(process.env.OPENAI_API_MODEL || 'gpt-4o') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters