Skip to content

Commit

Permalink
update system tokens.
Browse files Browse the repository at this point in the history
  • Loading branch information
shibing624 committed Apr 29, 2024
1 parent c56b61f commit ee61d40
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions openai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ModelList(BaseModel):


class ChatMessage(BaseModel):
role: Literal['user', 'assistant', 'system', 'function']
role: Literal['user', 'assistant', 'system', 'function', 'tool']
content: Optional[str] = None
tool_calls: Optional[Dict] = None

Expand Down Expand Up @@ -216,7 +216,7 @@ def parse_messages(messages, tools):
if messages[0].role == 'system':
system = messages.pop(0).content.lstrip('\n').rstrip()
else:
system = 'You are a helpful assistant.'
system = ''

if tools:
tools_text = []
Expand Down Expand Up @@ -371,7 +371,7 @@ def prepare_chat(tokenizer, query, history, system):
"""Prepare model inputs for chat completion."""
if prompt_template:
history_messages = history + [[query, ""]]
prompt = prompt_template.get_prompt(messages=history_messages)
prompt = prompt_template.get_prompt(messages=history_messages, system_prompt=system)
else:
messages = [
{"role": "system", "content": system}
Expand Down

0 comments on commit ee61d40

Please sign in to comment.