Spaces:
Sleeping
Sleeping
Asaad Almutareb
commited on
Commit
•
9620371
1
Parent(s):
3619e81
moved collect_urls to utils and added chat_history in app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from hf_mixtral_agent import agent_executor
|
|
3 |
from innovation_pathfinder_ai.source_container.container import (
|
4 |
all_sources
|
5 |
)
|
|
|
6 |
|
7 |
if __name__ == "__main__":
|
8 |
|
@@ -23,6 +24,7 @@ if __name__ == "__main__":
|
|
23 |
result = agent_executor.invoke(
|
24 |
{
|
25 |
"input": question,
|
|
|
26 |
}
|
27 |
)
|
28 |
return result
|
@@ -32,20 +34,6 @@ if __name__ == "__main__":
|
|
32 |
print("You upvoted this response: " + data.value)
|
33 |
else:
|
34 |
print("You downvoted this response: " + data.value)
|
35 |
-
|
36 |
-
def collect_urls(data_list):
|
37 |
-
urls = []
|
38 |
-
for item in data_list:
|
39 |
-
# Check if item is a string and contains 'link:'
|
40 |
-
if isinstance(item, str) and 'link:' in item:
|
41 |
-
start = item.find('link:') + len('link: ')
|
42 |
-
end = item.find(',', start)
|
43 |
-
url = item[start:end if end != -1 else None].strip()
|
44 |
-
urls.append(url)
|
45 |
-
# Check if item is a dictionary and has 'Entry ID'
|
46 |
-
elif isinstance(item, dict) and 'Entry ID' in item:
|
47 |
-
urls.append(item['Entry ID'])
|
48 |
-
return urls
|
49 |
|
50 |
css="""
|
51 |
#col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
|
|
|
3 |
from innovation_pathfinder_ai.source_container.container import (
|
4 |
all_sources
|
5 |
)
|
6 |
+
from innovation_pathfinder_ai.utils import collect_urls
|
7 |
|
8 |
if __name__ == "__main__":
|
9 |
|
|
|
24 |
result = agent_executor.invoke(
|
25 |
{
|
26 |
"input": question,
|
27 |
+
"chat_history": history
|
28 |
}
|
29 |
)
|
30 |
return result
|
|
|
34 |
print("You upvoted this response: " + data.value)
|
35 |
else:
|
36 |
print("You downvoted this response: " + data.value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
css="""
|
39 |
#col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
|