pdfProject / main.py
Rakshitjan's picture
Update main.py
0b371e8 verified
raw
history blame contribute delete
952 Bytes
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}