mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-22 01:55:27 -04:00
xAI: Add live search to Grok3 series models and rename models by removing beta suffix (#968)
* refactor(model/xai): rename grok3 series models by removing beta suffix * feat(model/xai): add live search to Grok3 series models * chore(model/xai): update plugin version to 0.0.8 in manifest.yaml
This commit is contained in:
@@ -35,4 +35,4 @@ resource:
|
||||
tool:
|
||||
enabled: true
|
||||
type: plugin
|
||||
version: 0.0.6
|
||||
version: 0.0.8
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
model: grok-3-fast-beta
|
||||
model: grok-3-fast
|
||||
label:
|
||||
en_US: grok-3-fast-beta
|
||||
en_US: grok-3-fast
|
||||
model_type: llm
|
||||
features:
|
||||
- agent-thought
|
||||
@@ -31,6 +31,16 @@ parameter_rules:
|
||||
- json_schema
|
||||
- name: json_schema
|
||||
use_template: json_schema
|
||||
- name: search_parameters
|
||||
label:
|
||||
zh_Hans: 联网搜索参数
|
||||
en_US: Live Search Parameters
|
||||
type: text
|
||||
default: "{\n \"mode\": \"auto\"\n}"
|
||||
help:
|
||||
zh_Hans: 传递给联网搜索的参数,具体参数见 https://docs.x.ai/docs/api-reference#chat-completions
|
||||
en_US: Parameters to pass to the live search, see https://docs.x.ai/docs/api-reference#chat-completions
|
||||
required: false
|
||||
pricing:
|
||||
input: "5.00"
|
||||
output: "25.00"
|
||||
+12
-2
@@ -1,6 +1,6 @@
|
||||
model: grok-3-mini-fast-beta
|
||||
model: grok-3-mini-fast
|
||||
label:
|
||||
en_US: grok-3-mini-fast-beta
|
||||
en_US: grok-3-mini-fast
|
||||
model_type: llm
|
||||
features:
|
||||
- agent-thought
|
||||
@@ -43,6 +43,16 @@ parameter_rules:
|
||||
- json_schema
|
||||
- name: json_schema
|
||||
use_template: json_schema
|
||||
- name: search_parameters
|
||||
label:
|
||||
zh_Hans: 联网搜索参数
|
||||
en_US: Live Search Parameters
|
||||
type: text
|
||||
default: "{\n \"mode\": \"auto\"\n}"
|
||||
help:
|
||||
zh_Hans: 传递给联网搜索的参数,具体参数见 https://docs.x.ai/docs/api-reference#chat-completions
|
||||
en_US: Parameters to pass to the live search, see https://docs.x.ai/docs/api-reference#chat-completions
|
||||
required: false
|
||||
pricing:
|
||||
input: "0.60"
|
||||
output: "4.00"
|
||||
@@ -1,6 +1,6 @@
|
||||
model: grok-3-mini-beta
|
||||
model: grok-3-mini
|
||||
label:
|
||||
en_US: grok-3-mini-beta
|
||||
en_US: grok-3-mini
|
||||
model_type: llm
|
||||
features:
|
||||
- agent-thought
|
||||
@@ -43,6 +43,16 @@ parameter_rules:
|
||||
- json_schema
|
||||
- name: json_schema
|
||||
use_template: json_schema
|
||||
- name: search_parameters
|
||||
label:
|
||||
zh_Hans: 联网搜索参数
|
||||
en_US: Live Search Parameters
|
||||
type: text
|
||||
default: "{\n \"mode\": \"auto\"\n}"
|
||||
help:
|
||||
zh_Hans: 传递给联网搜索的参数,具体参数见 https://docs.x.ai/docs/api-reference#chat-completions
|
||||
en_US: Parameters to pass to the live search, see https://docs.x.ai/docs/api-reference#chat-completions
|
||||
required: false
|
||||
pricing:
|
||||
input: "0.30"
|
||||
output: "0.50"
|
||||
@@ -1,6 +1,6 @@
|
||||
model: grok-3-beta
|
||||
model: grok-3
|
||||
label:
|
||||
en_US: grok-3-beta
|
||||
en_US: grok-3
|
||||
model_type: llm
|
||||
features:
|
||||
- agent-thought
|
||||
@@ -31,6 +31,16 @@ parameter_rules:
|
||||
- json_schema
|
||||
- name: json_schema
|
||||
use_template: json_schema
|
||||
- name: search_parameters
|
||||
label:
|
||||
zh_Hans: 联网搜索参数
|
||||
en_US: Live Search Parameters
|
||||
type: text
|
||||
default: "{\n \"mode\": \"auto\"\n}"
|
||||
help:
|
||||
zh_Hans: 传递给联网搜索的参数,具体参数见 https://docs.x.ai/docs/api-reference#chat-completions
|
||||
en_US: Parameters to pass to the live search, see https://docs.x.ai/docs/api-reference#chat-completions
|
||||
required: false
|
||||
pricing:
|
||||
input: "3.00"
|
||||
output: "15.00"
|
||||
@@ -1,19 +0,0 @@
|
||||
model: grok-beta
|
||||
label:
|
||||
en_US: Grok Beta
|
||||
model_type: llm
|
||||
features:
|
||||
- agent-thought
|
||||
- tool-call
|
||||
- multi-tool-call
|
||||
- stream-tool-call
|
||||
model_properties:
|
||||
mode: chat
|
||||
context_size: 131072
|
||||
parameter_rules:
|
||||
- name: temperature
|
||||
use_template: temperature
|
||||
- name: top_p
|
||||
use_template: top_p
|
||||
- name: frequency_penalty
|
||||
use_template: frequency_penalty
|
||||
@@ -1,17 +0,0 @@
|
||||
model: grok-vision-beta
|
||||
label:
|
||||
en_US: Grok Vision Beta
|
||||
model_type: llm
|
||||
features:
|
||||
- agent-thought
|
||||
- vision
|
||||
model_properties:
|
||||
mode: chat
|
||||
context_size: 8192
|
||||
parameter_rules:
|
||||
- name: temperature
|
||||
use_template: temperature
|
||||
- name: top_p
|
||||
use_template: top_p
|
||||
- name: frequency_penalty
|
||||
use_template: frequency_penalty
|
||||
@@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
from collections.abc import Generator
|
||||
from typing import Optional, Union
|
||||
from dify_plugin.entities.model.llm import LLMMode, LLMResult
|
||||
@@ -19,6 +21,7 @@ class XAILargeLanguageModel(OAICompatLargeLanguageModel):
|
||||
user: Optional[str] = None,
|
||||
) -> Union[LLMResult, Generator]:
|
||||
self._add_custom_parameters(credentials)
|
||||
self._validate_search_parameters(model_parameters)
|
||||
return super()._invoke(model, credentials, prompt_messages, model_parameters, tools, stop, stream)
|
||||
|
||||
def validate_credentials(self, model: str, credentials: dict) -> None:
|
||||
@@ -32,3 +35,14 @@ class XAILargeLanguageModel(OAICompatLargeLanguageModel):
|
||||
credentials["function_calling_type"] = "tool_call"
|
||||
credentials["stream_function_calling"] = "support"
|
||||
credentials["vision_support"] = "support"
|
||||
|
||||
@staticmethod
|
||||
def _validate_search_parameters(model_parameters):
|
||||
if "search_parameters" not in model_parameters:
|
||||
return
|
||||
|
||||
search_parameters = model_parameters["search_parameters"]
|
||||
try:
|
||||
model_parameters["search_parameters"] = json.loads(search_parameters)
|
||||
except json.JSONDecodeError:
|
||||
raise ValueError("search_parameters must be a valid JSON string")
|
||||
|
||||
@@ -16,7 +16,7 @@ class XAIProvider(ModelProvider):
|
||||
"""
|
||||
try:
|
||||
model_instance = self.get_model_instance(ModelType.LLM)
|
||||
model = credentials.get("model", "grok-3-mini-beta")
|
||||
model = credentials.get("model", "grok-3-mini")
|
||||
model_instance.validate_credentials(model=model, credentials=credentials)
|
||||
except CredentialsValidateFailedError as ex:
|
||||
raise ex
|
||||
|
||||
@@ -37,29 +37,23 @@ provider_credential_schema:
|
||||
required: true
|
||||
type: secret-input
|
||||
variable: api_key
|
||||
- default: grok-3-mini-beta
|
||||
- default: grok-3-mini
|
||||
label:
|
||||
en_US: Model
|
||||
zh_Hans: 模型
|
||||
options:
|
||||
- label:
|
||||
en_US: grok-3-mini-beta
|
||||
value: grok-3-mini-beta
|
||||
en_US: grok-3-mini
|
||||
value: grok-3-mini
|
||||
- label:
|
||||
en_US: grok-3-beta
|
||||
value: grok-3-beta
|
||||
en_US: grok-3
|
||||
value: grok-3
|
||||
- label:
|
||||
en_US: grok-3-fast-beta
|
||||
value: grok-3-fast-beta
|
||||
en_US: grok-3-fast
|
||||
value: grok-3-fast
|
||||
- label:
|
||||
en_US: grok-3-mini-fast-beta
|
||||
value: grok-3-mini-fast-beta
|
||||
- label:
|
||||
en_US: grok-beta
|
||||
value: grok-beta
|
||||
- label:
|
||||
en_US: grok-vision-beta
|
||||
value: grok-vision-beta
|
||||
en_US: grok-3-mini-fast
|
||||
value: grok-3-mini-fast
|
||||
- label:
|
||||
en_US: grok-2-1212
|
||||
value: grok-2-1212
|
||||
|
||||
Reference in New Issue
Block a user