Skip to content

Commit

Permalink
Add some extra logging
Browse files Browse the repository at this point in the history
  • Loading branch information
marekzp committed Sep 13, 2024
1 parent 9de3fcd commit 8f1c72c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions llm-debate/debater.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import logging
from typing import List

logger = logging.getLogger(__name__)


class Debater:
def __init__(
Expand All @@ -15,8 +18,10 @@ def __init__(
self.position: str = position
self.responses: List[str] = []
self.debate_history: List[str] = []
logger.info(f"{position} debater initialized")

def start(self) -> str:
logger.info(f"Starting debate as {self.position} position")
initial_prompt: str = (
f"You are participating in a debate on the topic: '{self.topic}'. "
f"You are {self.position} the proposition. Make a convincing opening "
Expand All @@ -28,9 +33,11 @@ def start(self) -> str:
self.debate_history.append(
f"{self.position.capitalize()} opening argument: {response}"
)
logger.info(f"Opening argument generated for {self.position} position")
return response

def respond_to(self, opponent_argument: str) -> str:
logger.info(f"Generating response for {self.position} position")
self.debate_history.append(f"Opponent's argument: {opponent_argument}")

prompt: str = (
Expand All @@ -49,9 +56,12 @@ def respond_to(self, opponent_argument: str) -> str:
response: str = self.llm_client.get_response(prompt, self.model)
self.responses.append(response)
self.debate_history.append(f"{self.position.capitalize()} response: {response}")
logger.info(f"Response generated for {self.position} position")

return response

def conclude(self) -> str:
logger.info(f"Generating conclusion for {self.position} position")
prompt: str = (
f"You have been participating in a debate on the topic: '{self.topic}'. "
f"You are {self.position} the proposition. Here's the entire debate "
Expand All @@ -67,4 +77,6 @@ def conclude(self) -> str:
self.debate_history.append(
f"{self.position.capitalize()} conclusion: {response}"
)
logger.info(f"Conclusion generated for {self.position} position")

return response

0 comments on commit 8f1c72c

Please sign in to comment.