Spaces:
Sleeping
Sleeping
Download src/api/chat_endpoint.py from TeleologyHI/HIM-self: direct link, hf CLI and curl.
- Browser
- Download file 708 Bytes
-
https://huggingface.co/spaces/TeleologyHI/HIM-self/resolve/main/src/api/chat_endpoint.py
- Command line
-
hf download hf://spaces/TeleologyHI/HIM-self/src/api/chat_endpoint.py
-
curl -L -o chat_endpoint.py https://huggingface.co/spaces/TeleologyHI/HIM-self/resolve/main/src/api/chat_endpoint.py
708 Bytes
| from typing import Dict, Any | |
| from fastapi import FastAPI | |
| from src.model.him_model import HIMModel | |
| from src.core.config import HIMConfig | |
| app = FastAPI() | |
| model = HIMModel(HIMConfig()) | |
| async def chat( | |
| message: str, | |
| system_message: str = "You are a friendly Chatbot.", | |
| max_tokens: int = 512, | |
| temperature: float = 0.7, | |
| top_p: float = 0.95 | |
| ) -> Dict[str, Any]: | |
| input_data = { | |
| "message": message, | |
| "system_message": system_message, | |
| "parameters": { | |
| "max_tokens": max_tokens, | |
| "temperature": temperature, | |
| "top_p": top_p | |
| } | |
| } | |
| response = await model.generate_response(input_data) | |
| return response | |