이 튜토리얼에서는 LLMOps 모범 사례를 사용하여 프로덕션에 즉시 사용 가능한 AI 끌어오기 요청 검토기를 구축하는 방법을 보여줍니다. 여기에서 액세스할 수 있는 최종 애플리케이션은 공개 PR URL을 수락하고 AI 생성 리뷰를 반환합니다.
신청 개요
이 튜토리얼에서는 다음 내용을 다룹니다.
- 코드 개발: GitHub에서 PR 차이점을 검색하고 LLM 상호 작용을 위해 LiteLLM을 활용합니다.
- 관찰성: 애플리케이션 모니터링 및 디버깅을 위한 Agenta 구현
- 프롬프트 엔지니어링: Agenta의 플레이그라운드를 사용하여 프롬프트 및 모델 선택을 반복합니다.
- LLM 평가: 신속한 모델 평가를 위해 LLM을 판사로 채용합니다.
- 배포: v0.dev를 사용하여 애플리케이션을 API로 배포하고 간단한 UI를 생성합니다.
핵심 로직
AI 어시스턴트의 워크플로는 간단합니다. PR URL이 주어지면 GitHub에서 차이점을 검색하여 검토를 위해 LLM에 제출합니다.
GitHub diff는 다음을 통해 액세스할 수 있습니다.
<code>https://patch-diff.githubusercontent.com/raw/{owner}/{repo}/pull/{pr_number}.diff</code>
이 Python 함수는 diff를 가져옵니다.
def get_pr_diff(pr_url): # ... (Code remains the same) return response.text
LiteLLM은 LLM 상호 작용을 촉진하여 다양한 제공자 간에 일관된 인터페이스를 제공합니다.
prompt_system = """ You are an expert Python developer performing a file-by-file review of a pull request. You have access to the full diff of the file to understand the overall context and structure. However, focus on reviewing only the specific hunk provided. """ prompt_user = """ Here is the diff for the file: {diff} Please provide a critique of the changes made in this file. """ def generate_critique(pr_url: str): diff = get_pr_diff(pr_url) response = litellm.completion( model=config.model, messages=[ {"content": config.system_prompt, "role": "system"}, {"content": config.user_prompt.format(diff=diff), "role": "user"}, ], ) return response.choices[0].message.content
Agenta로 관찰성 구현
Agenta는 관찰 가능성을 향상하고 입력, 출력 및 데이터 흐름을 추적하여 더 쉽게 디버깅할 수 있도록 합니다.
Agenta 초기화 및 LiteLLM 콜백 구성:
import agenta as ag ag.init() litellm.callbacks = [ag.callbacks.litellm_handler()]
Agenta 데코레이터를 사용한 도구 기능:
@ag.instrument() def generate_critique(pr_url: str): # ... (Code remains the same) return response.choices[0].message.content
AGENTA_API_KEY
환경 변수(Agenta에서 가져옴)를 설정하고 선택적으로 자체 호스팅을 위해 AGENTA_HOST
를 설정합니다.
LLM 놀이터 만들기
Agenta의 사용자 정의 워크플로 기능은 반복 개발을 위한 IDE와 유사한 놀이터를 제공합니다. 다음 코드 조각은 Agenta와의 구성 및 통합을 보여줍니다.
from pydantic import BaseModel, Field from typing import Annotated import agenta as ag import litellm from agenta.sdk.assets import supported_llm_models # ... (previous code) class Config(BaseModel): system_prompt: str = prompt_system user_prompt: str = prompt_user model: Annotated[str, ag.MultipleChoice(choices=supported_llm_models)] = Field(default="gpt-3.5-turbo") @ag.route("/", config_schema=Config) @ag.instrument() def generate_critique(pr_url:str): diff = get_pr_diff(pr_url) config = ag.ConfigManager.get_from_route(schema=Config) response = litellm.completion( model=config.model, messages=[ {"content": config.system_prompt, "role": "system"}, {"content": config.user_prompt.format(diff=diff), "role": "user"}, ], ) return response.choices[0].message.content
Agenta를 통한 서비스 제공 및 평가
- 앱 이름과 API 키를 지정하여
agenta init
실행 - 달려
agenta variant serve app.py
.
이렇게 하면 엔드투엔드 테스트를 위해 Agenta의 플레이그라운드를 통해 애플리케이션에 액세스할 수 있습니다. 평가에는 LLM 판사가 사용됩니다. 평가자 프롬프트는 다음과 같습니다.
<code>You are an evaluator grading the quality of a PR review. CRITERIA: ... (criteria remain the same) ANSWER ONLY THE SCORE. DO NOT USE MARKDOWN. DO NOT PROVIDE ANYTHING OTHER THAN THE NUMBER</code>
평가자를 위한 사용자 프롬프트:
<code>https://patch-diff.githubusercontent.com/raw/{owner}/{repo}/pull/{pr_number}.diff</code>
배포 및 프런트엔드
Agenta의 UI를 통해 배포가 수행됩니다.
- 개요 페이지로 이동하세요.
- 선택한 변형 옆에 있는 세 개의 점을 클릭하세요.
- "프로덕션에 배포"를 선택합니다.
빠른 UI 생성을 위해 v0.dev 프런트엔드가 사용되었습니다.
다음 단계 및 결론
향후 개선 사항에는 신속한 개선, 전체 코드 컨텍스트 통합, 대규모 차이 처리 등이 포함됩니다. 이 튜토리얼에서는 Agenta 및 LiteLLM을 사용하여 프로덕션에 즉시 사용 가능한 AI 끌어오기 요청 검토기를 구축, 평가 및 배포하는 방법을 성공적으로 보여줍니다.
위 내용은 vev, litellm 및 Agenta를 사용하여 AI 코드 검토 도우미 구축의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

PythonlistsCanstoreAnyDatAtype, ArrayModuLearRaysStoreOneType 및 NUMPYARRAYSAREFORNUMERICALPUTATION.1) LISTSAREVERSATILEBUTLESSMEMORY-EFFICENT.2) ARRAYMODUERRAYRAYRAYSARRYSARESARESARESARESARESARESAREDOREDORY-UNFICEDONOUNEOUSDATA.3) NumpyArraysUraysOrcepperperperperperperperperperperperperperperperferperferperferferpercient

whenyouattempttoreavalueofthewrongdatatypeinapythonaphonarray, thisiSdueTotheArrayModule의 stricttyPeenforcement, theAllElementStobeofthesAmetypecified bythetypecode.forperformancersassion, arraysaremoreficats the thraysaremoreficats thetheperfication the thraysaremorefications는

Pythonlistsarepartoftsandardlardlibrary, whileraysarenot.listsarebuilt-in, 다재다능하고, 수집 할 수있는 반면, arraysarreprovidedByTearRaymoduledlesscommonlyusedDuetolimitedFunctionality.

thescriptIsrunningwithHongpyThonversionDueCorRectDefaultTerpretersEttings.tofixThis : 1) checktheDefaultPyThonVersionUsingPyThon-VersionorPyThon3- version.2) usvirtual-ErondmentsBythePython.9-Mvenvmyenv, 활성화, 및 파괴

PythonArraysSupportVariousOperations : 1) SlicingExtractsSubsets, 2) 추가/확장 어드먼트, 3) 삽입 값 삽입 ATSpecificPositions, 4) retingdeletesElements, 5) 분류/ReversingChangesOrder 및 6) ListsompectionScreateNewListSbasedOnsistin

NumpyArraysareSentialplosplicationSefficationSefficientNumericalcomputationsanddatamanipulation. Theyarcrucialindatascience, MachineLearning, Physics, Engineering 및 Financeduetotheiribility에 대한 handlarge-scaledataefficivally. forexample, Infinancialanyaly

UseanArray.ArrayOveralistInpyThonWhendealingwithhomogeneousData, Performance-CriticalCode, OrinterFacingwithCcode.1) HomogeneousData : ArraysSaveMemorywithtypepletement.2) Performance-CriticalCode : arraysofferbetterporcomanceFornumericalOperations.3) Interf

아니요, NOTALLLISTOPERATIONARESUPPORTEDBYARRARES, andVICEVERSA.1) ArraySDONOTSUPPORTDYNAMICOPERATIONSLIKEPENDORINSERTWITHUTRESIGING, WHITHIMPACTSPERFORMANCE.2) ListSDONOTEECONSTANTTIMECOMPLEXITEFORDITITICCESSLIKEARRAYSDO.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.
