tugot17 commited on
Commit
5ec0408
1 Parent(s): e903846

Upload 3 files

Browse files
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ faiss_index_03/index.faiss filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import gradio as gr
3
+ from langchain import FAISS
4
+ from langchain.embeddings import OpenAIEmbeddings
5
+ import os
6
+
7
+
8
+ embeddings = OpenAIEmbeddings()
9
+ faiss_path = Path(__file__).parent / "faiss_index_03"
10
+ docsearch = FAISS.load_local(faiss_path, embeddings)
11
+
12
+ def generate_outputs(query: str, k: int):
13
+ outputs = []
14
+ docs_and_scores = docsearch.similarity_search_with_score(query, k=k)
15
+ for doc, score in docs_and_scores:
16
+ output_text = f"{doc.page_content} + \n Score: {score:.2f}"
17
+ outputs.append(output_text)
18
+ return "\n---------------------------------------------------------\n" \
19
+ "---------------------------------------------------------\n" \
20
+ "---------------------------------------------------------\n".join(outputs)
21
+
22
+ # Define input/output interfaces and options
23
+ iface = gr.Interface(
24
+ fn=generate_outputs,
25
+ inputs=[
26
+ gr.Textbox(label="Enter your text", value="Sample text", lines=2),
27
+ gr.Slider(label="Number of outputs", minimum=1, maximum=12, value=4)
28
+ ],
29
+ outputs=[
30
+ gr.Textbox(label="Generated Outputs")
31
+ ],
32
+ title="Text Generation App",
33
+ description="Enter your text and choose the number of outputs you'd like to generate"
34
+ )
35
+
36
+ # Launch the Gradio app
37
+ iface.launch()
faiss_index_03/index.faiss ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ce554e40e6d45f9f6e876bad78020e38f1a84f55f0e444d452e83fff9ee9ad5
3
+ size 31033389
faiss_index_03/index.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f88804041a4c7ea4f718746eba3a2955588d7180dfc17036bd09bac682827604
3
+ size 13955061