🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import type { ChatModelCard } from '@lobechat/types';
import { ModelProvider } from 'model-bank';
import type { OpenAICompatibleFactoryOptions } from '../../core/openaiCompatible';
import { createOpenAICompatibleRuntime } from '../../core/openaiCompatible';
import { createStepfunImage } from './createImage';
export interface StepfunModelCard {
id: string;
}
export const params = {
baseURL: 'https://api.stepfun.com/v1',
chatCompletion: {
handlePayload: (payload) => {
const { enabledSearch, stream, tools, ...rest } = payload;
const stepfunTools = enabledSearch
? [
...(tools || []),
{
function: {
description: 'use web_search to search information on the internet',
},
type: 'web_search',
},
]
: tools;
return {
...rest,
stream: stream ?? true,
tools: stepfunTools,
} as any;
},
},
debug: {
chatCompletion: () => process.env.DEBUG_STEPFUN_CHAT_COMPLETION === '1',
},
createImage: createStepfunImage,
models: async ({ client }) => {
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
// ref: https://platform.stepfun.com/docs/llm/modeloverview
const functionCallKeywords = ['step-1-', 'step-1o-', 'step-1v-', 'step-2-'];
const visionKeywords = ['step-1o-', 'step-r1-v-', 'step-1v-'];
const reasoningKeywords = ['step-r1-'];
const modelsPage = (await client.models.list()) as any;
const modelList: StepfunModelCard[] = modelsPage.data;
return modelList
.map((model) => {
const knownModel = LOBE_DEFAULT_MODEL_LIST.find(
(m) => model.id.toLowerCase() === m.id.toLowerCase(),
);
return {
contextWindowTokens: knownModel?.contextWindowTokens ?? undefined,
displayName: knownModel?.displayName ?? undefined,
enabled: knownModel?.enabled || false,
functionCall:
functionCallKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
knownModel?.abilities?.functionCall ||
false,
id: model.id,
reasoning:
reasoningKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
knownModel?.abilities?.reasoning ||
false,
vision:
visionKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
knownModel?.abilities?.vision ||
false,
};
})
.filter(Boolean) as ChatModelCard[];
},
provider: ModelProvider.Stepfun,
} satisfies OpenAICompatibleFactoryOptions;
export const LobeStepfunAI = createOpenAICompatibleRuntime(params);