isitcoding commited on
Commit
3c90410
·
verified ·
1 Parent(s): cd7e83a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -31
app.py CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  '''import os
2
  import gradio as gr
3
  from transformers import pipeline
@@ -72,35 +76,4 @@ iface = gr.Interface(
72
  iface.launch()
73
  '''
74
 
75
- import gradio as gr
76
- from transformers import pipeline
77
-
78
- # Load a text generation model (e.g., GPT-2 or a model of your choice)
79
- generator = pipeline("text-generation", model="isitcoding/gpt2_120_finetuned", tokenizer="isitcoding/gpt2_120_finetuned")
80
 
81
- # Function to generate assistant's response based on user input
82
- def generate_response(messages):
83
- # Extract the user message from the input format
84
- user_message = messages[-1]["content"]
85
-
86
- # Generate a response based on the user's input
87
- response = generator(user_message, max_length=100, num_return_sequences=1)
88
-
89
- # Get the assistant's message from the generated output
90
- assistant_message = response[0]["generated_text"]
91
-
92
- # Return the updated conversation with user and assistant messages
93
- messages.append({"role": "assistant", "content": assistant_message})
94
- return messages
95
-
96
- # Set up the Gradio interface
97
- iface = gr.Interface(
98
- fn=generate_response,
99
- inputs=gr.Textbox(placeholder="Type your message..."), # User input
100
- outputs=gr.JSON(), # JSON format output to display the conversation
101
- live=True, # Ensure real-time updates
102
- title="Text Generation Pipeline",
103
- description="Enter a message to get a response from the assistant."
104
- )
105
-
106
- iface.launch()
 
1
+ from transformers import pipeline
2
+ generator = pipeline('text-generation', model = 'isitcoding/gpt2_120_finetuned')
3
+ generator("", max_length = 1028, num_return_sequences=3)
4
+
5
  '''import os
6
  import gradio as gr
7
  from transformers import pipeline
 
76
  iface.launch()
77
  '''
78
 
 
 
 
 
 
79