Spaces:
Runtime error
Runtime error
Commit
·
4c8be87
1
Parent(s):
c8f549d
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,7 +44,7 @@ function_descriptions = [
|
|
| 44 |
}
|
| 45 |
]
|
| 46 |
|
| 47 |
-
|
| 48 |
Dear Jason
|
| 49 |
I hope this message finds you well. I'm Shirley from Gucci;
|
| 50 |
|
|
@@ -57,16 +57,26 @@ Looking forward
|
|
| 57 |
Shirley Lou
|
| 58 |
"""
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
response = openai.ChatCompletion.create(
|
| 64 |
-
model="gpt-3.5-turbo",
|
| 65 |
-
messages=message,
|
| 66 |
-
functions = function_descriptions,
|
| 67 |
-
function_call="auto"
|
| 68 |
-
)
|
| 69 |
|
| 70 |
-
print(response)
|
| 71 |
|
| 72 |
-
st.header("Done!")
|
|
|
|
| 44 |
}
|
| 45 |
]
|
| 46 |
|
| 47 |
+
test_email = """
|
| 48 |
Dear Jason
|
| 49 |
I hope this message finds you well. I'm Shirley from Gucci;
|
| 50 |
|
|
|
|
| 57 |
Shirley Lou
|
| 58 |
"""
|
| 59 |
|
| 60 |
+
email = st.text_input("email",test_email)
|
| 61 |
+
|
| 62 |
+
def extract_data(email,function_descriptions):
|
| 63 |
+
prompt = f"Please extract key information from this email: {email} "
|
| 64 |
+
message = [{"role": "user", "content": prompt}]
|
| 65 |
+
|
| 66 |
+
response = openai.ChatCompletion.create(
|
| 67 |
+
model="gpt-3.5-turbo",
|
| 68 |
+
messages=message,
|
| 69 |
+
functions = function_descriptions,
|
| 70 |
+
function_call="auto"
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
print(response)
|
| 74 |
+
return response
|
| 75 |
+
|
| 76 |
+
if st.button(Extract):
|
| 77 |
+
data = extract_data(email,function_descriptions)
|
| 78 |
+
st.json(data)
|
| 79 |
+
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
|
|
|
| 82 |
|
|
|