0504ankitsharma commited on
Commit
4d9d3fd
·
verified ·
1 Parent(s): 5298e3b

Upload server.py

Browse files
Files changed (1) hide show
  1. server.py +10 -2
server.py CHANGED
@@ -12,6 +12,8 @@ from get_embedding_function import get_embedding_function
12
  from langchain_community.vectorstores import Chroma
13
  from langchain.prompts import ChatPromptTemplate
14
  from langchain_community.llms.ollama import Ollama
 
 
15
 
16
  PROMPT_TEMPLATE = """
17
  Answer the question based only on the following context:
@@ -41,6 +43,11 @@ def get_embedding_function():
41
  def greet_json():
42
  return {"Hello": "World!"}
43
 
 
 
 
 
 
44
  @app.get("/train")
45
  def train():
46
 
@@ -139,8 +146,9 @@ def clear_database():
139
 
140
 
141
  @app.get("/query")
142
- def query(query_text: str):
143
- # Prepare the DB.
 
144
  embedding_function = get_embedding_function()
145
  db = Chroma(persist_directory=CHROMA_PATH, embedding_function=embedding_function)
146
 
 
12
  from langchain_community.vectorstores import Chroma
13
  from langchain.prompts import ChatPromptTemplate
14
  from langchain_community.llms.ollama import Ollama
15
+ from pydantic import BaseModel
16
+
17
 
18
  PROMPT_TEMPLATE = """
19
  Answer the question based only on the following context:
 
43
  def greet_json():
44
  return {"Hello": "World!"}
45
 
46
+
47
+ class QueryRequest(BaseModel):
48
+ query_text: str
49
+
50
+
51
  @app.get("/train")
52
  def train():
53
 
 
146
 
147
 
148
  @app.get("/query")
149
+ def query(request: QueryRequest):
150
+ query_text = request.query_text
151
+ # Prepare the DB.
152
  embedding_function = get_embedding_function()
153
  db = Chroma(persist_directory=CHROMA_PATH, embedding_function=embedding_function)
154