Skip to content

Commit

Permalink
bugfix gen_keyword for doc_qa
Browse files Browse the repository at this point in the history
  • Loading branch information
JianxinMa committed Feb 16, 2024
1 parent c9dfe77 commit 59a0e47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
7 changes: 3 additions & 4 deletions qwen_agent/llm/oai.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ def __init__(self, cfg: Optional[Dict] = None):
),
).strip()

api_key = self.cfg.get(
'api_key',
os.getenv('OPENAI_API_KEY', 'EMPTY'),
).strip()
api_key = self.cfg.get('api_key', '').strip()
if not api_key:
api_key = os.getenv('OPENAI_API_KEY', 'EMPTY').strip()

if openai.__version__.startswith('0.'):
if api_base:
Expand Down
8 changes: 4 additions & 4 deletions qwen_agent/llm/qwen_dashscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def __init__(self, cfg: Optional[Dict] = None):
super().__init__(cfg)

self.model = self.cfg.get('model', 'qwen-max')
dashscope.api_key = self.cfg.get(
'api_key',
os.getenv('DASHSCOPE_API_KEY', 'EMPTY'),
).strip()
api_key = self.cfg.get('api_key', '').strip()
if not api_key:
api_key = os.getenv('DASHSCOPE_API_KEY', 'EMPTY').strip()
dashscope.api_key = api_key

def _chat_stream(
self,
Expand Down
8 changes: 4 additions & 4 deletions qwen_agent/llm/qwenvl_dashscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def __init__(self, cfg: Optional[Dict] = None):
super().__init__(cfg)

self.model = self.cfg.get('model', 'qwen-vl-max')
dashscope.api_key = self.cfg.get(
'api_key',
os.getenv('DASHSCOPE_API_KEY', 'EMPTY'),
).strip()
api_key = self.cfg.get('api_key', '').strip()
if not api_key:
api_key = os.getenv('DASHSCOPE_API_KEY', 'EMPTY').strip()
dashscope.api_key = api_key

def _chat_stream(
self,
Expand Down
9 changes: 5 additions & 4 deletions qwen_agent/prompts/gen_keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ def __init__(self,
llm: Optional[Union[Dict, BaseChatModel]] = None,
system_message: Optional[str] = DEFAULT_SYSTEM_MESSAGE,
**kwargs):
llm = copy.deepcopy(llm)
if isinstance(llm, dict):
llm = get_chat_model(llm)
llm.generate_cfg['stop'].append('Observation:')
if llm is not None: # TODO: Why this happens?
llm = copy.deepcopy(llm)
if isinstance(llm, dict):
llm = get_chat_model(llm)
llm.generate_cfg['stop'].append('Observation:')
super().__init__(function_list, llm, system_message, **kwargs)

def _run(self,
Expand Down

0 comments on commit 59a0e47

Please sign in to comment.