Spaces:
Sleeping
Sleeping
Create main.py (#1)
Browse files- Create main.py (1eee609790f514dd8d8f71032d076e57060c3565)
main.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request
|
2 |
+
from twilio.twiml.messaging_response import MessagingResponse
|
3 |
+
|
4 |
+
sms_chain = LLMChain(
|
5 |
+
llm=Baseten(model="YOUR-MODEL-VERSION-ID"),
|
6 |
+
prompt=prompt,
|
7 |
+
memory=ConversationBufferWindowMemory(k=2),
|
8 |
+
llm_kwargs={"max_length": 4096}
|
9 |
+
)
|
10 |
+
|
11 |
+
app = Flask(__name__)
|
12 |
+
|
13 |
+
|
14 |
+
@app.route("/sms", methods=['GET', 'POST'])
|
15 |
+
def sms():
|
16 |
+
resp = MessagingResponse()
|
17 |
+
inb_msg = request.form['Body'].lower().strip()
|
18 |
+
output = sms_chain.predict(sms_input=inb_msg)
|
19 |
+
print(output)
|
20 |
+
resp.message(output)
|
21 |
+
return str(resp)
|
22 |
+
|
23 |
+
if __name__ == "__main__":
|
24 |
+
app.run(debug=True)
|