Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,9 +16,6 @@ client = Client("on1onmangoes/CNIHUB101324v10", hf_token=HF_TOKEN)
|
|
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,
|
24 |
history: list,
|
@@ -46,12 +43,60 @@ def stream_chat_with_rag(
|
|
46 |
penalty=penalty,
|
47 |
api_name="/chat"
|
48 |
)
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
# Update the conversation history
|
51 |
history = history + [(message, response)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
54 |
-
|
55 |
|
56 |
|
57 |
# # Function to handle chat API call
|
|
|
16 |
# Update the conversation history within the function.
|
17 |
# Return the updated history along with any other required outputs.
|
18 |
|
|
|
|
|
|
|
19 |
def stream_chat_with_rag(
|
20 |
message: str,
|
21 |
history: list,
|
|
|
43 |
penalty=penalty,
|
44 |
api_name="/chat"
|
45 |
)
|
46 |
+
|
47 |
+
# Debugging statements
|
48 |
+
print(f"API Response Type: {type(response)}")
|
49 |
+
print(f"API Response: {response}")
|
50 |
+
|
51 |
+
# Ensure response is a string
|
52 |
+
if isinstance(response, list):
|
53 |
+
# If response is a list, extract the assistant's reply
|
54 |
+
response = response[0] if response else ""
|
55 |
+
|
56 |
# Update the conversation history
|
57 |
history = history + [(message, response)]
|
58 |
+
|
59 |
+
# Return the updated history
|
60 |
+
return history
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
# # Function to handle chat API call
|
66 |
+
# # Function to handle chat API call
|
67 |
+
# def stream_chat_with_rag(
|
68 |
+
# message: str,
|
69 |
+
# history: list,
|
70 |
+
# client_name: str,
|
71 |
+
# system_prompt: str,
|
72 |
+
# num_retrieved_docs: int,
|
73 |
+
# num_docs_final: int,
|
74 |
+
# temperature: float,
|
75 |
+
# max_new_tokens: int,
|
76 |
+
# top_p: float,
|
77 |
+
# top_k: int,
|
78 |
+
# penalty: float,
|
79 |
+
# ):
|
80 |
+
# # Use the parameters provided by the UI
|
81 |
+
# response = client.predict(
|
82 |
+
# message=message,
|
83 |
+
# client_name=client_name,
|
84 |
+
# system_prompt=system_prompt,
|
85 |
+
# num_retrieved_docs=num_retrieved_docs,
|
86 |
+
# num_docs_final=num_docs_final,
|
87 |
+
# temperature=temperature,
|
88 |
+
# max_new_tokens=max_new_tokens,
|
89 |
+
# top_p=top_p,
|
90 |
+
# top_k=top_k,
|
91 |
+
# penalty=penalty,
|
92 |
+
# api_name="/chat"
|
93 |
+
# )
|
94 |
+
|
95 |
+
# # Update the conversation history
|
96 |
+
# history = history + [(message, response)]
|
97 |
|
98 |
+
# # Return the assistant's reply and the updated history
|
99 |
+
# return "", history
|
100 |
|
101 |
|
102 |
# # Function to handle chat API call
|