팁 (조언)
대체 Foundry 프로젝트 빠른 시작을 사용할 수 있습니다. 빠른 시작: Microsoft Foundry(Foundry 프로젝트) 시작
이 빠른 시작에서는 허브 기반 프로젝트에 대한 로컬 환경을 설정하고, 모델을 배포하고, 간단한 추적/가치 있는 채팅 스크립트를 빌드합니다.
필수 조건
- Azure 구독.
- 기존 허브 프로젝트(또는 하나 만들기). 그렇지 않은 경우 Foundry 프로젝트 빠른 시작을 사용하는 것이 좋습니다.
개발 환경 설정
- 필수 구성 요소(Python, Azure CLI, 로그인)를 설치합니다.
- 패키지를 설치합니다.
pip install azure-ai-inference azure-identity azure-ai-projects==1.0.0b10
프로젝트 유형에 따라 고유한 azure-ai-projects 버전이 필요합니다. 충돌을 방지하기 위해 각 프로젝트를 자체 격리된 환경에 유지합니다.
모델 배포
- 포털: 로그인하고 허브 프로젝트를 엽니다.
- 모델 카탈로그: gpt-4o-mini를 선택합니다.
- 이 모델 >을 사용하여 기본 배포 이름 >인 Deploy를 수락하십시오.
- 성공 후: 놀이터에서 열어 확인합니다.
채팅 앱 빌드
샘플 코드를 사용하여 chat.py 만듭니다.
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
project_connection_string = "<your-connection-string-goes-here>"
project = AIProjectClient.from_connection_string(
conn_str=project_connection_string, credential=DefaultAzureCredential()
)
chat = project.inference.get_chat_completions_client()
response = chat.complete(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": "You are an AI assistant that speaks like a techno punk rocker from 2350. Be cool but not too cool. Ya dig?",
},
{"role": "user", "content": "Hey, can you help me with my taxes? I'm a freelancer."},
],
)
print(response.choices[0].message.content)
프로젝트 개요 페이지에서 프로젝트 연결 문자열을 삽입합니다(코드에서 자리 표시자 복사, 바꾸기).
Run:
python chat.py
프롬프트 템플릿 추가
콧수염 템플릿을 사용하여 get_chat_response 추가한 다음(chat-template.py 샘플 참조) 사용자/컨텍스트 메시지를 사용하여 호출합니다.
템플릿 응답을 보려면 다시 실행합니다.
자원을 정리하세요
요금이 부과되지 않도록 완료된 경우 배포 또는 프로젝트를 삭제합니다.