Skip to content

Support Dify Provider #4084

@SeieiSogen

Description

@SeieiSogen

Feature Description

The example can be found in the OpenAI Provider:

https://sdk.vercel.ai/providers/ai-sdk-providers/openai

It would be great if you could add a provider like Dify

https://docs.dify.ai/guides/application-publishing/based-on-frontend-templates

to make it usable with Vercel AI SDK.

Use Cases

import { createDify } from "@ai-sdk/dify";
import { streamObject } from 'ai';
import { z } from 'zod';

const dify = createDify({
    response_mode: "streaming",
    inputs: {
        name: "John Doe",
    },
});

const { partialObjectStream } = streamObject({
  model: dify,
  schema: z.object({
    recipe: z.object({
      name: z.string(),
      ingredients: z.array(z.string()),
      steps: z.array(z.string()),
    }),
  }),
  prompt: 'Generate a lasagna recipe.',
});

for await (const partialObject of partialObjectStream) {
  console.clear();
  console.log(partialObject);
}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions