Skip to content

Langchain (flowise)

BobMaster edited this page Apr 24, 2024 · 3 revisions

Langchain api endpoint powered by Flowise

sample config.json

{
  "homeserver": "https://xxxx",
  "user_id": "@lullap:xxxx",
  "password": "xxxxx",
  "device_id": "MatrixChatGPTBot",
  "lc_admin": ["@admin:xxxxx.org"]
}

sample .env

HOMESERVER="https://matrix.xxxxxx.xxxx" 
USER_ID="@lullap:xxxxxxxxxxxxx.xxx" 
PASSWORD="xxxxxxxxxxxxxxx" 
DEVICE_ID="xxxxxxxxxxxxxx" 
LC_ADMIN="@admin:xxxxxx.xxx,@admin2:xxxxxx.xxx"

For users:

list your available agents

!agent list

change your current using agent (remove {})

!agent use {agent_name}

use that agent

!lc {prompt}

For admins:

"""
username: user_id or room_id
- user_id: @xxxxx:xxxxx.xxxxx
- room_id: !xxxxx:xxxxx.xxxxx

agent_name: the name of the agent
api_url: api_endpoint
api_key: api_key (Optional)
permission: integer (can: 1, cannot: 0)

{1} update api_url
{2} update api_key
{3} update permission
{4} update agent name

# add langchain endpoint
!lcadmin add {username} {agent_name} {api_url} {api_key *Optional} {permission}

# update api_url
!lcadmin update {1} {username} {agent} {api_url}
# update api_key
!lcadmin update {2} {username} {agent} {api_key}
# update permission
!lcadmin update {3} {username} {agent} {permission}
# update agent name
!lcadmin update {4} {username} {agent} {api_url}

# delete agent
!lcadmin delete {username} {agent}

# delete all agent
!lcadmin delete {username}

# list agent
!lcadmin list {username}

# list all agents
!lcadmin list
"""

some examples:

# add endpoint for specific user/room
!lcadmin add @test1:matrix.local agent1 http://localhost:3000/api/v1/prediction/4035116b-bf8e-4657-8363-4f18911008c9  1
!lcadmin add @test1:matrix.local agent2 http://localhost:3000/api/v1/prediction/a9c2c174-3d3d-478a-a7be-4ac0e9666842 H0e3RqhZOmvg+d5Ws8QyH9O3+0sgAx4cZE+yTSUkD6c=  1

# update api_url
!lcadmin update 1 @bobmaster:matrix.local agent1 http://flowise:3000/api/v1/prediction/6deb3c89-45bf-4ac4-a0b0-b2d5ef249d21
# update api_key
!lcadmin update 2 @bobmaster:matrix.local agent1 H0e3RqhZOmvg+d5Ws8QyH9O3+0sgAx4cZE+yTSUkD6c=
# update permission
!lcadmin update 3 @bobmaster:matrix.local agent2 0
# update agent name
!lcadmin update 4 new_agent_name http://flowise:3000/api/v1/prediction/6deb3c89-45bf-4ac4-a0b0-b2d5ef249d21 

# delete agent
!lcadmin delete @test1:matrix.local agent2
# delete all agent
!lcadmin delete @test1:matrix.local

# list agent
!lcadmin list @test1:matrix.local
# list all agents
!lcadmin list
Clone this wiki locally