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.0.post4.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.0.post4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file livekit_plugins_difyai-1.1.0.post4.tar.gz.

File metadata

File hashes

Hashes for livekit_plugins_difyai-1.1.0.post4.tar.gz
Algorithm Hash digest
SHA256 19bb1a93ed933f600356e5e53f00f7c8249eda9e03cb0b19ab95de91c8a40428
MD5 f7b6b4affcd16f2215e799c3b211cbc1
BLAKE2b-256 d5d197a408712f622faf8e762a93065fb2d9cc383d9768628420da8c7809f96d

See more details on using hashes here.

File details

Details for the file livekit_plugins_difyai-1.1.0.post4-py3-none-any.whl.

File metadata

File hashes

Hashes for livekit_plugins_difyai-1.1.0.post4-py3-none-any.whl
Algorithm Hash digest
SHA256 7453a7e4ad3b44dec1e260db77d38de8bf948165163341b8168625dada98f7f4
MD5 f943ab89da6c5c1724e28510ba8a2246
BLAKE2b-256 bdebabdc435c99b165b11dd53d9c997f36a3f3674f351ae0c975e14427190f9d

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