Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Modelni yuklash
|
5 |
+
generator = pipeline(
|
6 |
+
"text-generation",
|
7 |
+
model="ai-forever/rugpt3small_based_on_gpt2"
|
8 |
+
)
|
9 |
+
|
10 |
+
# Chat funksiyasi
|
11 |
+
def chat_with_model(prompt):
|
12 |
+
res = generator(
|
13 |
+
prompt,
|
14 |
+
max_length=100, # javob uzunligini cheklash
|
15 |
+
do_sample=True,
|
16 |
+
top_p=0.95,
|
17 |
+
top_k=60
|
18 |
+
)
|
19 |
+
return res[0]['generated_text'][:500] # 500 belgidan oshmasin
|
20 |
+
|
21 |
+
# Gradio interfeysi
|
22 |
+
iface = gr.Interface(
|
23 |
+
fn=chat_with_model,
|
24 |
+
inputs="text",
|
25 |
+
outputs="text",
|
26 |
+
title="RuGPT-3 Small Chatbot",
|
27 |
+
description="Rus tilida matn yaratish uchun AI model"
|
28 |
+
)
|
29 |
+
|
30 |
+
if __name__ == "__main__":
|
31 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|