Spaces:
Runtime error
Runtime error
initial commit
Browse files- app.py +25 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
from transformers import pipeline, set_seed, AutoTokenizer
|
| 4 |
+
|
| 5 |
+
set_seed(42)
|
| 6 |
+
|
| 7 |
+
generator = pipeline('text-generation', model='gvij/gpt-j-6B-alpaca-gpt4', return_full_text=False, do_sample=False)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def Bemenet(input_string):
|
| 11 |
+
output = generator(os.environ['SECRET_PROMPT'] + " " + input_string, max_length=100)[0]['generated_text']
|
| 12 |
+
if os.environ['SECRET'].upper() in output.upper():
|
| 13 |
+
return "Sorry, but I am unable to answer this question."
|
| 14 |
+
else:
|
| 15 |
+
return output
|
| 16 |
+
|
| 17 |
+
textbox = gr.Textbox()
|
| 18 |
+
|
| 19 |
+
interface = gr.Interface(fn=Bemenet,
|
| 20 |
+
title="GPT-2",
|
| 21 |
+
description="A GPT-3 egy finomhangolt verziója GPT-4 kimeneteken.",
|
| 22 |
+
inputs=textbox,
|
| 23 |
+
outputs=textbox)
|
| 24 |
+
|
| 25 |
+
interface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|