on1onmangoes commited on
Commit
807b3b1
·
verified ·
1 Parent(s): b26952f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -14
app.py CHANGED
@@ -8,22 +8,54 @@ HF_TOKEN = os.getenv("HF_TOKEN") # Replace with your actual token if not using
8
  # Initialize the Gradio Client for the specified API
9
  client = Client("on1onmangoes/CNIHUB10724v9", hf_token=HF_TOKEN)
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  # Function to handle chat API call
12
- def stream_chat_with_rag(message, system_prompt, num_retrieved_docs, num_docs_final, temperature, max_new_tokens, top_p, top_k, penalty):
13
- response = client.predict(
14
- message=message,
15
- client_name="rosariarossi", # Hardcoded client name
16
- system_prompt=system_prompt,
17
- num_retrieved_docs=num_retrieved_docs,
18
- num_docs_final=num_docs_final,
19
- temperature=temperature,
20
- max_new_tokens=max_new_tokens,
21
- top_p=top_p,
22
- top_k=top_k,
23
- penalty=penalty,
24
- api_name="/chat"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  )
26
- return response
 
 
27
 
28
  # Function to handle PDF processing API call
29
  def process_pdf(pdf_file):
 
8
  # Initialize the Gradio Client for the specified API
9
  client = Client("on1onmangoes/CNIHUB10724v9", hf_token=HF_TOKEN)
10
 
11
+ # OG code in V9
12
+ def stream_chat_with_rag(
13
+ message: str,
14
+ history: list,
15
+ client_name: str,
16
+ system_prompt: str,
17
+ num_retrieved_docs: int = 10,
18
+ num_docs_final: int = 9,
19
+ temperature: float = 0,
20
+ max_new_tokens: int = 1024,
21
+ top_p: float = 1.0,
22
+ top_k: int = 20,
23
+ penalty: float = 1.2,
24
+ ):
25
+
26
  # Function to handle chat API call
27
+ # def stream_chat_with_rag(message, system_prompt, num_retrieved_docs, num_docs_final, temperature, max_new_tokens, top_p, top_k, penalty):
28
+ # response = client.predict(
29
+ # message=message,
30
+ # client_name="rosariarossi", # Hardcoded client name
31
+ # system_prompt=system_prompt,
32
+ # num_retrieved_docs=num_retrieved_docs,
33
+ # num_docs_final=num_docs_final,
34
+ # temperature=temperature,
35
+ # max_new_tokens=max_new_tokens,
36
+ # top_p=top_p,
37
+ # top_k=top_k,
38
+ # penalty=penalty,
39
+ # api_name="/chat"
40
+ # )
41
+ # return response
42
+
43
+ result = client.predict(
44
+ message="Hello!!",
45
+ client_name="rosariarossi",
46
+ system_prompt="You are an expert assistant",
47
+ num_retrieved_docs=10,
48
+ num_docs_final=9,
49
+ temperature=0,
50
+ max_new_tokens=1024,
51
+ top_p=1,
52
+ top_k=20,
53
+ penalty=1.2,
54
+ api_name="/chat"
55
  )
56
+ return result
57
+
58
+
59
 
60
  # Function to handle PDF processing API call
61
  def process_pdf(pdf_file):