Skip to content

Commit

Permalink
fix: Lista de messages não estava retornando corretamente
Browse files Browse the repository at this point in the history
O metodo .extend é inplace, como estava sendo utilizado em uma lista que
não tinha sido criada, estava retornando null

related #1
  • Loading branch information
RWallan committed May 23, 2024
1 parent e9e6b40 commit e628d1a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions openiziai/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,19 @@ def prompt(
Returns:
PromptResponse: Informações do prompt construído.
"""
messages = [{'role': 'system', 'content': self._template}]
if history:
_history = [m.model_dump() for m in history]
messages = [{'role': 'system', 'content': self._template}].extend(
_history
)
messages.extend(_history)
_prompt = _history[-1].get('content')
elif prompt:
_prompt = prompt
messages = [
{
'role': 'system',
'content': self._template,
},
messages.extend([
{
'role': 'user',
'content': _prompt,
},
]
])
else:
raise ValueError('`prompt` ou `history` precisam ser passados.')

Expand Down

0 comments on commit e628d1a

Please sign in to comment.