Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- ollama
- AI
- vibe coding
- Quantization
- VirtualBox
- SwiftUI
- 파인튜닝
- IOS
- php
- 클로드
- Claude
- persona
- apache
- Fine Tuning
- MAC
- python
- LLM
- MCP
- Llama
- MacOS
- WWDC
- HTTP
- 양자화
- Xcode
- 정보관리기술사
- OSX
- finetuning
- swift
- ai 모델 학습시키기
- apple gpu
Archives
- Today
- Total
Project Jo
Python 서버 만들기 본문
# server.py
from fastapi import FastAPI, Request
from pydantic import BaseModel
import uvicorn
app = FastAPI()
class Message(BaseModel):
role: str
content: str
@app.post("/chat")
async def chat(message: Message):
return {
"message": {
"role": "assistant",
"content": f"Echo: {message.content}"
}
}
if __name__ == "__main__":
uvicorn.run("server:app", host="0.0.0.0", port=8000, reload=True)
FastAPI는 Python에서 빠르고 간편하게 REST API 서버를 만들 수 있게 해주는 프레임워크로 해당 API 를 사용해 기본적인 서버를 구축 하고자 한다.
조건
1. LLM 과 같이 POST/JSON 타입으로 통신 한다.
2. 당연히 비동기로 동작해야 한다.
설명이 포함된 코드는 첨부파일로 올림.
'Developer > LLM' 카테고리의 다른 글
클로드(Claude) MCP (0) | 2025.04.21 |
---|---|
챗봇(Chat Bot) (0) | 2025.04.18 |
페르소나(Persona) (0) | 2025.04.14 |
FineTuning (0) | 2025.04.14 |
Role과 Content의 개념 (0) | 2025.04.08 |