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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for livekit_plugins_difyai-1.1.2.post6.tar.gz
Algorithm Hash digest
SHA256 f56f5efc253d880af6bf3a0900cb34c4efa343ed63c23a0518f5ff3baffdab7f
MD5 4d401434a330c63a704bedea218f6a5f
BLAKE2b-256 5c9ef11d2b56ba2923d7f2cbb655e4ad1afb925cadf6c1b4c98e1ac9b05562a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for livekit_plugins_difyai-1.1.2.post6-py3-none-any.whl
Algorithm Hash digest
SHA256 d33eaf29b257490d0e8f0dddab2978c667e90b427fcb78ff0422128708945b9d
MD5 1092a2bd19ce4744a5ea5fcacbab1bca
BLAKE2b-256 2c616bdd67ae3982e1ff01250316003dd5a08a8cdecdec9ff67401bd82bb3c27

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