Skip to content

Commit

Permalink
Implement compose_message_openai function
Browse files Browse the repository at this point in the history
  • Loading branch information
Flagro committed Dec 9, 2024
1 parent 0be0825 commit 71db4b6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bot/rp_bot/ai_agent/models_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,19 @@ def get_price(
+ image_generation_pixels * output_pixel_price
)

@staticmethod
def compose_message_openai(
message_text: str, role: Literal["user", "system"] = "user"
) -> Dict[str, str]:
return {"role": role, "content": message_text}

@staticmethod
def compose_messages_openai(
user_input: str, system_prompt: str
) -> List[Dict[str, str]]:
return [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_input},
ModelsToolkit.compose_message_openai(system_prompt, role="system"),
ModelsToolkit.compose_message_openai(user_input, role="user"),
]

async def get_response(self, question: str) -> str:
Expand Down

0 comments on commit 71db4b6

Please sign in to comment.