mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 03:26:17 +00:00
Standardize SparkLLM (#25239)
- **Description:** Standardize SparkLLM, include: - docs, the issue #24803 - to support stream - update api url - model init arg names, the issue #20085
This commit is contained in:
@@ -18,3 +18,28 @@ def test_generate() -> None:
|
||||
output = llm.generate(["Say foo:"])
|
||||
assert isinstance(output, LLMResult)
|
||||
assert isinstance(output.generations, list)
|
||||
|
||||
|
||||
def test_spark_llm_with_param_alias() -> None:
|
||||
"""Test SparkLLM with parameters alias."""
|
||||
llm = SparkLLM( # type: ignore[call-arg]
|
||||
app_id="your-app-id",
|
||||
api_key="your-api-key",
|
||||
api_secret="your-api-secret",
|
||||
model="Spark4.0 Ultra",
|
||||
api_url="your-api-url",
|
||||
timeout=20,
|
||||
)
|
||||
assert llm.spark_app_id == "your-app-id"
|
||||
assert llm.spark_api_key == "your-api-key"
|
||||
assert llm.spark_api_secret == "your-api-secret"
|
||||
assert llm.spark_llm_domain == "Spark4.0 Ultra"
|
||||
assert llm.spark_api_url == "your-api-url"
|
||||
assert llm.request_timeout == 20
|
||||
|
||||
|
||||
def test_spark_llm_with_stream() -> None:
|
||||
"""Test SparkLLM with stream."""
|
||||
llm = SparkLLM() # type: ignore[call-arg]
|
||||
for chunk in llm.stream("你好呀"):
|
||||
assert isinstance(chunk, str)
|
||||
|
Reference in New Issue
Block a user