Teams/Slackのチャットボット¶
SlackとMicrosoft Teamsは、DataRobotのデプロイと対話できるアプリケーションやボットの作成をサポートしています。 Using Slack or Teams as a front-end for an LLM-based chat application enables broad availability in an organization, providing the ability to upload documents easily as well as leverage internal knowledge stored in team channels or conversations.
IT組織から権限を取得し、Slack組織にSlackアプリを作成します。 次に、Slack APIを使用して、 アプリを作成します。
IT組織から権限を取得し、カスタマイズされたアプリをアップロードします。 次に、 Microsoftの開発者ポータルでアプリケーションとotを登録します。
SlackとTeamsの両方のメッセージ送信アクションで、ユーザーの質問をプロンプトとしてDataRobot LLMデプロイにエクスポートし、REST APIコールからのレスポンスをボットのユーザーメッセージに提供します。 DataRobotを使用すると、トークンの使用状況、プロンプト、レスポンス、毒性、およびその他の カスタム指標を追跡し、組織内でアプリケーションの監視とガバナンスを行うことができます。
以下のコードをSlackまたはTeamsのメッセージング構造に適応させることで、DataRobot LLMデプロイにクエリーとしてメッセージを渡し、レスポンスを得ることができます。
import datarobotx as drx
# configure drx LLM Deployment
RAG = drx.Deployment.from_url(
url=f'https://app.datarobot.com/deployments/{RAG_did}/overview'
)
def make_datarobot_deployment_unstructured_predictions(
data,
**kwargs,
):
query = json.loads(data)
response = RAG.predict_unstructured(query)
return json.dumps(response)
def make_prediction(prompt, history=None) -> dict:
data = {
"prompt": prompt,
}
if history:
data["chat_history"] = [
[entry.get("user", ""), entry.get("chatbot", "")] for entry in history
]
response = make_datarobot_deployment_unstructured_predictions(
json.dumps(data)
)
response = json.loads(response)
return response