Update app.py
Browse files
app.py
CHANGED
|
@@ -23,30 +23,6 @@ from utils import query_as_list, get_answer
|
|
| 23 |
import gradio as gr
|
| 24 |
from fewshot import examples
|
| 25 |
|
| 26 |
-
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0, api_key=os.environ['API_KEY'])
|
| 27 |
-
example_selector = SemanticSimilarityExampleSelector.from_examples(
|
| 28 |
-
examples,
|
| 29 |
-
OpenAIEmbeddings(model="text-embedding-3-small", api_key=os.environ['API_KEY']),
|
| 30 |
-
Chroma(persist_directory="data"),
|
| 31 |
-
# Chroma,
|
| 32 |
-
k=5,
|
| 33 |
-
input_keys=["input"],
|
| 34 |
-
)
|
| 35 |
-
|
| 36 |
-
db = SQLDatabase.from_uri("sqlite:///attendance_system.db")
|
| 37 |
-
|
| 38 |
-
employee = query_as_list(db, "SELECT FullName FROM Employee")
|
| 39 |
-
|
| 40 |
-
vector_db = Chroma.from_texts(employee, OpenAIEmbeddings(model="text-embedding-3-small", api_key=os.environ['API_KEY']))
|
| 41 |
-
retriever = vector_db.as_retriever(search_kwargs={"k": 15})
|
| 42 |
-
description = """Use to look up values to filter on. Input is an approximate spelling of the proper noun, output is \
|
| 43 |
-
valid proper nouns. Use the noun most similar to the search."""
|
| 44 |
-
retriever_tool = create_retriever_tool(
|
| 45 |
-
retriever,
|
| 46 |
-
name="search_proper_nouns",
|
| 47 |
-
description=description,
|
| 48 |
-
)
|
| 49 |
-
|
| 50 |
|
| 51 |
if __name__ == "__main__":
|
| 52 |
demo = gr.Interface(fn=get_answer, inputs="text", outputs="text")
|
|
|
|
| 23 |
import gradio as gr
|
| 24 |
from fewshot import examples
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
demo = gr.Interface(fn=get_answer, inputs="text", outputs="text")
|