Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use components to invoke Qwen models #3864

Open
alex-ge123 opened this issue Sep 20, 2024 · 2 comments
Open

How to use components to invoke Qwen models #3864

alex-ge123 opened this issue Sep 20, 2024 · 2 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@alex-ge123
Copy link

Bug Description

How to use components to invoke Qwen models
微信图片_20240920151229

Reproduction

image

Expected behavior

image

Who can help?

No response

Operating System

windows

Langflow Version

1.0.18

Python Version

3.11

Screenshot

No response

Flow File

No response

@alex-ge123 alex-ge123 added the bug Something isn't working label Sep 20, 2024
@alex-ge123
Copy link
Author

微信图片_20240920151229

@dosubot dosubot bot added the question Further information is requested label Sep 20, 2024
Copy link

dosubot bot commented Sep 20, 2024

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:

from langchain_community.chat_models.baidu_qianfan_endpoint import QianfanChatEndpoint
from pydantic.v1 import SecretStr

# Define the parameters for the Qwen model
parameters = {
    "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 model
try:
    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"]
    )
except Exception as e:
    raise ValueError("Could not connect to Qwen API.") from e

# Generate text using the Qwen model
output = qwen_model.generate_text("Your input text here")  # Replace with your input text

# Print the generated text
print(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].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants