Lyzr.ai로 텍스트 변환: 단계별 가이드

PHPz
풀어 주다: 2024-08-07 08:04:12
원래의
991명이 탐색했습니다.

Transform Your Text with Lyzr.ai: A Step-by-Step Guide

글쓰기는 우리 일상에 꼭 필요한 부분입니다. 이메일 초안 작성, 문서 작성, 스토리텔링 등 무엇이든 우리는 명확성과 정확성을 목표로 합니다. 하지만 맞춤법 검사기로 오류를 수정하는 것은 어려울 수 있습니다.

텍스트를 다듬기 위해 설계된 환상적인 도구인 AI 교정을 시작하세요. 오늘은 AI를 사용하여 작문 능력을 향상하고 문법, 철자법, 구두점 및 서식을 수정하는 간단한 코드를 살펴보겠습니다.

문제 설명

문법적으로 올바른 텍스트를 작성하는 것은 중요하지만 어려운 경우가 많습니다. 수동 교정에는 시간이 많이 걸리고 오류를 놓칠 수 있습니다. 이 코드는 Lyzr.ai를 사용해 텍스트를 확인하고 편집하여 글쓰기 효율성을 높여줍니다.

전제조건

시작하기 전에 Python 프로그래밍을 이해하고 API 키를 사용하여 OpenAI API에 액세스할 수 있어야 합니다. Python 라이브러리와 Lyzr.ai의 프레임워크 설치 및 가져오기에 대한 지식도 도움이 됩니다.

Lyzr Automata 프레임워크 설치

pip install lyzr-automata

# For Google Colab or notebook
!pip install lyzr-automata
로그인 후 복사

코드 및 설명

코드를 단계별로 분석해 보겠습니다.

from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent, Task
from lyzr_automata.tasks.task_literals import InputType, OutputType
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from lyzr_automata import Logger

API_KEY = input('Enter OpenAI API Key')
text = input('Enter the Text Here: ')
로그인 후 복사

Lyzr.ai 라이브러리에서 필요한 도구를 가져오는 것으로 시작하고 사용자에게 교정할 OpenAI API 키와 텍스트를 입력하라는 메시지를 표시합니다.

open_ai_model_text = OpenAIModel(
    api_key=API_KEY,
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.5,
        "max_tokens": 1500,
    },
)
로그인 후 복사

API 키와 매개변수를 사용하여 AI 모델을 설정하고 AI의 행동과 응답 길이를 제어합니다.

def ai_proofreader(text):
    ProofReader = Agent(
        prompt_persona="""You are an expert proofreader who can find grammatical errors, and you excel at checking for grammar, spelling, punctuation, and formatting errors.""",
        role="AI Proofreader",
    )

    rephrase_text = Task(
        name="Rephrasing Text",
        agent=ProofReader,
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=open_ai_model_text,
        instructions=f"Check the entire text: '{text}' and rephrase it according to grammar, spelling, punctuation, and formatting errors. [Important] Avoid introduction and conclusion in the response.",
        log_output=True,
        enhance_prompt=False,
        default_input=text
    )

    remarks = Task(
        name="Remarks",
        agent=ProofReader,
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=open_ai_model_text,
        instructions=f"Check the entire text: '{text}' and provide remarks in bullet points according to grammar, spelling, punctuation, and formatting errors. [Important] Avoid introduction and conclusion in the response.",
        log_output=True,
        enhance_prompt=False,
        default_input=text
    )

    logger = Logger()

    main_output = LinearSyncPipeline(
        logger=logger,
        name="AI ProofReader",
        completion_message="App Generated all things!",
        tasks=[
            rephrase_text,
            remarks,
        ],
    ).run()

    return main_output
로그인 후 복사

ai_proofreader라는 함수를 정의합니다. 내부에서는 전문 교정자 역할을 하는 ProofReader라는 에이전트를 만듭니다. 두 가지 작업이 생성됩니다. 하나는 텍스트를 바꾸는 작업이고 다른 하나는 설명을 제공하는 작업입니다. 두 작업 모두 ProofReader 에이전트와 AI 모델을 사용합니다.

로거가 프로세스를 모니터링합니다. 그런 다음 작업을 순차적으로 실행하여 수정된 텍스트와 설명을 생성하는 파이프라인을 설정합니다.

generated_output = ai_proofreader(text=text)
rephrased_text = generated_output[0]['task_output']
remarks = generated_output[1]['task_output']
로그인 후 복사

사용자의 텍스트로 함수를 호출하고 다시 표현된 텍스트와 설명을 출력으로 가져옵니다.

샘플 입력

text = """ I Rajesh have 2+ years of experience in python developer, 
I know to create backend applications, 
I am seeking a new role for new learnings """
로그인 후 복사

출력

""" 
My name is Rajesh, and I possess over two years of experience as a Python developer. 
I am skilled in creating backend applications and am currently seeking a new role to further my learning 

- The phrase "I Rajesh have 2+ years of experience in python developer" should be corrected to "I, Rajesh, have over two years of experience as a Python developer." This correction addresses a punctuation issue (adding commas around "Rajesh"), a numerical expression ("2+" to "over two"), and clarifies the role ("in python developer" to "as a Python developer").
- "python" should be capitalized to "Python" to properly denote the programming language.
- The phrase "I know to create backend applications" could be more fluidly expressed as "I know how to create backend applications" or "I am skilled in creating backend applications" for clarity and grammatical correctness.
- The phrase "I am seeking a new role for new learnings" could be improved for clarity and professionalism. A better alternative might be "I am seeking a new role to further my learning" or "I am seeking a new role to continue my professional development."
- The entire passage could benefit from better punctuation and formatting for clarity and flow. For instance, using semicolons or periods to separate independent clauses can improve readability: "My name is Rajesh, and I possess over two years of experience as a Python developer; I am skilled in creating backend applications and am currently seeking a new role to further my learning."
- Consistency in tense and style would improve the professional tone of the passage.
"""
로그인 후 복사

Lyzr.ai 소개

Lyzr.ai는 GenAI 애플리케이션을 빠르게 생성하기 위한 로우 코드 에이전트 개발 키트를 제공합니다. 이 간단한 에이전트 프레임워크를 사용하면 교정 및 글쓰기를 비롯한 다양한 용도에 사용할 수 있는 안전하고 안정적인 생성 AI 애플리케이션을 구축할 수 있습니다.

참고자료

자세한 내용은 Lyzr 웹사이트를 방문하거나, 데모를 예약하거나, Discord 및 Slack의 커뮤니티 채널에 가입하세요.

  • Lyzr 홈페이지
  • 데모 예약
  • Lyzr 커뮤니티 채널: Discord, Slack

AI 교정기: GitHub

위 내용은 Lyzr.ai로 텍스트 변환: 단계별 가이드의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

원천:dev.to
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!