Update app.py
Browse files
app.py
CHANGED
|
@@ -1,46 +1,17 @@
|
|
| 1 |
-
|
| 2 |
-
for row in board:
|
| 3 |
-
print(" | ".join(row))
|
| 4 |
-
print("-" * 9)
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
for i in range(3):
|
| 9 |
-
if all(cell == player for cell in board[i]) or all(board[j][i] == player for j in range(3)):
|
| 10 |
-
return True
|
| 11 |
-
if all(board[i][i] == player for i in range(3)) or all(board[i][2 - i] == player for i in range(3)):
|
| 12 |
-
return True
|
| 13 |
-
return False
|
| 14 |
|
| 15 |
-
|
| 16 |
-
return all(cell != " " for row in board for cell in row)
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
row = int(input(f"Player {current_player}, enter row (0, 1, or 2): "))
|
| 28 |
-
col = int(input(f"Player {current_player}, enter column (0, 1, or 2): "))
|
| 29 |
-
|
| 30 |
-
if board[row][col] == " ":
|
| 31 |
-
board[row][col] = current_player
|
| 32 |
-
if check_winner(board, current_player):
|
| 33 |
-
print_board(board)
|
| 34 |
-
print(f"Player {current_player} wins! Congratulations!")
|
| 35 |
-
break
|
| 36 |
-
elif check_tie(board):
|
| 37 |
-
print_board(board)
|
| 38 |
-
print("It's a tie! Well played.")
|
| 39 |
-
break
|
| 40 |
-
else:
|
| 41 |
-
current_player = "O" if current_player == "X" else "X"
|
| 42 |
-
else:
|
| 43 |
-
print("Cell already occupied. Try again.")
|
| 44 |
-
|
| 45 |
-
if __name__ == "__main__":
|
| 46 |
-
tic_tac_toe()
|
|
|
|
| 1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
|
|
|
|
| 7 |
|
| 8 |
+
messages = [
|
| 9 |
+
{"role": "user", "content": "What is your favourite condiment?"},
|
| 10 |
+
{"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
|
| 11 |
+
{"role": "user", "content": "Do you have mayonnaise recipes?"}
|
| 12 |
+
]
|
| 13 |
|
| 14 |
+
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
|
| 15 |
|
| 16 |
+
outputs = model.generate(inputs, max_new_tokens=20)
|
| 17 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|