Skip to main content

LiveKit Agent Plugins for Dify

Project description

LiveKit Plugins Dify

Agent Framework plugin for Dify.

Installation

pip install livekit-plugins-difyai

Pre-requisites

  • Dify API Key environment variables: DIFY_API_KEY
  • Dify API Base URL environment variables: DIFY_API_BASE. defaults to https://api.dify.ai/v1.

Usage

This example shows how to use the Dify plugin.

from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
from livekit.plugins import dify
from dotenv import load_dotenv


async def entry_point(ctx: JobContext):
    
    await ctx.connect()
    
    agent = Agent(instructions="You are a helpful assistant.")
    llm = dify.LLM(user="xxx")
    session = AgentSession(
        stt = xxx,
        llm = llm
        tts = xxx,
    )
    
    await session.start(agent=agent, room=ctx.room)
    ## 支持dify开场词
    opening_words = await llm.get_opening_words()
    if opening_words:
        await session.say(opening_words)


if __name__ == "__main__":
    load_dotenv()
    cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

livekit_plugins_difyai-1.1.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

livekit_plugins_difyai-1.1.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file livekit_plugins_difyai-1.1.2.tar.gz.

File metadata

File hashes

Hashes for livekit_plugins_difyai-1.1.2.tar.gz
Algorithm Hash digest
SHA256 9287c6658ad5bb5e91012e6054abeb9a4857b0357adf7c49dc5c9c4023aaa8d3
MD5 36599af7fb61011e242ebe3a6b1bb038
BLAKE2b-256 b4d5f8248ea5e73490fe4ef11b5b4fa24b037dc23a500fe3b67b1c61ac68ee4f

See more details on using hashes here.

File details

Details for the file livekit_plugins_difyai-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for livekit_plugins_difyai-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6a33dd2f37a0def2117ee149861a1da8c988f985c365fe358d51c65bb83b78ce
MD5 88401b178f671d650b1c6f425d22324c
BLAKE2b-256 93e241057814e4a86af547a1cd48d5030aa447cab5050c793583dcebce1f35bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page