Log as markdown
This commit is contained in:
@@ -14,7 +14,7 @@ def main():
|
|||||||
exit
|
exit
|
||||||
opponents_answer = "Du bist der erste Teilnehmer in der ersten Runde. Was ist deine Meinung zum Thema?"
|
opponents_answer = "Du bist der erste Teilnehmer in der ersten Runde. Was ist deine Meinung zum Thema?"
|
||||||
|
|
||||||
for i in range(4):
|
for i in range(20):
|
||||||
print(f"Round {i+1}")
|
print(f"Round {i+1}")
|
||||||
|
|
||||||
for participant in participants:
|
for participant in participants:
|
||||||
|
|||||||
+19
-4
@@ -24,7 +24,11 @@ class Participant:
|
|||||||
self.name = f"""{name} {fake.name()}"""
|
self.name = f"""{name} {fake.name()}"""
|
||||||
self.client = Mistral(api_key=api_key)
|
self.client = Mistral(api_key=api_key)
|
||||||
self.role_description = role_description
|
self.role_description = role_description
|
||||||
os.remove(f"log/{self.__class__.__name__}.txt")
|
|
||||||
|
try:
|
||||||
|
os.remove(f"log/{self.__class__.__name__}.md")
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
self.messages = [{"role": "system", "content": basic_instruction},
|
self.messages = [{"role": "system", "content": basic_instruction},
|
||||||
{"role": "system", "content": self.role_description}]
|
{"role": "system", "content": self.role_description}]
|
||||||
@@ -33,6 +37,7 @@ class Participant:
|
|||||||
self.messages.append({"role": "user", "content": question})
|
self.messages.append({"role": "user", "content": question})
|
||||||
|
|
||||||
response = self.client.chat.complete(
|
response = self.client.chat.complete(
|
||||||
|
temperature=0.7,
|
||||||
model="mistral-large-latest",
|
model="mistral-large-latest",
|
||||||
messages=self.messages)
|
messages=self.messages)
|
||||||
|
|
||||||
@@ -44,10 +49,20 @@ class Participant:
|
|||||||
return answer
|
return answer
|
||||||
|
|
||||||
def write_to_file(self, filename, messages):
|
def write_to_file(self, filename, messages):
|
||||||
with open(f"log/{filename}.txt", "w") as file:
|
with open(f"log/{filename}.md", "w") as file:
|
||||||
for message in messages:
|
for message in messages:
|
||||||
file.write(f"{message['role']}: {message['content']}\n\n")
|
role = "unknown"
|
||||||
file.write("----------------------------------------------------------\n\n")
|
match message['role']:
|
||||||
|
case "system":
|
||||||
|
role = "System Prompt"
|
||||||
|
case "user":
|
||||||
|
role = "Gegnerische Antwort"
|
||||||
|
case "assistant":
|
||||||
|
role = "Meine Antwort"
|
||||||
|
|
||||||
|
file.write(f"## {role}\n")
|
||||||
|
|
||||||
|
file.write(f"{message['content']}\n\n")
|
||||||
|
|
||||||
|
|
||||||
class ProParticipant(Participant):
|
class ProParticipant(Participant):
|
||||||
|
|||||||
Reference in New Issue
Block a user