Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +10 -0
- help_me_talk.py +22 -0
app.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from help_me_talk import helpTalk
|
| 3 |
+
|
| 4 |
+
def prompt(input):
|
| 5 |
+
return helpTalk(input)
|
| 6 |
+
|
| 7 |
+
prob = gr.Textbox(label="Argument")
|
| 8 |
+
book = gr.Textbox(label="Response")
|
| 9 |
+
iface = gr.Interface(fn=prompt, inputs=prob, outputs=book,title="Let Me help you Bro : )", description="Did you get stuck in conversation like your step-../%$#")
|
| 10 |
+
iface.launch()
|
help_me_talk.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import openai
|
| 3 |
+
|
| 4 |
+
openai.api_key = os.getenv("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")
|
| 5 |
+
|
| 6 |
+
def helpTalk(input):
|
| 7 |
+
response = openai.Completion.create(
|
| 8 |
+
model="text-davinci-003",
|
| 9 |
+
prompt="Read the users input and respond in such a manner that user is bound to reply.\nInput : I am fine. \n\nOutput : That's great to hear! How has your day been?\n/#/#\nInput :",
|
| 10 |
+
temperature=0.7,
|
| 11 |
+
max_tokens=256,
|
| 12 |
+
top_p=1,
|
| 13 |
+
frequency_penalty=0,
|
| 14 |
+
presence_penalty=0,
|
| 15 |
+
stop=["/#/#"]
|
| 16 |
+
)
|
| 17 |
+
text = response["choices"][0]["text"]
|
| 18 |
+
text = text.replace("\n","")
|
| 19 |
+
start = text.find("Output:") + 5
|
| 20 |
+
end = len(text)
|
| 21 |
+
text = text[start:end].strip()
|
| 22 |
+
return text
|