Empereur-Pirate commited on
Commit
c5c4414
·
verified ·
1 Parent(s): 7f6e34d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +30 -1
main.py CHANGED
@@ -39,4 +39,33 @@ def get_default_inference_endpoint():
39
  # Define the index route
40
  @app.get('/', response_class=FileResponse)
41
  def index():
42
- return './static/index.html'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  # Define the index route
40
  @app.get('/', response_class=FileResponse)
41
  def index():
42
+ return './static/index.html'
43
+
44
+ from typing import Union
45
+ from transformers import pipeline
46
+
47
+ # Load miku pipeline
48
+ pipe_miku = pipeline("text-generation", model="miqudev/miqu-1-70b")
49
+
50
+ def miku(input):
51
+ output = pipe_miku(input)
52
+ return {"output": output[0]["generated_text"]}
53
+
54
+ @app.post("/infer_miku")
55
+ def infer_endpoint(data: dict):
56
+ """Receive input and generate text."""
57
+ input_text = data.get("input")
58
+
59
+ # Validate that the input is a string
60
+ assert isinstance(input_text, str), "Input must be a string."
61
+
62
+ if input_text is None:
63
+ return {"error": "No input text detected."}
64
+ else:
65
+ result = miku(input_text)
66
+ return result
67
+
68
+ @app.get("/infer_miku")
69
+ def get_default_inference_endpoint():
70
+ return {"message": "Use POST method to submit input data"}
71
+