-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (25 loc) · 779 Bytes
/
app.py
File metadata and controls
34 lines (25 loc) · 779 Bytes
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
30
31
32
33
34
import uvicorn
from fastapi import FastAPI, Request
from src.graphs.graph_builder import graphBuilder
from src.llms.groqllm import groqLLM
import os
from dotenv import load_dotenv
load_dotenv()
app=FastAPI()
os.environ["LANGSMITH_API_KEY"]=os.getenv["LANGCHAIN_API_KEY"]
## API's
@app.post("/blogs")
async def create_blogs(request:Request):
data=await request.json()
topic=data.get("topic","")
## get the llm objct
grokllm= groqLLM()
llm=groqLLM.get_llm.get_llm()
## get the graph
graph_builder=graphBuilder(llm)
if topic:
graph=graph_builder.setup_graph(usecase="topic")
state=graph.invoke("topic":topic)
return {"data":state}
if __name__=="__main__":
uvicorn.run("app:app", host=0.0.0.0, port=8000, reload=True)