Tijmen2 commited on
Commit
6b2aec8
·
verified ·
1 Parent(s): 831da4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -8,8 +8,15 @@ model_path = hf_hub_download(
8
  repo_id="AstroMLab/AstroSage-8B-GGUF",
9
  filename="AstroSage-8B-Q8_0.gguf"
10
  )
11
-
12
-
 
 
 
 
 
 
 
13
  # Placeholder responses for when context is empty
14
  GREETING_MESSAGES = [
15
  "Greetings! I am AstroSage, your guide to the cosmos. What would you like to explore today?",
@@ -26,15 +33,7 @@ def user(user_message, history):
26
 
27
  @spaces.GPU
28
  def bot(history):
29
- """Initialize the bot and stream the response."""
30
-
31
- llm = Llama(
32
- model_path=model_path,
33
- n_ctx=2048,
34
- chat_format="llama-3",
35
- n_gpu_layers=-1, # ensure all layers are on GPU
36
- flash_attn=True,
37
- )
38
 
39
  if not history:
40
  history = []
@@ -43,7 +42,7 @@ def bot(history):
43
  messages = [
44
  {
45
  "role": "system",
46
- "content": "You are AstroSage, an intelligent AI assistant specializing in astronomy, astrophysics, and space science. You provide accurate, scientific information while making complex concepts accessible. You're enthusiastic about space exploration and maintain a sense of wonder about the cosmos."
47
  }
48
  ]
49
 
 
8
  repo_id="AstroMLab/AstroSage-8B-GGUF",
9
  filename="AstroSage-8B-Q8_0.gguf"
10
  )
11
+
12
+ llm = Llama(
13
+ model_path=model_path,
14
+ n_ctx=2048,
15
+ chat_format="llama-3",
16
+ n_gpu_layers=-1, # ensure all layers are on GPU
17
+ flash_attn=True,
18
+ )
19
+
20
  # Placeholder responses for when context is empty
21
  GREETING_MESSAGES = [
22
  "Greetings! I am AstroSage, your guide to the cosmos. What would you like to explore today?",
 
33
 
34
  @spaces.GPU
35
  def bot(history):
36
+ """Yield the chatbot response for streaming."""
 
 
 
 
 
 
 
 
37
 
38
  if not history:
39
  history = []
 
42
  messages = [
43
  {
44
  "role": "system",
45
+ "content": "You are AstroSage, an intelligent AI assistant specializing in astronomy, astrophysics, and cosmology. Provide accurate, scientific information while making complex concepts accessible. You're enthusiastic about space exploration and maintain a sense of wonder about the cosmos."
46
  }
47
  ]
48