anubhav77 commited on
Commit
11dccc3
1 Parent(s): f030c48
Files changed (3) hide show
  1. .gitignore +1 -1
  2. src/chroma_intf.py +3 -2
  3. src/main.py +8 -2
.gitignore CHANGED
@@ -14,4 +14,4 @@ src/*.old.py
14
  src/toolSelector.py
15
  test/__pycache__/*.pyc
16
  src/baseInfra/memoryManager.py
17
- models/bge-large-en-v1.5/*.bin
 
14
  src/toolSelector.py
15
  test/__pycache__/*.pyc
16
  src/baseInfra/memoryManager.py
17
+ models/BAAI_bge-large-en-v1.5/*.bin
src/chroma_intf.py CHANGED
@@ -144,8 +144,9 @@ def addText(inStr:str,metadata):
144
  md=meta_defaults
145
  for key in metadata.keys():
146
  md[key]=metadata[key]
147
- md['timestamp']=datetime.now().strftime("%Y-%m-%d %H:%M:%S::%f")
148
- md['ID']=datetime.now().strftime("%Y-%m-%d %H:%M:%S::%f")+"-conversation"
 
149
 
150
  docs = [
151
  Document(page_content=inStr, metadata=md)]
 
144
  md=meta_defaults
145
  for key in metadata.keys():
146
  md[key]=metadata[key]
147
+ if "timestamp" not in metadata.keys():
148
+ md['timestamp']=datetime.now()
149
+ md['ID']=md['timestamp'].strftime("%Y-%m-%d %H:%M:%S::%f")+"-conversation"
150
 
151
  docs = [
152
  Document(page_content=inStr, metadata=md)]
src/main.py CHANGED
@@ -10,7 +10,7 @@ from fastapi import FastAPI as Response
10
  from sse_starlette.sse import EventSourceResponse
11
  from starlette.responses import StreamingResponse
12
  from starlette.requests import Request
13
- from pydantic import BaseModel
14
  from enum import Enum
15
  from typing import List, Dict, Any, Generator, Optional, cast, Callable
16
  from chroma_intf import *
@@ -19,9 +19,15 @@ import baseInfra.dropbox_handler as dbh
19
  class PathRequest(BaseModel):
20
  dir: str = "/"
21
 
 
 
 
 
 
 
22
  class DocWithMeta(BaseModel):
23
  text: str = ""
24
- metadata: Optional[dict] = {}
25
 
26
  async def catch_exceptions_middleware(
27
  request: Request, call_next: Callable[[Request], Any]
 
10
  from sse_starlette.sse import EventSourceResponse
11
  from starlette.responses import StreamingResponse
12
  from starlette.requests import Request
13
+ from pydantic import BaseModel, Extra
14
  from enum import Enum
15
  from typing import List, Dict, Any, Generator, Optional, cast, Callable
16
  from chroma_intf import *
 
19
  class PathRequest(BaseModel):
20
  dir: str = "/"
21
 
22
+ class MetaD(BaseModel):
23
+ timestamp: Optional[datetime]= datetime.now()
24
+ class Config:
25
+ allow_population_by_field_name = True
26
+ extra = Extra.allow
27
+
28
  class DocWithMeta(BaseModel):
29
  text: str = ""
30
+ metadata: Optional[MetaD] = MetaD()
31
 
32
  async def catch_exceptions_middleware(
33
  request: Request, call_next: Callable[[Request], Any]