MCPcopy Create free account
hub / github.com/Writesonic/GPTRouter / streamHandler

Function streamHandler

src/handlers/streamHandler.ts:4–21  ·  view source on GitHub ↗
({
  providerName,
  modelName,
  promptParams,
  timeout,
  maxRetries,
}: {
  providerName: string;
  modelName: string;
  promptParams: BasePromptParams;
  timeout: number;
  maxRetries: number;
})

Source from the content-addressed store, hash-verified

2import { BasePromptParams } from "../schema";
3
4export default async function* streamHandler({
5 providerName,
6 modelName,
7 promptParams,
8 timeout,
9 maxRetries,
10}: {
11 providerName: string;
12 modelName: string;
13 promptParams: BasePromptParams;
14 timeout: number;
15 maxRetries: number;
16}) {
17 const providerInstance = ProviderFactory.createProvider(providerName);
18 for await (const messageEvent of providerInstance.generateStream(modelName, promptParams, timeout, maxRetries)) {
19 yield messageEvent;
20 }
21}

Callers 3

generateResponseFunction · 0.85

Calls 1

createProviderMethod · 0.80

Tested by

no test coverage detected