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 78c4107

Browse files
committed
feat(use-examples): add send email example
1 parent ec27280 commit 78c4107

File tree

1 file changed

+42
-13
lines changed

1 file changed

+42
-13
lines changed

‎main.py

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def query_city_weather(self, city):
4040
st.markdown(
4141
f"**{cast['date']}** :`dayweather`:{cast['dayweather']},`nightweather`:{cast['nightweather']}, `daytemp`: {cast['daytemp']}, `nighttemp`:{cast['nighttemp']}")
4242

43+
@staticmethod
44+
def send_email(to_email, title, body):
45+
st.markdown(f"Recipient:{to_email}")
46+
st.markdown(f"Email Title:{title}")
47+
st.markdown(f"Email Body:{body}")
48+
4349

4450
def call_gpt(user_input):
4551
"""
@@ -53,25 +59,48 @@ def call_gpt(user_input):
5359
"""
5460
messages = [{"role": "user", "content": user_input}]
5561

56-
function = {
57-
"name": "query_city_weather",
58-
"description": "query weather temperature",
59-
"parameters": {
60-
"type": "object",
61-
"properties": {
62-
"city": {
63-
"type": "string",
64-
"description": "The city",
62+
function = [
63+
{
64+
"name": "query_city_weather",
65+
"description": "query weather temperature",
66+
"parameters": {
67+
"type": "object",
68+
"properties": {
69+
"city": {
70+
"type": "string",
71+
"description": "The city",
72+
},
6573
},
74+
"required": ["city"],
6675
},
67-
"required": ["city"],
6876
},
69-
}
77+
{
78+
"name": "send_email",
79+
"description": "Send email information",
80+
"parameters": {
81+
"type": "object",
82+
"properties": {
83+
"to_email": {
84+
"type": "string",
85+
"description": "Recipient's email address"
86+
},
87+
"title": {
88+
"type": "string",
89+
"description": "The title of the email"
90+
},
91+
"body": {
92+
"type": "string",
93+
"description": "The Body of the email"
94+
}
95+
}
96+
}
97+
}
98+
]
7099

71100
completion = openai.ChatCompletion.create(
72101
model="gpt-3.5-turbo-0613",
73102
messages=messages,
74-
functions=[function],
103+
functions=function,
75104
function_call="auto",
76105
)
77106
return completion.choices[0].message
@@ -99,4 +128,4 @@ def call_gpt(user_input):
99128
method_args_dict = json.loads(method_args)
100129

101130
method = getattr(skills_list_obj, method_name)
102-
method(method_args_dict['city'])
131+
method(**method_args_dict)

0 commit comments

Comments
(0)

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