Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/okisdev/ChatChat
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 29, 2024
2 parents 6302dbb + 93c1d9b commit 68064d8
Show file tree
Hide file tree
Showing 9 changed files with 6,120 additions and 4,782 deletions.
12 changes: 6 additions & 6 deletions app/[locale]/(home)/action.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExperimentalMessage } from 'ai';
import { CoreMessage } from 'ai';
import { createAI, createStreamableUI, createStreamableValue, getMutableAIState, StreamableValue } from 'ai/rsc';

import { AskFollowUpQuestion } from '@/components/layout/search/block/ask-follow-up-question';
Expand All @@ -13,9 +13,9 @@ import { SimpleModel } from '@/types/model';
import { SearchEngineSetting, TChallengerAction } from '@/types/search';
import { ProviderSetting } from '@/types/settings';

const allowProvider = ['OpenAI'] as Provider[];
const AllowSearchProvider = ['OpenAI'] as Provider[];

const chat = async (model: SimpleModel, messages: ExperimentalMessage[]) => {
const chat = async (model: SimpleModel, messages: CoreMessage[]) => {
'use server';
};

Expand All @@ -29,7 +29,7 @@ const search = async (
) => {
'use server';

if (!allowProvider.includes(model?.provider)) {
if (!AllowSearchProvider.includes(model?.provider)) {
return {
id: Date.now(),
isGenerating: false,
Expand Down Expand Up @@ -60,7 +60,7 @@ const search = async (
const uiStream = createStreamableUI();
const isGenerating = createStreamableValue(true);

const messages: ExperimentalMessage[] = aiState.get() as any;
const messages: CoreMessage[] = aiState.get() as any;

const question = formData?.get('input') as string;

Expand All @@ -69,7 +69,7 @@ const search = async (

if (content) {
const message = { role: 'user', content };
messages.push(message as ExperimentalMessage);
messages.push(message as CoreMessage);
aiState.update([...(aiState.get() as any), message]);
}

Expand Down
6 changes: 3 additions & 3 deletions app/api/search/google/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_streamText, ExperimentalMessage, StreamingTextResponse, ToolCallPart, ToolResultPart } from 'ai';
import { CoreMessage, StreamingTextResponse, streamText as aiStreamText, ToolCallPart, ToolResultPart } from 'ai';
import { createStreamableUI, createStreamableValue } from 'ai/rsc';

import { searcherPrompt } from '@/lib/prompt';
Expand All @@ -17,7 +17,7 @@ export async function POST(req: Request) {
config,
stream,
}: {
messages: ExperimentalMessage[];
messages: CoreMessage[];
config: ApiConfig;
stream: boolean;
} = await req.json();
Expand All @@ -33,7 +33,7 @@ export async function POST(req: Request) {
baseUrl: config.provider?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});

const result = await experimental_streamText({
const result = await aiStreamText({
model: openai.chat('gpt-4'),
system: searcherPrompt,
messages,
Expand Down
2 changes: 1 addition & 1 deletion components/layout/settings/provider/anthropic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const AnthropicProvider = ({ anthropic, setAnthropic }: { anthropic: Prov
<p className='px-1 text-sm'>Anthropic API Key</p>
<Input
type='text'
placeholder='sk-xxxx'
placeholder='sk-ant-xxxx'
value={anthropic?.apiKey}
onChange={(e) => {
setAnthropic({
Expand Down
6 changes: 3 additions & 3 deletions lib/search/challenger.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_generateObject, ExperimentalMessage } from 'ai';
import { CoreMessage, generateObject } from 'ai';
import { z } from 'zod';

import { challengerPrompt } from '@/lib/prompt';
Expand All @@ -10,15 +10,15 @@ export const challengerSchema = z.object({
next: z.enum(['proceed', 'challenge']),
});

export const challenger = async (messages: ExperimentalMessage[], model: SimpleModel, currentProviderSettings: ProviderSetting | null) => {
export const challenger = async (messages: CoreMessage[], model: SimpleModel, currentProviderSettings: ProviderSetting | null) => {
'use server';

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',
});

return await experimental_generateObject({
return await generateObject({
model: openai.chat(model.model_id ?? 'gpt-3.5-turbo'),
system: challengerPrompt,
messages,
Expand Down
6 changes: 3 additions & 3 deletions lib/search/clarifier.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_streamObject, ExperimentalMessage } from 'ai';
import { CoreMessage, streamObject } from 'ai';
import { createStreamableUI, createStreamableValue } from 'ai/rsc';
import { z } from 'zod';

Expand All @@ -17,7 +17,7 @@ export const clarifierSchema = z.object({
clarifyPlaceholder: z.string().optional().describe('The clarify placeholder for input'),
});

export const clarifier = async (uiStream: ReturnType<typeof createStreamableUI>, messages: ExperimentalMessage[], model: SimpleModel, currentProviderSettings: ProviderSetting | null) => {
export const clarifier = async (uiStream: ReturnType<typeof createStreamableUI>, messages: CoreMessage[], model: SimpleModel, currentProviderSettings: ProviderSetting | null) => {
'use server';

const objectStream = createStreamableValue<TClarifier>();
Expand All @@ -31,7 +31,7 @@ export const clarifier = async (uiStream: ReturnType<typeof createStreamableUI>,
// baseURL: currentProviderSettings?.OpenAI?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});

await experimental_streamObject({
await streamObject({
model: openai.chat(model.model_id ?? 'gpt-4-turbo'),
system: clarifierPrompt,
messages,
Expand Down
6 changes: 3 additions & 3 deletions lib/search/illustrator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_streamObject, ExperimentalMessage } from 'ai';
import { CoreMessage, streamObject } from 'ai';
import { createStreamableUI, createStreamableValue } from 'ai/rsc';
import { z } from 'zod';

Expand All @@ -13,7 +13,7 @@ export const illustratorSchema = z.object({
items: z.array(z.object({ query: z.string() })).length(3),
});

export const illustrator = async (uiStream: ReturnType<typeof createStreamableUI>, messages: ExperimentalMessage[], model: SimpleModel, currentProviderSettings: ProviderSetting | null) => {
export const illustrator = async (uiStream: ReturnType<typeof createStreamableUI>, messages: CoreMessage[], model: SimpleModel, currentProviderSettings: ProviderSetting | null) => {
'use server';

const objectStream = createStreamableValue<TIllustrator>();
Expand All @@ -25,7 +25,7 @@ export const illustrator = async (uiStream: ReturnType<typeof createStreamableUI
// baseURL: currentProviderSettings?.OpenAI?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});

await experimental_streamObject({
await streamObject({
model: openai.chat(model.model_id ?? 'gpt-4-turbo'),
system: illustratorPrompt,
messages,
Expand Down
6 changes: 3 additions & 3 deletions lib/search/searcher.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createOpenAI } from '@ai-sdk/openai';
import { experimental_streamText, ExperimentalMessage, ToolCallPart, ToolResultPart } from 'ai';
import { CoreMessage, streamText as aiStreamText, ToolCallPart, ToolResultPart } from 'ai';
import { createStreamableUI, createStreamableValue } from 'ai/rsc';
import { z } from 'zod';

Expand All @@ -22,7 +22,7 @@ export const searcherSchema = z.object({
export const searcher = async (
uiStream: ReturnType<typeof createStreamableUI>,
streamText: ReturnType<typeof createStreamableValue<string>>,
messages: ExperimentalMessage[],
messages: CoreMessage[],
isProSearch: boolean,
model: SimpleModel,
currentSearchEngineSettings: SearchEngineSetting | null,
Expand All @@ -37,7 +37,7 @@ export const searcher = async (
// baseURL: currentProviderSettings?.OpenAI?.endpoint ?? process.env.OPENAI_API_ENDPOINT ?? 'https://api.openai.com/v1',
});

const result = await experimental_streamText({
const result = await aiStreamText({
model: openai.chat(model.model_id ?? 'gpt-4-turbo'),
maxTokens: 2500,
system: searcherPrompt,
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"eslint:fix": "eslint --ext .ts,.tsx --fix ."
},
"dependencies": {
"@ai-sdk/anthropic": "^0.0.5",
"@ai-sdk/google": "^0.0.5",
"@ai-sdk/openai": "^0.0.4",
"@ai-sdk/anthropic": "^0.0.16",
"@ai-sdk/google": "^0.0.16",
"@ai-sdk/openai": "^0.0.16",
"@anthropic-ai/sdk": "^0.20.6",
"@aws-sdk/client-bedrock-runtime": "^3.556.0",
"@azure/openai": "^1.0.0-beta.12",
Expand All @@ -36,15 +36,15 @@
"@types/file-saver": "^2.0.7",
"@vercel/analytics": "^1.2.2",
"@vercel/speed-insights": "^1.0.10",
"ai": "^3.0.24",
"ai": "^3.1.15",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cohere-ai": "^7.9.5",
"file-saver": "^2.0.5",
"groq-sdk": "^0.3.2",
"jotai": "^2.8.0",
"lucide-react": "^0.363.0",
"next": "14.2.2",
"next": "14.2.3",
"next-intl": "^3.11.3",
"next-themes": "^0.3.0",
"openai": "^4.38.2",
Expand Down Expand Up @@ -80,6 +80,5 @@
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5",
"webpack": "^5.91.0"
},
"packageManager": "[email protected]"
}
}
}
Loading

0 comments on commit 68064d8

Please sign in to comment.