Skip to content

Commit

Permalink
add qwen model (InternLM#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
liujiangning30 authored Aug 2, 2024
1 parent 6b67975 commit 515596d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mindsearch/agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def init_agent(lang='cn', model_format='internlm_server'):

interpreter_prompt = GRAPH_PROMPT_CN if lang == 'cn' else GRAPH_PROMPT_EN
plugin_prompt = searcher_system_prompt_cn if lang == 'cn' else searcher_system_prompt_en
if model_format == 'gpt4':
if not model_format.lower().startswith('internlm'):
interpreter_prompt += graph_fewshot_example_cn if lang == 'cn' else graph_fewshot_example_en
plugin_prompt += fewshot_example_cn if lang == 'cn' else fewshot_example_en

Expand Down
1 change: 1 addition & 0 deletions mindsearch/agent/mindsearch_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def stream_chat(self, message, **kwargs):
agent_return.inner_steps = deepcopy(inner_history)
for _ in range(self.max_turn):
prompt = self._protocol.format(inner_step=inner_history)
code = None
for model_state, response, _ in self.llm.stream_chat(
prompt, session_id=random.randint(0, 999999), **kwargs):
if model_state.value < 0:
Expand Down
18 changes: 18 additions & 0 deletions mindsearch/agent/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,21 @@
gpt4 = dict(type=GPTAPI,
model_type='gpt-4-turbo',
key=os.environ.get('OPENAI_API_KEY', 'YOUR OPENAI API KEY'))

url = 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation'
qwen = dict(type=GPTAPI,
model_type='qwen-turbo',
key=os.environ.get('QWEN_API_KEY', 'YOUR QWEN API KEY'),
openai_api_base=url,
meta_template=[
dict(role='system', api_role='system'),
dict(role='user', api_role='user'),
dict(role='assistant', api_role='assistant'),
dict(role='environment', api_role='tool')
],
top_p=0.8,
top_k=1,
temperature=0,
max_new_tokens=8192,
repetition_penalty=1.02,
stop_words=['<|im_end|>'])

0 comments on commit 515596d

Please sign in to comment.