Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ai sdk #323

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/api/search/google/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from '@ai-sdk/openai';
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_streamText, ExperimentalMessage, StreamingTextResponse, ToolCallPart, ToolResultPart } from 'ai';
import { createStreamableUI, createStreamableValue } from 'ai/rsc';

Expand Down Expand Up @@ -28,7 +28,7 @@ export async function POST(req: Request) {

const uiStream = createStreamableUI();

const openai = new OpenAI({
const openai = createOpenAI({
apiKey: config.provider?.apiKey ?? process.env.OPENAI_API_KEY ?? '',
baseUrl: config.provider?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});
Expand Down
4 changes: 2 additions & 2 deletions lib/provider/Anthropic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Anthropic } from '@ai-sdk/anthropic';
import { createAnthropic } from '@ai-sdk/anthropic';

export const anthropic = new Anthropic({
export const anthropic = createAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY ?? '',
});
4 changes: 2 additions & 2 deletions lib/provider/Google.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Google } from '@ai-sdk/google';
import { createGoogleGenerativeAI } from '@ai-sdk/google';

export const google = new Google({
export const google = createGoogleGenerativeAI({
apiKey: process.env.GOOGLE_API_KEY ?? '',
// baseURL: process.env.OPENAI_API_ENDPOINT ?? '',
});
4 changes: 2 additions & 2 deletions lib/provider/OpenAI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OpenAI } from '@ai-sdk/openai';
import { createOpenAI } from '@ai-sdk/openai';

export const openai = new OpenAI({
export const openai = createOpenAI({
Comment on lines +1 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (code_refinement): Check if createOpenAI supports all previous functionalities of OpenAI class.

apiKey: process.env.OPENAI_API_KEY ?? '',
// baseURL: process.env.OPENAI_API_ENDPOINT ?? '',
});
4 changes: 2 additions & 2 deletions lib/search/challenger.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from '@ai-sdk/openai';
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_generateObject, ExperimentalMessage } from 'ai';
import { z } from 'zod';

Expand All @@ -13,7 +13,7 @@ export const challengerSchema = z.object({
export const challenger = async (messages: ExperimentalMessage[], model: SimpleModel, currentProviderSettings: ProviderSetting | null) => {
'use server';

const openai = new OpenAI({
const openai = createOpenAI({
apiKey: currentProviderSettings?.OpenAI?.apiKey ?? process.env.OPENAI_API_KEY ?? '',
// baseURL: currentProviderSettings?.OpenAI?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});
Expand Down
4 changes: 2 additions & 2 deletions lib/search/clarifier.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from '@ai-sdk/openai';
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_streamObject, ExperimentalMessage } from 'ai';
import { createStreamableUI, createStreamableValue } from 'ai/rsc';
import { z } from 'zod';
Expand Down Expand Up @@ -26,7 +26,7 @@ export const clarifier = async (uiStream: ReturnType<typeof createStreamableUI>,

let clarifierResponse: TClarifier = {};

const openai = new OpenAI({
const openai = createOpenAI({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (code_refinement): Check consistency of API key and endpoint usage in createOpenAI across different settings.

apiKey: currentProviderSettings?.OpenAI?.apiKey ?? process.env.OPENAI_API_KEY ?? '',
// baseURL: currentProviderSettings?.OpenAI?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});
Expand Down
4 changes: 2 additions & 2 deletions lib/search/illustrator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from '@ai-sdk/openai';
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_streamObject, ExperimentalMessage } from 'ai';
import { createStreamableUI, createStreamableValue } from 'ai/rsc';
import { z } from 'zod';
Expand All @@ -20,7 +20,7 @@ export const illustrator = async (uiStream: ReturnType<typeof createStreamableUI

uiStream.append(<Related relatedQueries={objectStream.value} />);

const openai = new OpenAI({
const openai = createOpenAI({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (code_refinement): Validate that createOpenAI integrates seamlessly with UI components like uiStream.

apiKey: currentProviderSettings?.OpenAI?.apiKey ?? process.env.OPENAI_API_KEY ?? '',
// baseURL: currentProviderSettings?.OpenAI?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});
Expand Down
4 changes: 2 additions & 2 deletions lib/search/searcher.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from '@ai-sdk/openai';
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_streamText, ExperimentalMessage, ToolCallPart, ToolResultPart } from 'ai';
import { createStreamableUI, createStreamableValue } from 'ai/rsc';
import { z } from 'zod';
Expand Down Expand Up @@ -32,7 +32,7 @@ export const searcher = async (

let fullResponse = '';

const openai = new OpenAI({
const openai = createOpenAI({
apiKey: currentProviderSettings?.OpenAI?.apiKey ?? process.env.OPENAI_API_KEY ?? '',
// baseURL: currentProviderSettings?.OpenAI?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});
Expand Down