hitting gpt3
Browse files- app.py +18 -4
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,12 +1,26 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
from transformers import pipeline
|
| 4 |
-
|
| 5 |
-
pipe = pipeline("text-generation", model="mistralai/Mistral-7B-v0.1")
|
| 6 |
|
| 7 |
#generates an AI description of your character
|
| 8 |
def describe(names):
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
iface = gr.Interface(fn=describe, inputs=gr.Textbox(label="Your DND character",show_label=True),
|
| 12 |
outputs=gr.Textbox(label="The character",show_label=True))
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import openai
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
#generates an AI description of your character
|
| 6 |
def describe(names):
|
| 7 |
+
|
| 8 |
+
completion = openai.Completion.create(
|
| 9 |
+
engine='text-davinci-003',
|
| 10 |
+
prompt=names,
|
| 11 |
+
max_tokens=210,
|
| 12 |
+
temperature=0.97,
|
| 13 |
+
frequency_penalty=0.2,
|
| 14 |
+
presence_penalty= 0.25,
|
| 15 |
+
top_p=1)
|
| 16 |
+
|
| 17 |
+
result =completion.choices[0].text
|
| 18 |
+
if not result :
|
| 19 |
+
result = "Could you be any more boring?"
|
| 20 |
+
|
| 21 |
+
return result
|
| 22 |
+
|
| 23 |
+
|
| 24 |
|
| 25 |
iface = gr.Interface(fn=describe, inputs=gr.Textbox(label="Your DND character",show_label=True),
|
| 26 |
outputs=gr.Textbox(label="The character",show_label=True))
|
requirements.txt
CHANGED
|
@@ -1,2 +1,3 @@
|
|
| 1 |
transformers
|
| 2 |
-
torch
|
|
|
|
|
|
| 1 |
transformers
|
| 2 |
+
torch
|
| 3 |
+
openai
|