Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Add output language to Agents (#214)

Dmitrii Khizbullin5b0bfc230b00
diff --git a/apps/agents/agents.py b/apps/agents/agents.py
index 94bb188ff..3ae75a4a3 100644
--- a/apps/agents/agents.py
+++ b/apps/agents/agents.py
@@ -135,6 +135,7 @@ def role_playing_start(
max_messages: float,
with_task_specifier: bool,
word_limit: int,
+ language: str,
) -> Union[Dict, Tuple[State, str, Union[str, Dict], ChatBotHistory, Dict]]:
""" Creates a role playing session.
@@ -193,6 +194,7 @@ def role_playing_start(
task_type=task_type,
extend_sys_msg_meta_dicts=extend_sys_msg_meta_dicts,
extend_task_specify_meta_dict=meta_dict,
+ output_language=language,
)
except (openai.error.RateLimitError, tenacity.RetryError,
RuntimeError) as ex:
@@ -436,10 +438,13 @@ def construct_ui(blocks, api_key: Optional[str] = None) -> None:
label="Word limit for task specifier",
visible=task_specifier_cb.value)
with gr.Column():
- num_messages_sl = gr.Slider(minimum=1, maximum=50, step=1,
- value=10, interactive=True,
- label="Messages to generate")
-
+ with gr.Row():
+ num_messages_sl = gr.Slider(minimum=1, maximum=50, step=1,
+ value=10, interactive=True,
+ label="Messages to generate")
+ with gr.Row():
+ language_ta = gr.TextArea(label="Language", value="English",
+ lines=1, interactive=True)
with gr.Column(scale=2):
with gr.Row():
start_bn = gr.Button("Make agents chat [takes time]",
@@ -454,7 +459,8 @@ def construct_ui(blocks, api_key: Optional[str] = None) -> None:
task_prompt_ta = gr.TextArea(label="Planned task prompt", lines=1,
interactive=False, visible=False)
chatbot = gr.Chatbot(label="Chat between autonomous agents")
- session_state = gr.State(State.empty())
+ empty_state = State.empty()
+ session_state: gr.State = gr.State(empty_state)
universal_task_bn.click(lambda: "Help me to do my job", None,
original_task_ta)
@@ -467,7 +473,7 @@ def construct_ui(blocks, api_key: Optional[str] = None) -> None:
.then(role_playing_start,
[session_state, society_dd, assistant_ta, user_ta,
original_task_ta, num_messages_sl,
- task_specifier_cb, ts_word_limit_nb],
+ task_specifier_cb, ts_word_limit_nb, language_ta],
[session_state, specified_task_ta, task_prompt_ta,
chatbot, progress_sl],
queue=False) \
diff --git a/apps/agents/test/test_agents.py b/apps/agents/test/test_agents.py
index 72154374c..423cd2cff 100644
--- a/apps/agents/test/test_agents.py
+++ b/apps/agents/test/test_agents.py
@@ -57,10 +57,11 @@ def test_session():
max_messages = 10
with_task_specifier = False
word_limit = 50
+ language = "English"
state, specified_task_prompt, planned_task_upd, chat, progress_upd = \
role_playing_start(state, society_name, assistant, user,
original_task, max_messages,
- with_task_specifier, word_limit)
+ with_task_specifier, word_limit, language)
assert state.session is not None