torchchat
torchchat copied to clipboard
OpenAI API JSON formatted
Implement JSON formatted responses using OpenAI API types for server completion requests. Rather than giving single tokens at a time, the server will respond with a JSON following the API dataclasses corresponding to OpenAI API types.
Testing: Server
python3 torchchat.py server stories15M
Request (chunked)
curl http://127.0.0.1:5000/chat \
-H "Content-Type: application/json" \
-d '{
"model": "stories15M",
"stream": "true",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Story about a dog."
}
]
Request (synchronous)
curl http://127.0.0.1:5000/chat \
-H "Content-Type: application/json" \
-d '{
"model": "stories15M",
"stream": "false",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Story about a dog."
}
]
https://github.com/user-attachments/assets/1171db63-094b-4313-a1c6-76d042ceefca