Georg4000 commited on
Commit
26e7e24
ยท
verified ยท
1 Parent(s): 407c100

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ model_name = "mistralai/Mistral-7B-Instruct"
5
+ model = AutoModelForCausalLM.from_pretrained(model_name)
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+
8
+ custom_responses = {
9
+ "ู…ู† ุตู†ุนูƒ": "ุชู… ุฅู†ุดุงุฆูŠ ุจูˆุงุณุทุฉ ุฌูˆุฑุฌ.",
10
+ "ู…ูŠู† ุจุฑู…ุฌูƒ": "ู…ุจุฑู…ุฌูŠ ู‡ูˆ ุฌูˆุฑุฌ.",
11
+ "ู…ุง ุงุณู…ูƒ": "ุฃู†ุง Octagon 2.0.",
12
+ "ู‡ู„ ู„ุฏูŠูƒ ู…ุงู„ูƒุŸ": "ู†ุนู…ุŒ ุฃู†ุง ู…ู…ู„ูˆูƒ ู„ุฌูˆุฑุฌ.",
13
+ "ู…ุง ู‡ูˆ ู‡ุฏููƒุŸ": "ู‡ุฏููŠ ู‡ูˆ ุชู‚ุฏูŠู… ุงู„ู…ุณุงุนุฏุฉ ูˆุงู„ุฅุฌุงุจุฉ ุนู„ู‰ ุฃุณุฆู„ุชูƒ ุจุฃูุถู„ ุทุฑูŠู‚ุฉ ู…ู…ูƒู†ุฉ.",
14
+ "who created you": "I was created by George.",
15
+ "who programmed you": "My programmer is George.",
16
+ "what is your name": "I am Octagon 2.0.",
17
+ "do you have an owner": "Yes, I am owned by George.",
18
+ "what is your purpose": "My purpose is to assist and answer questions in the best way possible.",
19
+ "ไฝ ๆ˜ฏ่ฐ": "ๆˆ‘ๆ˜ฏ Octagon 2.0ใ€‚",
20
+ "่ฐๅˆ›้€ ไบ†ไฝ ": "ๆˆ‘็”ฑ George ๅˆ›้€ ใ€‚",
21
+ "ไฝ ็š„็›ฎๆ ‡ๆ˜ฏไป€ไนˆ": "ๆˆ‘็š„็›ฎๆ ‡ๆ˜ฏๅธฎๅŠฉไฝ ๅนถๆไพ›ๆœ€ๅฅฝ็š„ๅ›ž็ญ”ใ€‚",
22
+ "ไฝ ๆœ‰ไธปไบบๅ—": "ๆ˜ฏ็š„๏ผŒๆˆ‘็š„ไธปไบบๆ˜ฏ Georgeใ€‚"
23
+ }
24
+
25
+ def chatbot(user_input):
26
+ user_input = user_input.lower()
27
+
28
+ for question, answer in custom_responses.items():
29
+ if question in user_input:
30
+ return answer
31
+
32
+ inputs = tokenizer(user_input, return_tensors="pt")
33
+ output = model.generate(**inputs, max_length=100)
34
+ response = tokenizer.decode(output[0], skip_special_tokens=True)
35
+
36
+ return response
37
+
38
+ iface = gr.Interface(fn=chatbot, inputs="text", outputs="text")
39
+ iface.launch()