alpdroidchat / app.py
alperall's picture
Update app.py
db534bd verified
raw
history blame
1.04 kB
import gradio as gr
from transformers import pipeline
# Model seçimi (hafif, hızlı)
model_name = "TheBloke/Mistral-7B-Instruct-v0.1-GGUF"
# Pipeline ile sohbet modeli açıyoruz
chat = pipeline("text-generation", model=model_name, device=0, trust_remote_code=True)
# AlpDroid promptunu çekiyoruz (Raw link)
import requests
prompt_url = "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
system_prompt = requests.get(prompt_url).text
def alp_droid_chat(user_input):
full_prompt = system_prompt + "\n\nKullanıcı: " + user_input + "\nAlpDroid:"
response = chat(full_prompt, max_length=512, do_sample=True, temperature=0.7)
return response[0]['generated_text'].split("AlpDroid:")[-1].strip()
iface = gr.Interface(fn=alp_droid_chat,
inputs=gr.Textbox(lines=5, placeholder="Sorunu yaz..."),
outputs="text",
title="AlpDroid AI Chat",
description="Mistral tabanlı AlpDroid promptuyla çalışan yapay zeka.")
iface.launch()