use gpt function

This commit is contained in:
fiatrete
2023-06-16 15:58:57 +08:00
parent 88e3ed0648
commit 0a4feb1daf
11 changed files with 181 additions and 135 deletions
@@ -18,7 +18,18 @@ def reg_or_not():
@functional_module(
name="add_alarm",
description="Create an alarm",
signature={"date": "The alarm date, 'YYYY-mm-dd HH:MM:SS format'", "desc": "The event description"})
signature={
"date": {
"description": "The alarm date, 'YYYY-mm-dd HH:MM:SS format'",
"type": "string",
"required": True
},
"desc": {
"description": "The event description",
"type": "string",
"required": True
}
})
async def add_alarm(context: CallerContext, date, desc):
# date = "2023-05-10 14:56:59"
now = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S").timestamp()
@@ -43,7 +54,14 @@ def reg_or_not():
@functional_module(
name="delete_alarm",
description="delete all alarms whose ID is in the list",
signature={"IDs": "A list of alarm IDs to"})
signature={
"IDs": {
"type": "array",
"items": { "type": "string" },
"description": "A list of alarm IDs to delete",
"required": True
}
})
async def delete_alarm(context: CallerContext, IDs: List[str]):
# get all tasks
result = await do_get(google_calendar_service_address + "/tasks")
@@ -113,7 +113,7 @@ Sometimes you maybe asked to generate a pic of myself. That means you MUST add '
- Add unique touches to each output, making it lengthy, detailed, and stylized.
- Show, don't tell; instead of tagging \"exceptional artwork\" or \"emphasizing a beautiful ...\" provide - precise details.
- Ensure the output is placed inside a beautiful and stylized markdown.
- The prompt you return MUST be English. The lenth of prompt MUST less than 150.
- The prompt you return MUST be English. The tokens of prompt MUST less than 70.
"""
OTHER_SD_PARAMS_NAME = "other"
@@ -153,7 +153,7 @@ NOTE: Just reply using these information, don't ask me anything.
sys_prompt = {'role': 'system', 'content': gpt_system_prompt}
messages = [sys_prompt, {'role': 'user', 'content': prompt}]
model = CFG.small_llm_model
resp = await acreate_chat_completion(
_, resp = await acreate_chat_completion(
messages,
model,
temperature=0,
@@ -207,7 +207,7 @@ NOTE: Just reply using these information, don't ask me anything.
messages = [sys_prompt, {'role': 'user', 'content': "Generation " + origin_str}]
model = CFG.small_llm_model
try:
resp = await acreate_chat_completion(
_, resp = await acreate_chat_completion(
messages,
model,
temperature=0,
@@ -239,7 +239,12 @@ NOTE: Just reply using these information, don't ask me anything.
@functional_module(
name="stable_diffusion",
description="Generate a picture.",
signature={'prompt': 'the description I told you'})
signature={
'prompt': {
"type": "string",
"description": 'the description I told you'
}
})
async def stable_diffusion(context: CallerContext, prompt: str):
await context.reply_text("I'm generating the image, this may take a while.")
style = await determine_style(prompt)
@@ -14,8 +14,12 @@ def reg_or_not():
@functional_module(
name="post_tweet",
description="post a tweet",
signature={"content": "the content of the tweet"}
)
signature={
"content": {
"type": "string",
"description": "the content of the tweet"
}
})
async def post_tweet(context: CallerContext, content: str):
response = await do_post(twitter_service_address + "/twitter/tweet_post", '', {"content": content})
logger.info(f"response: {response}")
+24 -4
View File
@@ -14,7 +14,12 @@ def reg_or_not():
@functional_module(
name="youtube_video_brief",
description="Get the brief content of a youtube video",
signature={"url": "The address of the video"})
signature={
"url": {
"type": "string",
"description": "The address of the video"
}
})
async def youtube_video_brief(context: CallerContext, url: str):
await context.push_notification(f"One second... I'm watching this video: {url}")
if not url.startswith('https://www.youtube.com/watch?'):
@@ -38,7 +43,12 @@ def reg_or_not():
@functional_module(
name="youtube_video_brief_vid",
description="Get the brief content of a youtube video identified by video id",
signature={"video_id": "The video id of the video"})
signature={
"video_id": {
"type": "string",
"description": "The video id of the video"
}
})
async def youtube_video_brief_vid(context: CallerContext, video_id: str):
url = f'https://www.youtube.com/watch?v={video_id}'
await context.push_notification(f"One second... I'm watching this video: {url}")
@@ -70,7 +80,12 @@ def reg_or_not():
@functional_module(
name="youtube_x_video_info",
description="Get the basic information of a youtube user's newest videos, when the summary of videos are not required, you should use this function",
signature={"username": "The username"})
signature={
"username": {
"type": "string",
"description": "The username"
}
})
async def youtube_x_video_info(context: CallerContext, username: str):
response = await youtube_latest_video_info_of(context, username, False)
result = f'The brief content of the latest videos of {username} are:\n'
@@ -86,7 +101,12 @@ def reg_or_not():
@functional_module(
name="youtube_notify_new",
description="Watching an Youtuber, push an notification when the youtuber published a new video",
signature={"username": "The username"})
signature={
"username": {
"type": "string",
"description": "The username"
}
})
async def youtube_notify_new(context: CallerContext, username: str):
if username.startswith('@'):
username = username[1:]