Upload app.py
Browse files
app.py
CHANGED
|
@@ -119,7 +119,7 @@ async def main():
|
|
| 119 |
sns.set_style('whitegrid',{'font.sans-serif':['simhei','Arial']})
|
| 120 |
-------------------------------------------------------------------------
|
| 121 |
""" ## seaborn中的palette参数可以设定图表的颜色,选项包括:deep, muted, pastel, bright, dark, colorblind,Spectral。更多参数可以参考:https://seaborn.pydata.org/generated/seaborn.color_palette.html。
|
| 122 |
-
|
| 123 |
# sns.set_style('whitegrid',{'font.sans-serif': ['simhei','Arial']})
|
| 124 |
# print('now font is:', myfont)
|
| 125 |
|
|
@@ -129,29 +129,31 @@ async def main():
|
|
| 129 |
### 加载上传的文件,主要路径在上面代码中。
|
| 130 |
files = [File.from_path(str(uploaded_file_path))]
|
| 131 |
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
#
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
| 155 |
|
| 156 |
st.session_state.messages.append(
|
| 157 |
{"role": "assistant", "content": full_response})
|
|
|
|
| 119 |
sns.set_style('whitegrid',{'font.sans-serif':['simhei','Arial']})
|
| 120 |
-------------------------------------------------------------------------
|
| 121 |
""" ## seaborn中的palette参数可以设定图表的颜色,选项包括:deep, muted, pastel, bright, dark, colorblind,Spectral。更多参数可以参考:https://seaborn.pydata.org/generated/seaborn.color_palette.html。
|
| 122 |
+
myfont=FontProperties(fname='SimHei.ttf')
|
| 123 |
# sns.set_style('whitegrid',{'font.sans-serif': ['simhei','Arial']})
|
| 124 |
# print('now font is:', myfont)
|
| 125 |
|
|
|
|
| 129 |
### 加载上传的文件,主要路径在上面代码中。
|
| 130 |
files = [File.from_path(str(uploaded_file_path))]
|
| 131 |
|
| 132 |
+
|
| 133 |
+
with st.status('processing...', expanded=True,state='running'):
|
| 134 |
+
### generate the response
|
| 135 |
+
response = await session.generate_response(
|
| 136 |
+
user_request, files=files
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
# output to the user
|
| 140 |
+
print("AI: ", response.content)
|
| 141 |
+
full_response = response.content
|
| 142 |
+
### full_response = "this is full response"
|
| 143 |
+
|
| 144 |
+
# for file in response.files:
|
| 145 |
+
for i, file in enumerate(response.files):
|
| 146 |
+
# await file.asave(f"/Users/yunshi/Downloads/360Data/Data Center/Working-On Task/演讲与培训/2023ChatGPT/Coding/code_interpreter/output{i}.png") ##working.
|
| 147 |
+
# st.image(file.get_image() #! working.
|
| 148 |
+
# file.show_image()
|
| 149 |
+
# st.image(file.get_image(), width=500, output_format='png')
|
| 150 |
+
st.image(file.get_image(), width=None, output_format='PNG') #* 注意这里的设定,可以提高图片的精细程度。
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
# message_placeholder.markdown(full_response + "▌") ## orignal code.
|
| 154 |
+
# message_placeholder.markdown(full_response) ## orignal code.
|
| 155 |
+
st.write(full_response)
|
| 156 |
+
await session.astop() #! 确认需要关闭。
|
| 157 |
|
| 158 |
st.session_state.messages.append(
|
| 159 |
{"role": "assistant", "content": full_response})
|