Spaces:
Sleeping
Sleeping
Download app.py from Subhajit01/InterViewBuddyLLM: direct link, hf CLI and curl.
- Browser
- Download file 707 Bytes
-
https://huggingface.co/spaces/Subhajit01/InterViewBuddyLLM/resolve/main/app.py
- Command line
-
hf download hf://spaces/Subhajit01/InterViewBuddyLLM/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Subhajit01/InterViewBuddyLLM/resolve/main/app.py
707 Bytes
| from flask import Flask, request, jsonify | |
| from transformers import AutoModelForSeq2SeqLM, AutoTokenizer | |
| from flask_cors import CORS | |
| app = Flask(__name__) | |
| CORS(app) | |
| tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small") | |
| model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small") | |
| def chat(): | |
| data = request.get_json() | |
| prompt = data.get("prompt", "") | |
| inputs = tokenizer(prompt, return_tensors="pt") | |
| outputs = model.generate(**inputs, max_new_tokens=100) | |
| reply = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| return jsonify({"response": reply}) | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=7860) | |