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

"No valves to update" #328

Open
rcontesti opened this issue Nov 15, 2024 · 1 comment
Open

"No valves to update" #328

rcontesti opened this issue Nov 15, 2024 · 1 comment

Comments

@rcontesti
Copy link

rcontesti commented Nov 15, 2024

I'm trying to upload any of examples in the repo to the pipelines settings tab. But when I try to save I get the error: No valves to update.

Can somebody point to what might be going on? Thank you.

Allow me show my code for context:

from typing import List, Union, Generator, Iterator
import os 
from pydantic import BaseModel
import requests


class Pipeline:
    class Valves(BaseModel):
        AGENT_HOST: str
        AGENT_PORT: int
        AGENT_ENDPOINT:str
        pipelines: List[str] = []
        priority: int = 0

    # Update valves/ environment variables based on your selected database 
    def __init__(self):
        self.name = "Xerket Chat"

        # Initialize
        self.valves = self.Valves(
            **{
                # "pipelines": ["*"],                                                           # Connect to all pipelines
                "AGENT_HOST": os.getenv("AGENT_HOST", "0.0.0.0"),
                "AGENT_PORT": os.getenv("AGENT_PORT", 5006),
                "AGENT_ENDPOINT": os.getenv("AGENT_ENDPOINT", "/message"),     
            }
        )

    async def on_startup(self):
        # # This function is called when the server is started.
        pass

    async def on_shutdown(self):
        pass

    def pipe(
        self, user_message: str, model_id: str, messages: List[dict], body: dict
    ) -> Union[str, Generator, Iterator]:
        
        AGENT_ENDPOINT = self.valves.AGENT_ENDPOINT
        AGENT_PORT = self.valves.AGENT_PORT
        AGENT_HOST = self.valves.AGENT_HOST

        url = f"http://{AGENT_HOST}:{AGENT_PORT}{AGENT_ENDPOINT}"
        data = {"content": user_message}

        response = requests.post(url, json=data)

        agent_response = ""
        
        if response.status_code == 200:
            agent_response = response.json['response']
        else:
            agent_response =  "Agent not available"
            
        return agent_response
@willdady
Copy link

My guess is you need to have this function defined?

async def on_valves_updated(self):
        # This function is called when the valves are updated.
        pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants