Spaces:
Sleeping
Sleeping
Delete app.py
#2
by
geyik1
- opened
app.py
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import google.generativeai as genai
|
3 |
-
import os
|
4 |
-
from google.api_core import client_options
|
5 |
-
|
6 |
-
# API yapılandırması
|
7 |
-
options = client_options.ClientOptions(
|
8 |
-
api_endpoint='generativelanguage.googleapis.com'
|
9 |
-
)
|
10 |
-
|
11 |
-
# API anahtarını güvenli bir şekilde saklayın ve yapılandırın
|
12 |
-
api_key = os.getenv('GOOGLE_API_KEY')
|
13 |
-
if not api_key:
|
14 |
-
print("GOOGLE_API_KEY bulunamadı!")
|
15 |
-
|
16 |
-
genai.configure(
|
17 |
-
api_key=api_key,
|
18 |
-
client_options=options,
|
19 |
-
transport='rest'
|
20 |
-
)
|
21 |
-
|
22 |
-
def list_models():
|
23 |
-
try:
|
24 |
-
for m in genai.list_models():
|
25 |
-
print(m.name)
|
26 |
-
except Exception as e:
|
27 |
-
print(f"Model listesi alınamadı: {str(e)}")
|
28 |
-
|
29 |
-
def generate_response(q1, q2, q3, q4, q5, q6, q7, q8, q9, q10):
|
30 |
-
if not api_key:
|
31 |
-
return "API anahtarı bulunamadı. Lütfen GOOGLE_API_KEY environment variable'ını kontrol edin."
|
32 |
-
|
33 |
-
# Sabit prompt template
|
34 |
-
template = """Create an idea for a mobile game of genre {Q2}, targeting {Q1} gamers as the target audience. This game should have the potential to retain users for at least 30 days and offer an innovative experience. Use a unique, fun and potential theme (e.g. {Q3}) for the game concept. Design user-friendly and engaging core game mechanics {Q4} suitable for {Q1} and enrich these mechanics with a unique twist. Propose a system for player progression (e.g. unlocking new regions, characters or items). The game's monetization model can take the form of {Q5}, which should be both player-friendly and include elements that can generate sustainable revenue, such as ads, in-game purchases or subscriptions, depending on the structure of the game. Add features to incentivize daily player engagement or create long-term commitment (e.g. special events, challenges, leaderboards or multiplayer elements). Explain the key elements that differentiate the reference {Q6} game(s) from existing games in the market and how it differs. Mention why the target audience would be interested in this game concept. Use art language such as {Q7}. Consider technical limitations when designing the prototype, such as development with {Q8}. You can use {Q9} as a game control system.
|
35 |
-
|
36 |
-
First, provide a detailed ideation of the game concept in several paragraphs, explaining:
|
37 |
-
- The core game concept and what makes it unique
|
38 |
-
- How it differs from existing games, especially {Q6}
|
39 |
-
- Why the target audience would be interested
|
40 |
-
- The key features and mechanics that will drive retention
|
41 |
-
- The progression and monetization strategy
|
42 |
-
- The visual and technical approach
|
43 |
-
|
44 |
-
Then, provide a detailed Game Design Document (GDD) with the following sections:
|
45 |
-
|
46 |
-
1- Ideation Method
|
47 |
-
2- Platform
|
48 |
-
3- Genre
|
49 |
-
4- Game Brief & Core Loop
|
50 |
-
5- Mechanics
|
51 |
-
6- Monetization Models
|
52 |
-
7- Theme
|
53 |
-
8- Strength
|
54 |
-
9- Player Feeling
|
55 |
-
10- Control
|
56 |
-
11- Art Style
|
57 |
-
12- Characters
|
58 |
-
13- Props
|
59 |
-
14- Collectible Items
|
60 |
-
15- Obstacles
|
61 |
-
16- Camera Angels
|
62 |
-
17- Environment
|
63 |
-
18- Win/Loss Conditions
|
64 |
-
19- References
|
65 |
-
20- UI/UX
|
66 |
-
21- Level Design
|
67 |
-
22- Additional Notes
|
68 |
-
|
69 |
-
Finally, create a detailed backlog of technical tasks that would be needed to implement this game design.
|
70 |
-
|
71 |
-
Please provide this response in {Q10}."""
|
72 |
-
|
73 |
-
# Kullanıcı inputlarını template'e yerleştir
|
74 |
-
prompt = template.format(
|
75 |
-
Q1=q1, Q2=q2, Q3=q3, Q4=q4, Q5=q5,
|
76 |
-
Q6=q6, Q7=q7, Q8=q8, Q9=q9, Q10=q10
|
77 |
-
)
|
78 |
-
|
79 |
-
try:
|
80 |
-
# Model yapılandırması
|
81 |
-
generation_config = {
|
82 |
-
"temperature": 0.9,
|
83 |
-
"top_p": 1,
|
84 |
-
"top_k": 1,
|
85 |
-
"max_output_tokens": 2048,
|
86 |
-
}
|
87 |
-
|
88 |
-
# Gemini modelini çağır
|
89 |
-
model = genai.GenerativeModel(
|
90 |
-
model_name="models/gemini-1.5-pro", # Güncellenmiş model adı
|
91 |
-
generation_config=generation_config
|
92 |
-
)
|
93 |
-
|
94 |
-
# Test mesajı gönder
|
95 |
-
test_response = model.generate_content("Test connection")
|
96 |
-
if not test_response or not hasattr(test_response, 'text'):
|
97 |
-
return "Model bağlantısı başarısız. Lütfen daha sonra tekrar deneyin."
|
98 |
-
|
99 |
-
# Asıl içeriği oluştur
|
100 |
-
response = model.generate_content(prompt)
|
101 |
-
|
102 |
-
if response and hasattr(response, 'text'):
|
103 |
-
return response.text
|
104 |
-
else:
|
105 |
-
return "API yanıt verdi fakat içerik boş. Lütfen tekrar deneyin."
|
106 |
-
|
107 |
-
except Exception as e:
|
108 |
-
print(f"Hata detayı: {str(e)}")
|
109 |
-
return f"Bir hata oluştu: {str(e)}\nLütfen API anahtarınızı ve bağlantınızı kontrol edin."
|
110 |
-
|
111 |
-
# Gradio arayüzü
|
112 |
-
iface = gr.Interface(
|
113 |
-
fn=generate_response,
|
114 |
-
inputs=[
|
115 |
-
gr.Textbox(label="Hedef Kitle", placeholder="örn. Mobil"),
|
116 |
-
gr.Textbox(label="Oyun Türü", placeholder="örn. Casual"),
|
117 |
-
gr.Textbox(label="Tema", placeholder="örn. Puzzle"),
|
118 |
-
gr.Textbox(label="Temel Mekanik", placeholder="örn. Match-3"),
|
119 |
-
gr.Textbox(label="Monetizasyon", placeholder="örn. RV, IAP, Subscription"),
|
120 |
-
gr.Textbox(label="Referans Oyun", placeholder="örn. Royal Match"),
|
121 |
-
gr.Textbox(label="Sanat Stili", placeholder="örn. Cartoon"),
|
122 |
-
gr.Textbox(label="Teknoloji", placeholder="örn. Unity"),
|
123 |
-
gr.Textbox(label="Kontrol Sistemi", placeholder="örn. Tap"),
|
124 |
-
gr.Textbox(label="Yanıt Dili", placeholder="örn. Turkish")
|
125 |
-
],
|
126 |
-
outputs="text",
|
127 |
-
title="Oyun Tasarım Asistanı",
|
128 |
-
description="Oyun fikirlerinizi geliştirmek için yapay zeka destekli bir asistan."
|
129 |
-
)
|
130 |
-
|
131 |
-
if __name__ == "__main__":
|
132 |
-
print("=== Uygulama Başlatılıyor ===")
|
133 |
-
list_models() # Mevcut modelleri listele
|
134 |
-
iface.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|