You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use components to invoke Qwen models, you can follow a structure similar to the one provided for the Baidu Qianfan model in the Langflow documentation. Here is an example based on the structure of the QianfanChatEndpointComponent:
fromlangchain_community.chat_models.baidu_qianfan_endpointimportQianfanChatEndpointfrompydantic.v1importSecretStr# Define the parameters for the Qwen modelparameters= {
"model": "Qwen/Qwen1.5-72B-Chat", # Replace with the actual Qwen model name"qianfan_ak": "your-qwen-api-key", # Replace with your Qwen API key"qianfan_sk": "your-qwen-secret-key", # Replace with your Qwen secret key"top_p": 0.8, # Set the top_p parameter"temperature": 0.1, # Set the temperature for randomness"penalty_score": 1.0, # Set the penalty score"endpoint": "your-qwen-endpoint"# Replace with your Qwen endpoint
}
# Create an instance of the Qwen modeltry:
qwen_model=QianfanChatEndpoint(
model=parameters["model"],
qianfan_ak=SecretStr(parameters["qianfan_ak"]),
qianfan_sk=SecretStr(parameters["qianfan_sk"]),
top_p=parameters["top_p"],
temperature=parameters["temperature"],
penalty_score=parameters["penalty_score"],
endpoint=parameters["endpoint"]
)
exceptExceptionase:
raiseValueError("Could not connect to Qwen API.") frome# Generate text using the Qwen modeloutput=qwen_model.generate_text("Your input text here") # Replace with your input text# Print the generated textprint(output)
This example assumes that the Qwen model component follows a similar pattern to the Baidu Qianfan model. You would need to replace the placeholders with actual values and ensure that the QianfanChatEndpoint class and its methods are correctly implemented. For detailed documentation and integration guides, you can refer to the specific component documentation for other models like Amazon Bedrock, Anthropic, Azure OpenAI, etc., as they provide a comprehensive list of parameters and usage examples [1][2][3][4].
Bug Description
How to use components to invoke Qwen models
Reproduction
Expected behavior
Who can help?
No response
Operating System
windows
Langflow Version
1.0.18
Python Version
3.11
Screenshot
No response
Flow File
No response
The text was updated successfully, but these errors were encountered: