Giter Club home page Giter Club logo

Comments (1)

dosubot avatar dosubot commented on July 20, 2024 2

Hey @medoer! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together!

To resolve the HTML parsing error when building the Groq component, ensure that the HTML content is correctly formatted and that there are no syntax errors. In the provided code, there was a missing closing angle bracket in the last line of the content. Correcting this should help resolve the parsing error.

Here is the corrected content:

from typing import Optional

from langchain_groq import ChatGroq
from langflow.base.models.groq_constants import MODEL_NAMES
from pydantic.v1 import SecretStr

from langflow.base.constants import STREAM_INFO_TEXT
from langflow.base.models.model import LCModelComponent
from langflow.field_typing import Text

class GroqModel(LCModelComponent):
    display_name: str = "Groq"
    description: str = "Generate text using Groq."
    icon = "Groq"

    field_order = [
        "groq_api_key",
        "model",
        "max_output_tokens",
        "temperature",
        "top_k",
        "top_p",
        "n",
        "input_value",
        "system_message",
        "stream",
    ]

    def build_config(self):
        return {
            "groq_api_key": {
                "display_name": "Groq API Key",
                "info": "API key for the Groq API.",
                "password": True,
            },
            "groq_api_base": {
                "display_name": "Groq API Base",
                "info": "Base URL path for API requests, leave blank if not using a proxy or service emulator.",
                "advanced": True,
            },
            "max_tokens": {
                "display_name": "Max Output Tokens",
                "info": "The maximum number of tokens to generate.",
                "advanced": True,
            },
            "temperature": {
                "display_name": "Temperature",
                "info": "Run inference with this temperature. Must by in the closed interval [0.0, 1.0].",
            },
            "n": {
                "display_name": "N",
                "info": "Number of chat completions to generate for each prompt. Note that the API may not return the full n completions if duplicates are generated.",
                "advanced": True,
            },
            "model_name": {
                "display_name": "Model",
                "info": "The name of the model to use. Supported examples: gemini-pro",
                "options": MODEL_NAMES,
            },
            "input_value": {"display_name": "Input", "info": "The input to the model."},
            "stream": {
                "display_name": "Stream",
                "info": STREAM_INFO_TEXT,
                "advanced": True,
            },
            "system_message": {
                "display_name": "System Message",
                "info": "System message to pass to the model.",
                "advanced": True,
            },
        }

    def build(
        self,
        groq_api_key: str,
        model_name: str,
        input_value: Text,
        groq_api_base: Optional[str] = None,
        max_tokens: Optional[int] = None,
        temperature: float = 0.1,
        n: Optional[int] = 1,
        stream: bool = False,
        system_message: Optional[str] = None,
    ) -> Text:
        output = ChatGroq(
            model_name=model_name,
            max_tokens=max_tokens or None,  # type: ignore
            temperature=temperature,
            groq_api_base=groq_api_base,
            n=n or 1,
            groq_api_key=SecretStr(groq_api_key),
            streaming=stream,
        )
        return self.get_chat_result(output, stream, input_value, system_message)

Make sure to replace the content in your project with the corrected version above [1].

Additionally, ensure you have the correct dependencies and versions required for the Groq component to function correctly:

langchain-groq = "^0.1.3"
pydantic = "^1.10.2"

These dependencies are specified in the pyproject.toml file [2].

To continue talking to Dosu, mention @dosu.

from langflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.