File size: 1,451 Bytes
fe02755 | 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 35 36 37 38 39 40 | import gradio as gr
import requests
import json
# الرابط ديال السيرفر ديالك فـ DigitalOcean
URL = "http://134.199.193.220:8000/v1/chat/completions"
def generate_response(message, history):
payload = {
"model": "meta-llama/Meta-Llama-3-8B-Instruct",
"messages": [
{"role": "system", "content": "You are a helpful Moroccan assistant. Answer in Moroccan Darija."},
{"role": "user", "content": message}
],
"temperature": 0.7,
"max_tokens": 500
}
headers = {"Content-Type": "application/json"}
try:
response = requests.post(URL, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
result = response.json()
return result['choices'][0]['message']['content']
else:
return f"خطأ من السيرفر: {response.status_code}"
except Exception as e:
return f"ماقدرتش نتواصل مع AMD GPU: {str(e)}"
# واجهة الشات
demo = gr.ChatInterface(
fn=generate_response,
title="Sawt AI - Powered by AMD MI300X",
description="هاد المساعد الذكي خدام بأقوى GPU ديال AMD فـ DigitalOcean ومرتبط بـ Hugging Face",
examples=["كيف داير؟", "شنو هي أحسن مدينة فالمغرب؟", "عطيني وصفة ديال الطجين"]
)
if __name__ == "__main__":
demo.launch() |