Spaces:
Runtime error
Runtime error
File size: 561 Bytes
4c16e63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
from llama_cpp import Llama
# Initialize the Llama model with GGUF format
llm = Llama(model_path="./models/mistral-7b-instruct-v0.2.Q4_K_M.gguf", n_ctx=2048)
# Function to generate response
def generate_response(prompt):
output = llm(prompt, max_tokens=200, stop=["</s>"])
return output["choices"][0]["text"]
# Gradio interface to interact with the model
def chat(prompt):
return generate_response(prompt)
# Creating the Gradio interface
iface = gr.Interface(fn=chat, inputs="text", outputs="text", live=True)
iface.launch()
|