Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
使用 Lyzr SDK 构建个性化礼品助手_创想鸟

使用 Lyzr SDK 构建个性化礼品助手

找到完美的礼物可能具有挑战性,尤其是在考虑收件人的独特兴趣、场合和预算时。 个性化礼品助手应用程序可以让这个过程变得更轻松、更愉快。利用 lyzr automata 和 openai 的 gpt-4 turbo 的强大功能,此应用程序可帮助您策划个性化的礼物推荐,一定会让任何收件人感到高兴。

使用 Lyzr SDK 构建个性化礼品助手

设置环境

首先,让我们导入必要的库并设置我们的环境。

import streamlit as stfrom lyzr_automata.ai_models.openai import openaimodelfrom lyzr_automata import agent, taskfrom lyzr_automata.pipelines.linear_sync_pipeline import linearsyncpipelinefrom pil import imagefrom lyzr_automata.tasks.task_literals import inputtype, outputtypeimport os

设置 openai api 密钥

我们需要设置 openai api 密钥来访问 gpt-4 turbo 模型。

os.environ["openai_api_key"] = st.secrets["apikey"]

应用程序标题和简介

我们设置了应用程序的标题并提供了简短的介绍来指导用户如何使用个性化礼品助手。

st.title("personalized gift assistant")st.markdown("welcome to personalized gift assistant! let us help you find the perfect gift for any occasion, tailored to your recipient's unique interests and your budget.")st.markdown("1) mention your receiver's age.")st.markdown("2) mention your receiver's interest.")st.markdown("3) mention the occasion.")st.markdown("4) mention your budget.")input = st.text_input("please enter the above details:", placeholder="type here")

设置 openai 模型

我们用特定参数初始化openai模型,根据用户输入生成个性化礼物推荐

open_ai_text_completion_model = openaimodel(    api_key=st.secrets["apikey"],    parameters={        "model": "gpt-4-turbo-preview",        "temperature": 0.2,        "max_tokens": 1500,    },)

定义生成函数

此功能使用 lyzr automata sdk 创建一个代理,根据用户的输入提供个性化礼物推荐。

def generation(input):    generator_agent = agent(        role="expert gift consultant",        prompt_persona="your task is to curate a personalized list of 5-7 gifts for the user and provide explanations for each choice, taking into account the receiver's age, receiver's interests, the occasion, and the budget.")    prompt = """[prompts here]"""    generator_agent_task = task(        name="generation",        model=open_ai_text_completion_model,        agent=generator_agent,        instructions=prompt,        default_input=input,        output_type=outputtype.text,        input_type=inputtype.text,    ).execute()    return generator_agent_task

生成礼物推荐的按钮

我们添加了一个按钮,点击后会触发生成个性化礼物推荐。

if st.button("Assist!"):    solution = generation(input)    st.markdown(solution)

个性化礼品助手旨在帮助您找到适合任何场合的完美礼物。通过利用 lyzr automata 和 openai 的 gpt-4 turbo 的强大功能,您可以获得根据收件人的年龄、兴趣、场合和预算量身定制的专家建议。立即探索个性化礼品助手,让送礼成为一种愉快的体验!

应用链接:https://giftassistant-lyzr.streamlit.app/

源代码:https://github.com/isakshay007/gift_assistant

如有任何疑问或支持,请随时联系

lyzr。您可以通过以下链接了解有关 lyzr 及其产品的更多信息:

网站:lyzr.ai
预订演示:预订演示
discord:加入我们的 discord 社区
slack:加入我们的 slack 频道

以上就是使用 Lyzr SDK 构建个性化礼品助手的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1348795.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
使用 Python 抓取 Google 财经的终极指南
上一篇 2025年12月13日 12:21:17
如何使用 Python 抓取 Google 新闻:分步指南
下一篇 2025年12月13日 12:21:30

相关推荐

发表回复

登录后才能评论
关注微信