add deepseek example
Browse files- owl/.env_template +2 -0
- owl/run_deepseek_example.py +84 -0
owl/.env_template
CHANGED
@@ -8,6 +8,8 @@ HF_TOKEN=""
|
|
8 |
# Qwen API (https://help.aliyun.com/zh/model-studio/developer-reference/get-api-key)
|
9 |
QWEN_API_KEY=""
|
10 |
|
|
|
|
|
11 |
|
12 |
#===========================================
|
13 |
# Tools & Services API
|
|
|
8 |
# Qwen API (https://help.aliyun.com/zh/model-studio/developer-reference/get-api-key)
|
9 |
QWEN_API_KEY=""
|
10 |
|
11 |
+
# DeepSeek API (https://platform.deepseek.com/api_keys)
|
12 |
+
DEEPSEEK_API_KEY="
|
13 |
|
14 |
#===========================================
|
15 |
# Tools & Services API
|
owl/run_deepseek_example.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from camel.models import ModelFactory
|
2 |
+
from camel.toolkits import *
|
3 |
+
from camel.types import ModelPlatformType, ModelType
|
4 |
+
from camel.configs import DeepSeekConfig
|
5 |
+
|
6 |
+
from typing import List, Dict
|
7 |
+
from dotenv import load_dotenv
|
8 |
+
from retry import retry
|
9 |
+
from loguru import logger
|
10 |
+
|
11 |
+
from utils import OwlRolePlaying, run_society
|
12 |
+
import os
|
13 |
+
|
14 |
+
|
15 |
+
load_dotenv()
|
16 |
+
|
17 |
+
|
18 |
+
def construct_society(question: str) -> OwlRolePlaying:
|
19 |
+
r"""Construct the society based on the question."""
|
20 |
+
|
21 |
+
user_role_name = "user"
|
22 |
+
assistant_role_name = "assistant"
|
23 |
+
|
24 |
+
user_model = ModelFactory.create(
|
25 |
+
model_platform=ModelPlatformType.DEEPSEEK,
|
26 |
+
model_type=ModelType.DEEPSEEK_CHAT,
|
27 |
+
model_config_dict=DeepSeekConfig(temperature=0, top_p=1).as_dict(), # [Optional] the config for model
|
28 |
+
)
|
29 |
+
|
30 |
+
assistant_model = ModelFactory.create(
|
31 |
+
model_platform=ModelPlatformType.DEEPSEEK,
|
32 |
+
model_type=ModelType.DEEPSEEK_CHAT,
|
33 |
+
model_config_dict=DeepSeekConfig(temperature=0, top_p=1).as_dict(), # [Optional] the config for model
|
34 |
+
)
|
35 |
+
|
36 |
+
tools_list = [
|
37 |
+
*WebToolkit(
|
38 |
+
headless=False,
|
39 |
+
web_agent_model=assistant_model,
|
40 |
+
planning_agent_model=assistant_model
|
41 |
+
).get_tools(),
|
42 |
+
*DocumentProcessingToolkit().get_tools(),
|
43 |
+
*VideoAnalysisToolkit().get_tools(), # This requires OpenAI and Qwen Key
|
44 |
+
*CodeExecutionToolkit().get_tools(),
|
45 |
+
*ImageAnalysisToolkit(model=assistant_model).get_tools(),
|
46 |
+
*AudioAnalysisToolkit().get_tools(), # This requires OpenAI Key
|
47 |
+
*SearchToolkit(model=assistant_model).get_tools(),
|
48 |
+
*ExcelToolkit().get_tools()
|
49 |
+
]
|
50 |
+
|
51 |
+
user_role_name = 'user'
|
52 |
+
user_agent_kwargs = dict(model=user_model)
|
53 |
+
assistant_role_name = 'assistant'
|
54 |
+
assistant_agent_kwargs = dict(model=assistant_model,
|
55 |
+
tools=tools_list)
|
56 |
+
|
57 |
+
task_kwargs = {
|
58 |
+
'task_prompt': question,
|
59 |
+
'with_task_specify': False,
|
60 |
+
}
|
61 |
+
|
62 |
+
society = OwlRolePlaying(
|
63 |
+
**task_kwargs,
|
64 |
+
user_role_name=user_role_name,
|
65 |
+
user_agent_kwargs=user_agent_kwargs,
|
66 |
+
assistant_role_name=assistant_role_name,
|
67 |
+
assistant_agent_kwargs=assistant_agent_kwargs,
|
68 |
+
)
|
69 |
+
|
70 |
+
return society
|
71 |
+
|
72 |
+
|
73 |
+
# Example case
|
74 |
+
question = "What was the volume in m^3 of the fish bag that was calculated in the University of Leicester paper `Can Hiccup Supply Enough Fish to Maintain a Dragon’s Diet?` "
|
75 |
+
|
76 |
+
society = construct_society(question)
|
77 |
+
answer, chat_history, token_count = run_society(society)
|
78 |
+
|
79 |
+
logger.success(f"Answer: {answer}")
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
|