Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
-
import os
|
4 |
|
5 |
-
|
|
|
|
|
6 |
def respond(message):
|
7 |
try:
|
8 |
if not message.strip():
|
9 |
return "اكتبلي حاجة علشان أرد 😊"
|
10 |
|
11 |
response = openai.ChatCompletion.create(
|
12 |
-
model="gpt-3.5-turbo",
|
13 |
messages=[
|
14 |
-
{"role": "system", "content": "أنت شات بوت
|
15 |
{"role": "user", "content": message}
|
16 |
]
|
17 |
)
|
18 |
-
|
19 |
-
return reply
|
20 |
|
21 |
except Exception as e:
|
22 |
return f"حصلت مشكلة 😢: {str(e)}"
|
23 |
|
24 |
iface = gr.Interface(
|
25 |
fn=respond,
|
26 |
-
inputs=gr.Textbox(lines=1, placeholder="اسأل نونو أي
|
27 |
outputs=gr.Textbox(label="رد نونو"),
|
28 |
title="نونو شات بوت",
|
29 |
-
description="
|
30 |
)
|
31 |
|
32 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
import openai
|
|
|
3 |
|
4 |
+
# ✅ اكتبي مفتاح OpenAI الخاص بيك هنا
|
5 |
+
openai.api_key = "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"
|
6 |
+
|
7 |
def respond(message):
|
8 |
try:
|
9 |
if not message.strip():
|
10 |
return "اكتبلي حاجة علشان أرد 😊"
|
11 |
|
12 |
response = openai.ChatCompletion.create(
|
13 |
+
model="gpt-3.5-turbo",
|
14 |
messages=[
|
15 |
+
{"role": "system", "content": "أنت شات بوت للأطفال اسمه نونو، بترد بشكل مبسط وظريف."},
|
16 |
{"role": "user", "content": message}
|
17 |
]
|
18 |
)
|
19 |
+
return response.choices[0].message.content.strip()
|
|
|
20 |
|
21 |
except Exception as e:
|
22 |
return f"حصلت مشكلة 😢: {str(e)}"
|
23 |
|
24 |
iface = gr.Interface(
|
25 |
fn=respond,
|
26 |
+
inputs=gr.Textbox(lines=1, placeholder="اسأل نونو أي سؤال!"),
|
27 |
outputs=gr.Textbox(label="رد نونو"),
|
28 |
title="نونو شات بوت",
|
29 |
+
description="نونو بيرد على كل أسئلتك بطريقة بسيطة!"
|
30 |
)
|
31 |
|
32 |
if __name__ == "__main__":
|