holytinz278 commited on
Commit
7a4a5a6
·
verified ·
1 Parent(s): bfdf731

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -1,11 +1,27 @@
1
  import gradio as gr
 
 
2
  from huggingface_hub import InferenceClient
3
 
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
- client = InferenceClient("Qwen/QwQ-32B-Preview")
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  def respond(
11
  message,
@@ -46,7 +62,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
46
  demo = gr.ChatInterface(
47
  respond,
48
  additional_inputs=[
49
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
  gr.Slider(
@@ -59,6 +75,5 @@ demo = gr.ChatInterface(
59
  ],
60
  )
61
 
62
-
63
  if __name__ == "__main__":
64
- demo.launch()
 
1
  import gradio as gr
2
+ import psycopg2
3
+ from database import db_connection
4
  from huggingface_hub import InferenceClient
5
 
6
  """
7
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
8
  """
9
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
10
 
11
+ CREATOR_NAME = "Ridimz" # Define your creator name here
12
+
13
+ def fetch_system_message():
14
+ conn = db_connection()
15
+ cursor = conn.cursor()
16
+ cursor.execute("SELECT message FROM system_messages WHERE name = 'MicroAI'")
17
+ result = cursor.fetchone()
18
+ cursor.close()
19
+ conn.close()
20
+
21
+ if result:
22
+ return result[0] # Return the message associated with 'MicroAI'
23
+ else:
24
+ return f"You are Micro AI, created by {CREATOR_NAME}. Follow the instructions precisely."
25
 
26
  def respond(
27
  message,
 
62
  demo = gr.ChatInterface(
63
  respond,
64
  additional_inputs=[
65
+ gr.Textbox(value=fetch_system_message(), label="System message"), # Call the function to fetch system message
66
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
67
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
68
  gr.Slider(
 
75
  ],
76
  )
77
 
 
78
  if __name__ == "__main__":
79
+ demo.launch()