GIGAParviz commited on
Commit
ef988e9
·
verified ·
1 Parent(s): 482b0de

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -38
app.py DELETED
@@ -1,38 +0,0 @@
1
- import gradio as gr
2
- from groq import Groq
3
- import time
4
-
5
- client = Groq(api_key="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")
6
-
7
- CONTEXT = (
8
- "This is a conversation with ParvizGPT. It is an artificial intelligence model designed by Amir Mahdi Parviz, "
9
- "an NLP expert, to help you with various tasks such as answering questions in persian, "
10
- "providing recommendations, and assisting with decision-making. Ask it anything!"
11
- )
12
-
13
- def generate_response(message, chat_history):
14
- full_message = CONTEXT + f"\nYou: {message}به فارسی بگو\nParvizGPT: "
15
-
16
- chat_completion = client.chat.completions.create(
17
- messages=[{"role": "user", "content": full_message}],
18
- model= "llama-3.1-8b-instant",
19
- )
20
- bot_message = chat_completion.choices[0].message.content
21
-
22
- for i in range(0, len(bot_message), 10):
23
- yield chat_history + [(message, bot_message[:i + 10])]
24
- time.sleep(0.1)
25
-
26
- yield chat_history + [(message, bot_message)]
27
-
28
- with gr.Blocks() as demo:
29
- gr.Markdown("<h1 style='text-align: center;'>💬 Parviz GPT</h1><p style='text-align: center; color: #e0e0e0;'>زنده باد</p>")
30
-
31
- chatbot = gr.Chatbot(label="جواب")
32
- msg = gr.Textbox(label="ورودی", placeholder="اینجا یه چی بپرس... ", lines=1)
33
-
34
- msg.submit(generate_response, [msg, chatbot], chatbot)
35
-
36
- clear = gr.ClearButton([msg, chatbot])
37
-
38
- demo.launch()