Integrate a custom Large Language Model

更新时间:
复制 MD 格式

The Mobi platform lets you integrate custom Large Language Models (LLMs). Using simple configurations, you can seamlessly connect and exchange data with any LLM that is compatible with the OpenAI API. This document describes how to create and use a custom LLM integration.

Features

The custom LLM integration feature on the Mobi platform supports the following:

  • Custom trigger methods: You can set integration operations to trigger manually or run automatically to meet the requirements of different business scenarios.

  • Callbacks and data transformation: You can execute specific integration operation events when a query succeeds or fails. You can also perform custom processing on the returned data.

  • Advanced settings: You can use advanced configurations for debouncing and execution prevention conditions to optimize the execution of integration operations.

For more information about events, see Integration operation events.

Use a custom LLM integration

Step 1: Create a custom LLM integration

  1. Log on to the Mobi platform and go to the console.

  2. Navigate to Resources -> Integration and click Create Integration.

  3. Select Custom Large Language Model, and enter a name and description for the integration.

  4. Configure the custom LLM integration details for different environments. This includes the OpenAI API endpoint and API-KEY.

  5. Click OK to create the custom LLM integration.

Step 2: Create an integration operation within the application

  1. Open the Code panel. Click + in the appropriate scope and select Integration Operation.

  2. Select the OpenAI integration that you created as the resource. After you select an operation type, the parameters for that type are displayed. Configure the parameters and click Run to retrieve the returned result.

  3. Click Run to preview the query result.

Configuration panel details

Integration configuration

For more information about the OpenAI API, see the ModelScope Community API Inference Introduction.

  • OpenAI API endpoint: The endpoint for a service that is compatible with the OpenAI API. For example, the ModelScope platform endpoint is https://api-inference.modelscope.cn/v1, and the DeepSeek platform endpoint is https://api.deepseek.com/v1.

  • API-KEY: The access credential used to make OpenAI requests. For example, this could be the SDK token from the ModelScope platform. To obtain an SDK token from your ModelScope account, go to https://modelscope.cn/my/myaccesstoken. To obtain an API Key from the DeepSeek platform, go to https://platform.deepseek.com/api_keys.

General configurations

  • Model: The name of the model to call. For models supported by the ModelScope platform, see the ModelScope Community API Inference Introduction. The DeepSeek platform supports deepseek-chat and deepseek-reasoner. For more information about DeepSeek platform models, see the DeepSeek API reference.

  • Conversation context: The messages array of message objects passed to the API call. A message object contains a role and content.

  • sse: A switch that enables streaming responses.

  • parameters: Extra parameters to pass to the API. These parameters include the maximum number of tokens to generate and the random number seed.

Callback configuration

  • Data transformation: Processes the data returned by the API. The default is return data, which means no processing is performed.

  • Success callback: The event to trigger when the API call succeeds.

  • Failure callback: The event to trigger when the API call fails.

Advanced configuration

  • Debounce: A debounce expression to prevent frequent API calls.

  • Execution prevention condition: A conditional expression that determines whether to execute this integration operation.

Manually trigger an integration

Event trigger

  1. In the component where you want to trigger the integration operation, configure an event handler.

  2. Set the action type to Integration Operation and select the corresponding integration.

  3. Enter the configured parameters as an object.

API trigger

If the name of the integration operation is action1, you can use the action1.trigger() method to trigger it from any location where a script can be executed. If the integration operation requires parameters, you must pass them as an object.