RAAZIM commited on
Commit
035004c
·
verified ·
1 Parent(s): 574add2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -33
app.py CHANGED
@@ -1,33 +1,47 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
-
4
- # 1. Load the GPT-Neo model (free to use)
5
- generator = pipeline("text-generation", model="EleutherAI/gpt-neo-1.3B")
6
-
7
- # 2. Create multi-turn chat memory
8
- history = []
9
-
10
- def chat(input_text):
11
- global history
12
- # Add user input to history
13
- history.append(f"User: {input_text}")
14
- # Prepare prompt with conversation history
15
- prompt = "\n".join(history) + "\nAI:"
16
- # Generate response
17
- response = generator(prompt, max_length=200, do_sample=True, temperature=0.7)
18
- ai_text = response[0]["generated_text"]
19
- # Add AI response to history
20
- history.append(f"AI: {ai_text}")
21
- return ai_text
22
-
23
- # 3. Gradio interface
24
- iface = gr.Interface(
25
- fn=chat,
26
- inputs=gr.Textbox(lines=2, placeholder="Type your message here..."),
27
- outputs="text",
28
- title="AltisBot", # <-- Your chatbot name here
29
- description="Your free AI assistant chatbot"
30
- )
31
-
32
- # 4. Launch the interface
33
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Install the Hugging Face CLI
3
+ powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"
4
+
5
+ # (optional) Login with your Hugging Face credentials
6
+ hf auth login
7
+
8
+ # Push your model files
9
+ hf upload RAAZIM/RT-AI .
10
+
11
+
12
+
13
+
14
+
15
+ import gradio as gr
16
+ from transformers import pipeline
17
+
18
+ # 1. Load the GPT-Neo model (free to use)
19
+ generator = pipeline("text-generation", model="EleutherAI/gpt-neo-1.3B")
20
+
21
+ # 2. Create multi-turn chat memory
22
+ history = []
23
+
24
+ def chat(input_text):
25
+ global history
26
+ # Add user input to history
27
+ history.append(f"User: {input_text}")
28
+ # Prepare prompt with conversation history
29
+ prompt = "\n".join(history) + "\nAI:"
30
+ # Generate response
31
+ response = generator(prompt, max_length=200, do_sample=True, temperature=0.7)
32
+ ai_text = response[0]["generated_text"]
33
+ # Add AI response to history
34
+ history.append(f"AI: {ai_text}")
35
+ return ai_text
36
+
37
+ # 3. Gradio interface
38
+ iface = gr.Interface(
39
+ fn=chat,
40
+ inputs=gr.Textbox(lines=2, placeholder="Type your message here..."),
41
+ outputs="text",
42
+ title="AltisBot", # <-- Your chatbot name here
43
+ description="Your free AI assistant chatbot"
44
+ )
45
+
46
+ # 4. Launch the interface
47
+ iface.launch()