Spaces:
Runtime error
Runtime error
on1onmangoes
commited on
Update app.py
Browse files
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 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
)
|
26 |
-
return
|
|
|
|
|
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):
|