Asaad Almutareb commited on
Commit
057d3c8
1 Parent(s): 25cdf03

using react widget for UI

Browse files
innovation_pathfinder_ai/backend/app/api/v1/agents/hf_mixtral_agent.py CHANGED
@@ -41,7 +41,7 @@ async def websocket_endpoint(websocket: WebSocket):
41
  try:
42
  data = await websocket.receive_json()
43
  user_message = data["message"]
44
- chat_history = data["history"]
45
 
46
  # resp = IChatResponse(
47
  # sender="you",
 
41
  try:
42
  data = await websocket.receive_json()
43
  user_message = data["message"]
44
+ chat_history = []#data["history"]
45
 
46
  # resp = IChatResponse(
47
  # sender="you",
innovation_pathfinder_ai/backend/app/main.py CHANGED
@@ -1,5 +1,7 @@
1
  from fastapi import FastAPI
2
  from app.api.v1.api import api_router as api_router_v1
 
 
3
  #from app.core.config import settings
4
  from fastapi.middleware.cors import CORSMiddleware
5
 
@@ -23,5 +25,10 @@ async def root():
23
  """
24
  return {"message": "API is running"}
25
 
 
 
 
 
 
26
  # Include the versioned API router from api.py
27
  app.include_router(api_router_v1)
 
1
  from fastapi import FastAPI
2
  from app.api.v1.api import api_router as api_router_v1
3
+ from fastapi.responses import HTMLResponse
4
+ from app.templates.chat import chat_html
5
  #from app.core.config import settings
6
  from fastapi.middleware.cors import CORSMiddleware
7
 
 
25
  """
26
  return {"message": "API is running"}
27
 
28
+ @app.get("/chat", response_class=HTMLResponse)
29
+ async def chat():
30
+
31
+ return chat_html
32
+
33
  # Include the versioned API router from api.py
34
  app.include_router(api_router_v1)
innovation_pathfinder_ai/backend/app/templates/chat.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ chat_html = """
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <title></title>
6
+ </head>
7
+ <body>
8
+ <webchat-widget
9
+ widget-websocket="ws://localhost:8001/chat/agent"
10
+ widget-color="#47A7F6"
11
+ widget-chat-avatar="https://icon-library.com/images/ai-icon/ai-icon-7.jpg"
12
+ widget-user-avatar="https://img2.freepng.es/20210721/osx/transparent-jedi-avatar-60f79d68da49c0.1144258416268404248941.jpg"
13
+ widget-header="Bot"
14
+ widget-subheader="Online"
15
+ widget-placeholder="Send a message"
16
+ widget-position="true"
17
+ widget-on="false"
18
+ >
19
+ </webchat-widget>
20
+ <script src="https://webchat-widget.pages.dev/static/js/main.js"></script>
21
+ </body>
22
+ </html>
23
+ """