mirror of
https://github.com/stackblitz/bolt.new
synced 2025-02-06 04:48:04 +00:00
merge with upstream
This commit is contained in:
parent
70d14df953
commit
074161024d
@ -22,7 +22,6 @@ export function getAnthropicModel(apiKey: string, model: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getOpenAILikeModel(baseURL: string, apiKey: string, model: string) {
|
export function getOpenAILikeModel(baseURL: string, apiKey: string, model: string) {
|
||||||
// console.log('OpenAILike config:', { baseURL, hasApiKey: !!apiKey, model });
|
|
||||||
const openai = createOpenAI({
|
const openai = createOpenAI({
|
||||||
baseURL,
|
baseURL,
|
||||||
apiKey,
|
apiKey,
|
||||||
@ -132,8 +131,6 @@ export function getModel(provider: string, model: string, env: Env, apiKeys?: Re
|
|||||||
apiKey = getAPIKey(env, provider, apiKeys); // Then assign
|
apiKey = getAPIKey(env, provider, apiKeys); // Then assign
|
||||||
baseURL = getBaseURL(env, provider);
|
baseURL = getBaseURL(env, provider);
|
||||||
|
|
||||||
// console.log('getModel inputs:', { provider, model, baseURL, hasApiKey: !!apiKey });
|
|
||||||
|
|
||||||
switch (provider) {
|
switch (provider) {
|
||||||
case 'Anthropic':
|
case 'Anthropic':
|
||||||
return getAnthropicModel(apiKey, model);
|
return getAnthropicModel(apiKey, model);
|
||||||
|
@ -52,12 +52,9 @@ function extractPropertiesFromMessage(message: Message): { model: string; provid
|
|||||||
})
|
})
|
||||||
: textContent.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '');
|
: textContent.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '');
|
||||||
|
|
||||||
// console.log('Model from message:', model);
|
|
||||||
// console.log('Found in MODEL_LIST:', MODEL_LIST.find((m) => m.name === model));
|
|
||||||
// console.log('Current MODEL_LIST:', MODEL_LIST);
|
|
||||||
|
|
||||||
return { model, provider, content: cleanedContent };
|
return { model, provider, content: cleanedContent };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function streamText(
|
export function streamText(
|
||||||
messages: Messages,
|
messages: Messages,
|
||||||
env: Env,
|
env: Env,
|
||||||
@ -79,20 +76,21 @@ export function streamText(
|
|||||||
|
|
||||||
return { ...message, content };
|
return { ...message, content };
|
||||||
}
|
}
|
||||||
|
return message;
|
||||||
|
});
|
||||||
|
|
||||||
const modelDetails = MODEL_LIST.find((m) => m.name === currentModel);
|
const modelDetails = MODEL_LIST.find((m) => m.name === currentModel);
|
||||||
|
|
||||||
const dynamicMaxTokens =
|
const dynamicMaxTokens =
|
||||||
modelDetails && modelDetails.maxTokenAllowed
|
modelDetails && modelDetails.maxTokenAllowed
|
||||||
? modelDetails.maxTokenAllowed
|
? modelDetails.maxTokenAllowed
|
||||||
: MAX_TOKENS;
|
: MAX_TOKENS;
|
||||||
|
|
||||||
return _streamText({
|
return _streamText({
|
||||||
model: getModel(currentProvider, currentModel, env, apiKeys),
|
...options,
|
||||||
system: getSystemPrompt(),
|
model: getModel(currentProvider, currentModel, env, apiKeys),
|
||||||
maxTokens: dynamicMaxTokens,
|
system: getSystemPrompt(),
|
||||||
messages: convertToCoreMessages(processedMessages),
|
maxTokens: dynamicMaxTokens,
|
||||||
...options,
|
messages: convertToCoreMessages(processedMessages),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)}
|
|
||||||
|
@ -37,8 +37,6 @@ async function chatAction({ context, request }: ActionFunctionArgs) {
|
|||||||
model: string
|
model: string
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// console.log('ChatAction:', JSON.stringify(messages));
|
|
||||||
|
|
||||||
const cookieHeader = request.headers.get("Cookie");
|
const cookieHeader = request.headers.get("Cookie");
|
||||||
|
|
||||||
// Parse the cookie's value (returns an object or null if no cookie exists)
|
// Parse the cookie's value (returns an object or null if no cookie exists)
|
||||||
|
@ -32,7 +32,7 @@ const PROVIDER_LIST: ProviderInfo[] = [
|
|||||||
name: 'OpenAILike',
|
name: 'OpenAILike',
|
||||||
staticModels: [
|
staticModels: [
|
||||||
{ name: 'o1-mini', label: 'o1-mini', provider: 'OpenAILike' },
|
{ name: 'o1-mini', label: 'o1-mini', provider: 'OpenAILike' },
|
||||||
{ name: 'gpt-4o-mini', label: 'GPT-4o Mini', provider: 'OpenAI' },
|
{ name: 'gpt-4o-mini', label: 'GPT-4o Mini', provider: 'OpenAILike' },
|
||||||
],
|
],
|
||||||
getDynamicModels: getOpenAILikeModels
|
getDynamicModels: getOpenAILikeModels
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user