Spaces:
Runtime error
Runtime error
File size: 1,240 Bytes
ddf87ae 5f8c6e2 247c95d 5f8c6e2 ddf87ae ad8b1a6 5f8c6e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import os
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
model_id = "mistralai/Mistral-7B-Instruct-v0.3"
hf_token = os.environ.get("hf_token") # Space Secret olarak tanımladın
tokenizer = AutoTokenizer.from_pretrained(model_id, token=hf_token)
model = AutoModelForCausalLM.from_pretrained(model_id, token=hf_token, device_map="auto")
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
def bust_myth(statement):
prompt = f"""
You are a cultural myth-busting assistant.
Your task is to:
1. Determine if the following statement is true, false, or partially true.
2. If it's a misconception, explain why it's incorrect.
3. Provide the correct information with a short cultural context.
Statement: "{statement}"
"""
result = pipe(prompt, max_new_tokens=300, temperature=0.7)[0]["generated_text"]
return result
gr.Interface(
fn=bust_myth,
inputs=gr.Textbox(label="Enter a cultural or world belief", lines=3, placeholder="E.g. All Canadians live in igloos."),
outputs="text",
title="🌍 World Fact & Misconception Buster",
description="Enter a statement about a country, culture, or people. The AI will fact-check and explain it."
).launch()
|