Spaces:
Sleeping
Sleeping
ElliottLepine
commited on
Commit
·
a4288d6
1
Parent(s):
013e46d
Add FastAPI
Browse files
app.py
CHANGED
@@ -7,6 +7,9 @@ from llama_index import (
|
|
7 |
)
|
8 |
import chromadb
|
9 |
from typing import TypedDict
|
|
|
|
|
|
|
10 |
|
11 |
from llama_index.llms import MistralAI
|
12 |
from llama_index.embeddings import MistralAIEmbedding
|
@@ -48,6 +51,8 @@ index = VectorStoreIndex(
|
|
48 |
)
|
49 |
query_engine = index.as_query_engine(similarity_top_k=5)
|
50 |
|
|
|
|
|
51 |
# Structure of the data sent by the form
|
52 |
InputForm = TypedDict('InputForm', {
|
53 |
'department': str,
|
@@ -58,8 +63,9 @@ InputForm = TypedDict('InputForm', {
|
|
58 |
})
|
59 |
|
60 |
# This function is the API endpoint the web app will use
|
|
|
61 |
def find_my_rotation(input: InputForm):
|
62 |
-
return "Hi, you. Your farm is " + input["farmSize"] + "ha"
|
63 |
|
64 |
|
65 |
def get_documents_in_db():
|
|
|
7 |
)
|
8 |
import chromadb
|
9 |
from typing import TypedDict
|
10 |
+
from fastapi import FastAPI, File, UploadFile, Request
|
11 |
+
from fastapi.responses import JSONResponse
|
12 |
+
|
13 |
|
14 |
from llama_index.llms import MistralAI
|
15 |
from llama_index.embeddings import MistralAIEmbedding
|
|
|
51 |
)
|
52 |
query_engine = index.as_query_engine(similarity_top_k=5)
|
53 |
|
54 |
+
app = FastAPI()
|
55 |
+
|
56 |
# Structure of the data sent by the form
|
57 |
InputForm = TypedDict('InputForm', {
|
58 |
'department': str,
|
|
|
63 |
})
|
64 |
|
65 |
# This function is the API endpoint the web app will use
|
66 |
+
@app.post("/find-my-rotation")
|
67 |
def find_my_rotation(input: InputForm):
|
68 |
+
return JSONResponse({"response": "Hi, you. Your farm is " + input["farmSize"] + "ha"})
|
69 |
|
70 |
|
71 |
def get_documents_in_db():
|