Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -74,7 +74,7 @@ def infer(prompt,
|
|
74 |
|
75 |
def getideas(text_inp):
|
76 |
|
77 |
-
text = prompt+"\nInput:"+
|
78 |
resp = infer(text,seed=random.randint(0,100))
|
79 |
|
80 |
generated_text=resp[0]['generated_text']
|
@@ -84,32 +84,6 @@ def getideas(text_inp):
|
|
84 |
topic = parts[0].strip()
|
85 |
topic="\n".join(topic.split('\n')[:3])
|
86 |
return(topic)
|
87 |
-
|
88 |
-
def query(text):
|
89 |
-
#global prompt
|
90 |
-
print(text)
|
91 |
-
text = prompt+"\nInput:"+text + "\nOutput:"
|
92 |
-
#print(text)
|
93 |
-
payload = {
|
94 |
-
"inputs": text,
|
95 |
-
"parameters": {
|
96 |
-
"max_length": 250,
|
97 |
-
"temperature": 0.9,
|
98 |
-
"seed":random.randint(0, 100),
|
99 |
-
},
|
100 |
-
}
|
101 |
-
|
102 |
-
data = json.dumps(payload)
|
103 |
-
response = requests.request("POST", API_URL, headers=headers, data=data)
|
104 |
-
#print('Response here\n',response.content)
|
105 |
-
generated_text=json.loads(response.content.decode("utf-8"))[0]['generated_text']
|
106 |
-
result = generated_text.replace(text,'').strip()
|
107 |
-
result = result.replace("Output:","")
|
108 |
-
parts = result.split("###")
|
109 |
-
topic = parts[0].strip()
|
110 |
-
topic=topic.split("Input:")[0]
|
111 |
-
print(topic)
|
112 |
-
return topic
|
113 |
|
114 |
|
115 |
with gr.Blocks() as demo:
|
|
|
74 |
|
75 |
def getideas(text_inp):
|
76 |
|
77 |
+
text = prompt+"\nInput:"+text_inp + "\nOutput:"
|
78 |
resp = infer(text,seed=random.randint(0,100))
|
79 |
|
80 |
generated_text=resp[0]['generated_text']
|
|
|
84 |
topic = parts[0].strip()
|
85 |
topic="\n".join(topic.split('\n')[:3])
|
86 |
return(topic)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
|
89 |
with gr.Blocks() as demo:
|