Spaces:
Runtime error
Runtime error
on1onmangoes
commited on
Commit
•
add9a1c
1
Parent(s):
c5a8c72
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,14 @@ HF_TOKEN = os.getenv("HF_TOKEN") # Replace with your actual token if not using
|
|
10 |
client = Client("on1onmangoes/CNIHUB101324v10", hf_token=HF_TOKEN)
|
11 |
# on1onmangoes/CNIHUB101324v10
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Function to handle chat API call
|
14 |
def stream_chat_with_rag(
|
15 |
message: str,
|
@@ -38,8 +46,44 @@ def stream_chat_with_rag(
|
|
38 |
penalty=penalty,
|
39 |
api_name="/chat"
|
40 |
)
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
# Function to handle PDF processing API call
|
45 |
def process_pdf(pdf_file):
|
|
|
10 |
client = Client("on1onmangoes/CNIHUB101324v10", hf_token=HF_TOKEN)
|
11 |
# on1onmangoes/CNIHUB101324v10
|
12 |
|
13 |
+
|
14 |
+
# Here's how you can fix it:
|
15 |
+
|
16 |
+
# Update the conversation history within the function.
|
17 |
+
# Return the updated history along with any other required outputs.
|
18 |
+
|
19 |
+
|
20 |
+
# Function to handle chat API call
|
21 |
# Function to handle chat API call
|
22 |
def stream_chat_with_rag(
|
23 |
message: str,
|
|
|
46 |
penalty=penalty,
|
47 |
api_name="/chat"
|
48 |
)
|
49 |
+
|
50 |
+
# Update the conversation history
|
51 |
+
history = history + [(message, response)]
|
52 |
+
|
53 |
+
# Return the assistant's reply and the updated history
|
54 |
+
return "", history
|
55 |
+
|
56 |
+
|
57 |
+
# # Function to handle chat API call
|
58 |
+
# def stream_chat_with_rag(
|
59 |
+
# message: str,
|
60 |
+
# history: list,
|
61 |
+
# client_name: str,
|
62 |
+
# system_prompt: str,
|
63 |
+
# num_retrieved_docs: int,
|
64 |
+
# num_docs_final: int,
|
65 |
+
# temperature: float,
|
66 |
+
# max_new_tokens: int,
|
67 |
+
# top_p: float,
|
68 |
+
# top_k: int,
|
69 |
+
# penalty: float,
|
70 |
+
# ):
|
71 |
+
# # Use the parameters provided by the UI
|
72 |
+
# response = client.predict(
|
73 |
+
# message=message,
|
74 |
+
# client_name=client_name,
|
75 |
+
# system_prompt=system_prompt,
|
76 |
+
# num_retrieved_docs=num_retrieved_docs,
|
77 |
+
# num_docs_final=num_docs_final,
|
78 |
+
# temperature=temperature,
|
79 |
+
# max_new_tokens=max_new_tokens,
|
80 |
+
# top_p=top_p,
|
81 |
+
# top_k=top_k,
|
82 |
+
# penalty=penalty,
|
83 |
+
# api_name="/chat"
|
84 |
+
# )
|
85 |
+
# # Return the assistant's reply
|
86 |
+
# return response
|
87 |
|
88 |
# Function to handle PDF processing API call
|
89 |
def process_pdf(pdf_file):
|