alperall commited on
Commit
f87b1c9
·
verified ·
1 Parent(s): 63d3ddc

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -86
app.py DELETED
@@ -1,86 +0,0 @@
1
- import gradio as gr
2
- import requests
3
- from huggingface_hub import InferenceClient
4
-
5
- client = InferenceClient("mistralai/Mistral-Nemo-Instruct-2407")
6
-
7
- # Sabit GitHub raw URL'si
8
- GITHUB_RAW_URL = "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
9
-
10
-
11
- def fetch_system_message():
12
- """Fetch system message from a GitHub raw link."""
13
- try:
14
- response = requests.get(GITHUB_RAW_URL)
15
- response.raise_for_status()
16
- return response.text.strip()
17
- except requests.exceptions.RequestException as e:
18
- return f"Error fetching system message: {str(e)}"
19
-
20
-
21
- def respond(message, history):
22
- # Sabit parametreler
23
- max_tokens = 512
24
- temperature = 0.7
25
- top_p = 0.95
26
-
27
- # Fetch the system message from GitHub
28
- system_message = fetch_system_message()
29
- if system_message.startswith("Error"):
30
- yield system_message
31
- return
32
-
33
- messages = [{"role": "system", "content": system_message}]
34
-
35
- for val in history:
36
- if val[0]:
37
- messages.append({"role": "user", "content": val[0]})
38
- if val[1]:
39
- messages.append({"role": "assistant", "content": val[1]})
40
-
41
- messages.append({"role": "user", "content": message})
42
-
43
- response = ""
44
-
45
- for message in client.chat_completion(
46
- messages,
47
- max_tokens=max_tokens,
48
- stream=True,
49
- temperature=temperature,
50
- top_p=top_p,
51
- ):
52
- token = message.choices[0].delta.content
53
- response += token
54
- yield response
55
-
56
-
57
- # Koyu tema tanımlama
58
- theme=gr.themes.Soft(
59
- primary_hue="emerald",
60
- secondary_hue="emerald",
61
- neutral_hue="gray",
62
- font=[
63
- gr.themes.GoogleFont("Exo"),
64
- "ui-sans-serif",
65
- "system-ui",
66
- "sans-serif"
67
- ]).set(
68
- body_background_fill_dark="#010409",
69
- block_background_fill_dark="#010409",
70
- block_border_width="1px",
71
- block_title_background_fill_dark="#1e1c26",
72
- input_background_fill_dark="#161b22",
73
- button_secondary_background_fill_dark="#21262d",
74
- border_color_accent_dark="#2f353c",
75
- border_color_primary_dark="#2f353c",
76
- background_fill_secondary_dark="#010409",
77
- color_accent_soft_dark="transparent",
78
- code_background_fill_dark="#0d1117",
79
- )
80
- # Demo başlatılıyor
81
- demo = gr.ChatInterface(
82
- respond,
83
- )
84
-
85
- if __name__ == "__main__":
86
- demo.launch(share=True)