adaptiveaiventures commited on
Commit
0f3904a
·
verified ·
1 Parent(s): f48b421

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import requests
3
+
4
+ app = FastAPI()
5
+
6
+ # TGI API URL
7
+ API_URL = "http://localhost:8080/generate"
8
+
9
+ @app.post("/generate")
10
+ async def generate_text(prompt: str, max_tokens: int = 200, temperature: float = 0.7):
11
+ payload = {
12
+ "inputs": prompt,
13
+ "parameters": {
14
+ "max_new_tokens": max_tokens,
15
+ "temperature": temperature,
16
+ "return_full_text": False
17
+ }
18
+ }
19
+ response = requests.post(API_URL, json=payload)
20
+ return response.json()