Skip to content

Commit

Permalink
cleaned reposne
Browse files Browse the repository at this point in the history
Signed-off-by: SarveshAtawane <[email protected]>
  • Loading branch information
SarveshAtawane committed Oct 7, 2024
1 parent b035d79 commit 684529a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def generate_response(session_id, model, tokenizer, query, vectordb):
Provide a very concise answer in no more than three short sentences."""

full_prompt = f"{qa_system_prompt}\n\nContext: {context}\n\nQuestion: {contextualized_query}\n\nAnswer:"

inputs = tokenizer(full_prompt, return_tensors="pt", padding=True).to(model.device)
streamer = TextIteratorStreamer(
tokenizer, skip_prompt=True, skip_special_tokens=True
Expand All @@ -75,4 +75,4 @@ def generate_response(session_id, model, tokenizer, query, vectordb):
print(response)
conversation_history.add_user_message(query)
conversation_history.add_ai_message(response)
return response
return response
5 changes: 4 additions & 1 deletion src/core/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from langchain.vectorstores import Chroma
from embeddings import embedding_function
from langchain_community.vectorstores.utils import filter_complex_metadata

config_data = load_yaml_file("config.yaml")

persist_directory = config_data["persist_directory"]
Expand All @@ -27,7 +28,9 @@
splits = text_splitter.split_documents(docs)

print(f"Number of chunks created: {len(splits)}")
vectorstore = Chroma.from_documents(filter_complex_metadata(splits), embeddings, persist_directory=persist_directory)
vectorstore = Chroma.from_documents(
filter_complex_metadata(splits), embeddings, persist_directory=persist_directory
)
# vectorstore = Chroma.from_documents(
# documents=splits, embedding=embeddings, persist_directory=persist_directory
# )
Expand Down
4 changes: 4 additions & 0 deletions src/core/routes/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@

router = APIRouter()


class ResponseMessage(BaseModel):
content: str
type: int
id: str


class RequestQuery(BaseModel):
id: str
content: str


class ResponseQuery(BaseModel):
id: str
message: ResponseMessage


@router.post("/query", response_model=ResponseQuery)
async def answer_query(item: RequestQuery) -> ResponseQuery:
try:
Expand Down

0 comments on commit 684529a

Please sign in to comment.