Spaces:
Sleeping
Sleeping
Commit
·
9991862
1
Parent(s):
93ad901
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
response = generator(
|
| 10 |
-
return response
|
| 11 |
|
| 12 |
-
# Create a Gradio interface
|
| 13 |
iface = gr.Interface(
|
| 14 |
-
fn=
|
| 15 |
-
inputs=
|
| 16 |
-
outputs=
|
|
|
|
|
|
|
| 17 |
live=True,
|
|
|
|
| 18 |
)
|
| 19 |
|
| 20 |
-
# Launch the Gradio interface
|
| 21 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Replace 'your_openai_api_key' with your actual OpenAI API key
|
| 5 |
+
api_key = "your_openai_api_key"
|
| 6 |
|
| 7 |
+
def generate_response(text):
|
| 8 |
+
generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B", device=0) # You can choose a different model here
|
| 9 |
+
response = generator(text, max_length=150, num_return_sequences=1, api_key=api_key)
|
| 10 |
+
return response[0]['generated_text']
|
| 11 |
|
|
|
|
| 12 |
iface = gr.Interface(
|
| 13 |
+
fn=generate_response,
|
| 14 |
+
inputs="text",
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="GPT-3.5 Turbo Chat",
|
| 17 |
+
description="An interface to chat with GPT-3.5 Turbo.",
|
| 18 |
live=True,
|
| 19 |
+
theme="huggingface",
|
| 20 |
)
|
| 21 |
|
|
|
|
| 22 |
iface.launch()
|