-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_server.py
More file actions
29 lines (25 loc) · 1.04 KB
/
data_server.py
File metadata and controls
29 lines (25 loc) · 1.04 KB
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
from fastapi import FastAPI
import pandas as pd
import json
import uvicorn
from ollama import chat, ChatResponse
import os
print("LAMA_NUM_PARALLEL:", os.getenv('LAMA_NUM_PARALLEL'))
print("OLLAMA_MAX_LOADED_MODELS:", os.getenv('OLLAMA_MAX_LOADED_MODELS'))
app=FastAPI()
@app.post("/ingestdata")
async def process_data(data :dict):
df = pd.DataFrame({'x': data['x'], 'y': data['y']})
# Store 'id' separately
data_id = data['id']
"""
We can proecess data here, or send it to a service to process
"""
response :ChatResponse = chat(model='llama3.2:latest', messages=[{'role': 'user', 'content': f""" I have location coordinates {df} count how many is there
only return the number of coordinates
"""}])
summary = response.message.content.strip()
print(summary)
return {"message": "success", "data": summary}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)