Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e7e8e35

Browse files
committed
feat(use-example): code optimize
1 parent 03a73b0 commit e7e8e35

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def call_gpt(user_input):
112112
st.title("Small assistant")
113113

114114
env = dotenv_values()
115+
115116
openai.api_key = env['OPENAI_API_KEY']
116117

117118
intents_list_obj = IntentsList()
@@ -122,10 +123,14 @@ def call_gpt(user_input):
122123
reply_content = call_gpt(prompt)
123124

124125
reply_content_dict = reply_content.to_dict()
125-
method_name = reply_content_dict['function_call']['name']
126-
method_args = reply_content_dict['function_call']['arguments']
127126

128-
method_args_dict = json.loads(method_args)
127+
if (reply_content_dict['content']):
128+
st.markdown(f"{reply_content_dict['content']}")
129+
else:
130+
method_name = reply_content_dict['function_call']['name']
131+
method_args = reply_content_dict['function_call']['arguments']
132+
133+
method_args_dict = json.loads(method_args)
129134

130-
method = getattr(intents_list_obj, method_name)
131-
method(**method_args_dict)
135+
method = getattr(intents_list_obj, method_name)
136+
method(**method_args_dict)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /