Invescoz commited on
Commit
6f5e1f1
·
verified ·
1 Parent(s): cc68256

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -3,13 +3,18 @@ from llama_cpp import Llama
3
  from typing import Generator
4
  import os
5
 
6
- # Initialize llama.cpp model
7
- model_path = "AstroMLab/AstroSage-8B-GGUF" # Downloaded from AstroMLab/AstroSage-8B-Q8_0-GGUF
8
- llm = Llama(model_path=model_path, n_ctx=2048, n_threads=2) # Fits in 16GB RAM with 2 CPU cores
 
 
 
 
 
9
 
10
  def generate_astrology_prediction(prompt: str) -> Generator[str, None, None]:
11
  """
12
- Generates astrology-based fortune-telling predictions using AstroSage-8B-Q8_0-GGUF with streaming.
13
  """
14
  system_prompt = (
15
  "You are an expert astrologer, specializing in fortune-telling. Given a user prompt "
@@ -18,9 +23,9 @@ def generate_astrology_prediction(prompt: str) -> Generator[str, None, None]:
18
  "Use bullet points for key predictions and keep responses engaging and concise. "
19
  "Despite being trained on astronomy, adapt your knowledge to provide astrology-like insights."
20
  )
21
- full_prompt = f"<|SYSTEM|> {system_prompt} <|USER|> {prompt} <|ASSISTANT|>"
22
 
23
- # Stream output from llama.cpp
24
  for output in llm(full_prompt, max_tokens=1000, temperature=0.7, top_p=0.9, stream=True):
25
  content = output["choices"][0]["text"]
26
  if content:
 
3
  from typing import Generator
4
  import os
5
 
6
+ # Initialize model
7
+ model_path = "AstroSage-8B-BF16.gguf" # Downloaded from AstroMLab/AstroSage-8B-GGUF
8
+ llm = Llama.from_pretrained(
9
+ repo_id="AstroMLab/AstroSage-8B-GGUF",
10
+ filename=model_path,
11
+ n_ctx=2048, # Context length for prompts
12
+ n_threads=2 # Use 2 CPU cores
13
+ )
14
 
15
  def generate_astrology_prediction(prompt: str) -> Generator[str, None, None]:
16
  """
17
+ Generates astrology-based fortune-telling predictions using AstroSage-8B-BF16.gguf with streaming.
18
  """
19
  system_prompt = (
20
  "You are an expert astrologer, specializing in fortune-telling. Given a user prompt "
 
23
  "Use bullet points for key predictions and keep responses engaging and concise. "
24
  "Despite being trained on astronomy, adapt your knowledge to provide astrology-like insights."
25
  )
26
+ full_prompt = f"<|SYSTEM|> {system_prompt}\n<|USER|> {prompt}\n<|ASSISTANT|>"
27
 
28
+ # Stream output
29
  for output in llm(full_prompt, max_tokens=1000, temperature=0.7, top_p=0.9, stream=True):
30
  content = output["choices"][0]["text"]
31
  if content: