from pydantic import BaseModel from .ConfigEnv import config from fastapi.middleware.cors import CORSMiddleware from langchain.llms import Clarifai from langchain.chains import LLMChain from langchain.prompts import PromptTemplate from TextGen import app @app.get("/", tags=["Home"]) def api_home(): return {'detail': 'Welcome to FastAPI TextGen Tutorial!'} @app.post("/api/generate", summary="Generate text from prompt", tags=["Generate"], response_model=Generate) def inference(input_prompt: str): return generate_text(prompt=input_prompt)