Spaces:
Build error
Build error
Download app.py from bhashwarsengupta/Femma: direct link, hf CLI and curl.
- Browser
- Download file 683 Bytes
-
https://huggingface.co/spaces/bhashwarsengupta/Femma/resolve/main/app.py
- Command line
-
hf download hf://spaces/bhashwarsengupta/Femma/app.py
-
curl -L -o app.py https://huggingface.co/spaces/bhashwarsengupta/Femma/resolve/main/app.py
683 Bytes
| import gradio as gr | |
| import keras_nlp | |
| print("Modules loaded!") | |
| print("Fetching model...") | |
| model = keras_nlp.models.GemmaCausalLM.from_preset("hf://bhashwarsengupta/gemma2-instruct-2b-en-finance") | |
| print("model successfully loaded!") | |
| def respond( | |
| message, | |
| history: list[tuple[str, str]] | |
| ): | |
| messages = f"Question:\n{message}\n\nAnswer:\n" | |
| print("Generating response...") | |
| output = model.generate(messages) | |
| print("Response generated!") | |
| # Split by "Answer:" from the right and get the last part | |
| response = output.rsplit("Answer:\n", 1)[-1] | |
| return response | |
| demo = gr.ChatInterface( | |
| respond | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |