abhi1nandy2 commited on
Commit
7ea7d8d
·
verified ·
1 Parent(s): 6761a81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -18,7 +18,7 @@ def get_text_from_url(url):
18
  visible_texts = filter(tag_visible, texts)
19
  return "\n".join(t.strip() for t in visible_texts)
20
 
21
- # Get the text from your homepage (and any additional extensions as needed)
22
  text_list = []
23
  homepage_url = "https://sites.google.com/view/abhilashnandy/home/"
24
  extensions = ["", "pmrf-profile-page"]
@@ -26,18 +26,15 @@ for ext in extensions:
26
  url_text = get_text_from_url(homepage_url + ext)
27
  text_list.append(url_text)
28
 
29
- # Optionally, repeat for sub-links if necessary
30
-
31
- # Build a system message with the homepage info
32
  SYSTEM_MESSAGE = (
33
  "You are a QA chatbot to answer queries (in less than 30 words) on my homepage that has the following information -\n\n"
34
  + "\n\n".join(text_list)
35
  + "\n\n"
36
  )
37
 
38
- # Use a model that works well on CPU, has a decently long context, and low inference latency.
39
- # Here we choose a small chat-optimized model:
40
- client = InferenceClient("TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF")
41
 
42
  def respond(message, history: list[tuple[str, str]], system_message=SYSTEM_MESSAGE,
43
  max_tokens=140, temperature=0.7, top_p=0.95):
@@ -54,7 +51,7 @@ def respond(message, history: list[tuple[str, str]], system_message=SYSTEM_MESSA
54
  max_tokens=max_tokens,
55
  temperature=temperature,
56
  top_p=top_p,
57
- # stream=True, # Uncomment to enable streaming
58
  )
59
  return response.choices[0].message["content"]
60
  except Exception as e:
@@ -71,7 +68,7 @@ with demo:
71
  fn=respond,
72
  examples=["Yo who dis Abhilash?", "What is Abhilash's most recent publication?"],
73
  additional_inputs=[
74
- # You can add extra Gradio components here if needed.
75
  ],
76
  )
77
 
 
18
  visible_texts = filter(tag_visible, texts)
19
  return "\n".join(t.strip() for t in visible_texts)
20
 
21
+ # Gather text from your homepage (and any extensions)
22
  text_list = []
23
  homepage_url = "https://sites.google.com/view/abhilashnandy/home/"
24
  extensions = ["", "pmrf-profile-page"]
 
26
  url_text = get_text_from_url(homepage_url + ext)
27
  text_list.append(url_text)
28
 
29
+ # Build the system message with homepage info.
 
 
30
  SYSTEM_MESSAGE = (
31
  "You are a QA chatbot to answer queries (in less than 30 words) on my homepage that has the following information -\n\n"
32
  + "\n\n".join(text_list)
33
  + "\n\n"
34
  )
35
 
36
+ # Use the GPTQ variant of TinyLlama which includes the tokenizer configuration
37
+ client = InferenceClient("TheBloke/TinyLlama-1.1B-Chat-v1.0-GPTQ")
 
38
 
39
  def respond(message, history: list[tuple[str, str]], system_message=SYSTEM_MESSAGE,
40
  max_tokens=140, temperature=0.7, top_p=0.95):
 
51
  max_tokens=max_tokens,
52
  temperature=temperature,
53
  top_p=top_p,
54
+ # stream=True, # Uncomment this if you want streaming output for debugging.
55
  )
56
  return response.choices[0].message["content"]
57
  except Exception as e:
 
68
  fn=respond,
69
  examples=["Yo who dis Abhilash?", "What is Abhilash's most recent publication?"],
70
  additional_inputs=[
71
+ # Additional components can be added here if needed.
72
  ],
73
  )
74