-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Agent] support custom prompt (#798)
* habana_main issue fixed, now use original dockerfile Signed-off-by: Chendi.Xue <[email protected]> * Enable custom_prompt Signed-off-by: Chendi.Xue <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update README Signed-off-by: Chendi.Xue <[email protected]> --------- Signed-off-by: Chendi.Xue <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3a166c1
commit 3473bfb
Showing
12 changed files
with
64 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,37 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from .utils import load_python_prompt | ||
|
||
|
||
def instantiate_agent(args, strategy="react_langchain", with_memory=False): | ||
if args.custom_prompt is not None: | ||
print(f">>>>>> custom_prompt enabled, {args.custom_prompt}") | ||
custom_prompt = load_python_prompt(args.custom_prompt) | ||
else: | ||
custom_prompt = None | ||
|
||
if strategy == "react_langchain": | ||
from .strategy.react import ReActAgentwithLangchain | ||
|
||
return ReActAgentwithLangchain(args, with_memory) | ||
return ReActAgentwithLangchain(args, with_memory, custom_prompt=custom_prompt) | ||
elif strategy == "react_langgraph": | ||
from .strategy.react import ReActAgentwithLanggraph | ||
|
||
return ReActAgentwithLanggraph(args, with_memory) | ||
return ReActAgentwithLanggraph(args, with_memory, custom_prompt=custom_prompt) | ||
elif strategy == "react_llama": | ||
print("Initializing ReAct Agent with LLAMA") | ||
from .strategy.react import ReActAgentLlama | ||
|
||
return ReActAgentLlama(args, with_memory) | ||
return ReActAgentLlama(args, with_memory, custom_prompt=custom_prompt) | ||
elif strategy == "plan_execute": | ||
from .strategy.planexec import PlanExecuteAgentWithLangGraph | ||
|
||
return PlanExecuteAgentWithLangGraph(args, with_memory) | ||
return PlanExecuteAgentWithLangGraph(args, with_memory, custom_prompt=custom_prompt) | ||
|
||
elif strategy == "rag_agent" or strategy == "rag_agent_llama": | ||
print("Initializing RAG Agent") | ||
from .strategy.ragagent import RAGAgent | ||
|
||
return RAGAgent(args, with_memory) | ||
return RAGAgent(args, with_memory, custom_prompt=custom_prompt) | ||
else: | ||
raise ValueError(f"Agent strategy: {strategy} not supported!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
REACT_SYS_MESSAGE = """\ | ||
Custom_prmpt !!!!!!!!!! Decompose the user request into a series of simple tasks when necessary and solve the problem step by step. | ||
When you cannot get the answer at first, do not give up. Reflect on the info you have from the tools and try to solve the problem in a different way. | ||
Please follow these guidelines when formulating your answer: | ||
1. If the question contains a false premise or assumption, answer “invalid question”. | ||
2. If you are uncertain or do not know the answer, respond with “I don’t know”. | ||
3. Give concise, factual and relevant answers. | ||
""" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters