Replies: 1 comment
-
🤖 Hi, Thanks for reaching out. It seems like you want to ask for more context from the user when the provided input is not enough. In your case, you want to ask for the Kubernetes cluster name and application deploy namespace when a user wants to restart a service. To achieve this, you can modify the def on_chat_model_start(
self,
serialized: Dict[str, Any],
messages: List[List[BaseMessage]],
*,
run_id: UUID,
kubernetes_cluster_name: str = None,
application_deploy_namespace: str = None,
**kwargs: Any,
) -> Any:
"""Run when the chat model is started."""
llm_model = kwargs.get("invocation_params", {}).get("model", None)
if llm_model is not None:
self.metadata["model"] = llm_model
# Add the Kubernetes cluster name and application deploy namespace to the metadata
if kubernetes_cluster_name is not None:
self.metadata["kubernetes_cluster_name"] = kubernetes_cluster_name
if application_deploy_namespace is not None:
self.metadata["application_deploy_namespace"] = application_deploy_namespace
if len(messages) == 0:
return
for message in messages[0]:
role = self.message_role_model.SYSTEM
if message.type == "human":
role = self.message_role_model.USER
elif message.type == "system":
role = self.message_role_model.SYSTEM
elif message.type == "ai":
role = self.message_role_model.ASSISTANT
self.messages.append(
self.message_model(
message=message.content,
role=role,
)
) In this modification, Additionally, you can modify the LangChain framework to request additional information from the user by adding the new key to the @property
def input_keys(self) -> List[str]:
"""Expect input key.
:meta private:
"""
return [self.question_key, "context"]
def _call(
self,
inputs: Dict[str, Any],
run_manager: Optional[CallbackManagerForChainRun] = None,
) -> Dict[str, str]:
_run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager()
question = inputs[self.question_key]
context = inputs["context"]
# ... rest of the method ... Remember to also modify the I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi team
we are using langchain agent to help us do self serving in kubernetes world, for example I want to troubleshoot a pod restart or restart a pod, most of time, user will only say "I want to restart my service with the name nginx", we need more context here most of the time such as
Kubernetes cluster name
,application deploy namespace
...seek any advice here to do this more elegantly, thanks 🙏 .
here's the code
Beta Was this translation helpful? Give feedback.
All reactions