sushruthsam commited on
Commit
5e7d2c0
·
verified ·
1 Parent(s): ca6acaf

Upload 2 files

Browse files
Files changed (2) hide show
  1. main.py +21 -0
  2. requirements.txt +6 -0
main.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ from ctransformers import AutoModelForCausalLM # Ensure correct import for your model
4
+
5
+ # Model loading
6
+ llm = AutoModelForCausalLM.from_pretrained("model.safetensors",
7
+ max_tokens = 512, threads = 3)
8
+
9
+ # Pydantic object for request validation
10
+ class Validation(BaseModel):
11
+ prompt: str
12
+
13
+ # Initialize FastAPI app
14
+ app = FastAPI()
15
+
16
+ # Endpoint for SQL query generation
17
+ @app.post("/generate_sql")
18
+ async def generate_sql(item: Validation):
19
+ # Use the provided prompt directly
20
+ completion = llm(item.prompt)
21
+ return completion
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ python-multipart
2
+ fastapi
3
+ pydantic
4
+ uvicorn
5
+ requests
6
+ ctransformers