欢迎光临
我们一直在努力

使用 Lyzr SDK 构建个性化自由助理

自由职业提供了一个充满机遇和灵活性的世界,但它也带来了一系列挑战。 个性化自由职业助手应用程序旨在提供量身定制的技巧和策略,帮助自由职业者在职业生涯中取得成功。利用 lyzr automata sdk 和 openai 的 gpt-4 turbo,该应用程序根据用户输入创建定制计划。

使用 Lyzr SDK 构建个性化自由助理

设置环境

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

import streamlit as st
from lyzr_automata.ai_models.openai import openaimodel
from lyzr_automata import agent, task
from lyzr_automata.pipelines.linear_sync_pipeline import linearsyncpipeline
from pil import image
from lyzr_automata.tasks.task_literals import inputtype, outputtype
import os

设置 openai api 密钥

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

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

应用程序标题和简介

接下来,我们设置应用程序的标题,并提供简要介绍,指导用户如何使用个性化自由助理。

st.title("freelance assistant")
st.markdown("welcome to freelance assistant, your personalized freelancing guide. enter your career details and goals for customized tips and strategies to enhance your freelance journey.")
st.markdown("1) mention your field of expertise.")
st.markdown("2) mention your experience level.")
st.markdown("3) mention your income goals.")
st.markdown("4) mention your preferred work-life balance.")
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 freelancing consultant",
        prompt_persona=f"your task is to offer personalized freelancing tips and strategic advice that aligns with the user's specific details.")
    prompt = f"""
[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://freelanceassistant-lyzr.streamlit.app/

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

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

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

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

赞(0) 打赏
未经允许不得转载:码农资源网 » 使用 Lyzr SDK 构建个性化自由助理
分享到

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册