Spaces:
Sleeping
Sleeping
File size: 952 Bytes
b208f1c 0b371e8 b208f1c |
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
from pydantic import BaseModel
from groq import Groq
import os
app = FastAPI()
groq_api_key = os.getenv("GROQ_API_KEY")
client = Groq(api_key=groq_api_key)
class RequestData(BaseModel):
user_message: str
@app.post("/chat")
def chat(data: RequestData):
chat_completion = client.chat.completions.create(
messages=[
{"role": "system", "content": "You are a expert weather analysis agent. I will provide you historical and future data in tabular form and you have to generate insights for the given data, Also make sure that you mention any scope of natural calamities expected and stuff"},
{"role": "user", "content": data.user_message},
],
model="llama-3.3-70b-versatile",
temperature=0.5,
max_completion_tokens=1024,
top_p=1,
stop=None,
stream=False,
)
return {"response": chat_completion.choices[0].message.content}
|