akhilhsingh commited on
Commit
cf54443
1 Parent(s): aa70cfe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -1,5 +1,5 @@
1
- import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
3
 
4
  # Load pre-trained GPT-2 model and tokenizer
5
  model_name = "google/gemma-7b"
@@ -19,11 +19,14 @@ def generate_response(prompt):
19
 
20
  return response
21
 
22
- gr.Interface(
23
- fn=generate_response,
24
- inputs=gr.Textbox(lines=2, placeholder="Enter your message here..."),
25
- outputs="text",
26
- title="Akhil's Chatbot (powered by GPT2)",
27
- description="This is a Basuc chatbot using OpenAI's GPT2. Ask it anything!",
28
- theme="compact"
29
- ).launch()
 
 
 
 
 
1
  from transformers import AutoModelForCausalLM, AutoTokenizer
2
+ import torch
3
 
4
  # Load pre-trained GPT-2 model and tokenizer
5
  model_name = "google/gemma-7b"
 
19
 
20
  return response
21
 
22
+ # Spaces-compatible function
23
+ def spaces_chatbot(input_dict):
24
+ prompt = input_dict["text"]
25
+ response = generate_response(prompt)
26
+ return {"response": response}
27
+
28
+ # Sample input
29
+ sample_input = {"text": "Hello, how are you?"}
30
+
31
+ # Test the function
32
+ print(spaces_chatbot(sample_input))