首頁  >  文章  >  後端開發  >  使用 Lyzr SDK 建立自訂 PC 指南

使用 Lyzr SDK 建立自訂 PC 指南

WBOY
WBOY原創
2024-08-06 20:38:22523瀏覽

Building a Custom PC Guide using Lyzr SDK

在當今科技發達的世界,擁有一台根據您的特定需求和預算量身定制的定制電腦可以讓一切變得不同。無論您是遊戲玩家、專業人士還是只是想要一台功能強大的機器的人,組裝 PC 都是一項既有益又經濟高效的努力。隨著人工智慧和自然語言處理的進步,Lyzr Automata 和 OpenAI 的 GPT-4 Turbo 等工具使這一過程變得更加容易。讓我們深入了解如何使用這些強大的工具來建立您的客製化電腦。

為什麼要使用 Lyzr SDK?

使用 Lyzr SDK,製作您自己的 GenAI 應用程式變得輕而易舉,只需要幾行程式碼即可快速啟動和運行。

查看 Lyzr SDK

讓我們開始吧!
設定環境

首先,我們使用 Streamlit 和 Lyzr Automata SDK 設定環境。 Streamlit 是一個用 Python 創建互動式 Web 應用程式的框架,Lyzr Automata 提供了一個利用 AI 模型的工具。

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("Custom PC Build Guide")
st.markdown("Welcome to the Custom PC Build Guide! Tell us your budget and what you need, and we'll help you build the perfect PC, tailored just for you.")
st.markdown("            1) Determine Your Budget.")
st.markdown("            2) Mention your needs (Primary Use,Preferred Brands if any and etc).")
st.markdown("            3) Provide additional information if any like Such as RGB lighting, quiet operation, overclocking capabilities, etc.")
input = st.text_input(" Please enter the above details:", placeholder="Type here")

設定 OpenAI 模型

我們使用特定參數初始化 OpenAI 模型,以產生 PC 建置指南。

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 建立一個代理,引導使用者完成 PC 建置流程。

def generation(input):
    generator_agent = Agent(
        role="Expert PC BUILDER and CUSTOMIZATION CONSULTANT",
        prompt_persona="Your task is to GUIDE users through the process of building their own CUSTOMIZED PC, tailored to their budget and specific needs, including primary use, preferred brands, and additional requirements such as RGB lighting, quiet operation, overclocking capabilities, etc.")
    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

產生指南的按鈕

我們新增了一個按鈕,點擊時會觸發產生 PC 建置指南。

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

建造客製化電腦一開始似乎令人畏懼,但有了正確的指導和工具,它就會成為一項易於管理甚至令人愉快的任務。透過利用 Lyzr Automata 和 OpenAI 的 GPT-4 Turbo 的功能,您可以獲得根據您的特定需求和預算量身定制的專家建議。該應用程式不僅可以幫助您選擇正確的組件,還提供清晰的逐步說明來組裝您的電腦。

借助人工智慧的力量,您可以確保您的客製化 PC 建置滿足您的效能要求、美學偏好和預算限制。無論您是遊戲玩家、專業人士還是只是技術愛好者,本指南旨在簡化流程,讓您的客製化 PC 組裝體驗盡可能順暢。

應用程式連結:https://custompc-lyzr.streamlit.app/

原始碼:https://github.com/isakshay007/Custom_PC

自訂 PC 指南 由 Lyzr Automata Agent 提供支持,利用 OpenAI 的 GPT-4 Turbo 的功能。如有任何疑問或問題,請聯絡 Lyzr。您可以透過以下連結了解更多有關 Lyzr 及其產品的資訊:

網址:Lyzr.ai
預約示範:預約示範
Discord:加入我們的 Discord 社群
Slack:加入我們的 Slack 頻道

隨意探索該應用程序,提供您的詳細信息,然後開始建立您夢想的電腦。快樂建造!

以上是使用 Lyzr SDK 建立自訂 PC 指南的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn