Spaces:
Runtime error
Runtime error
Vincent Claes
commited on
Commit
•
611aebd
1
Parent(s):
8b6eec6
first minimal working version using gradio
Browse files- Makefile +2 -0
- app.py +34 -0
- poetry.lock +0 -0
- pyproject.toml +1 -0
Makefile
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
deps:
|
2 |
+
poetry export --without-hashes --format=requirements.txt > requirements.txt
|
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
import weaviate
|
5 |
+
|
6 |
+
collection_name = "Chunk"
|
7 |
+
|
8 |
+
|
9 |
+
def predict(input_text):
|
10 |
+
client = weaviate.Client(
|
11 |
+
url=os.environ["WEAVIATE_URL"],
|
12 |
+
auth_client_secret=weaviate.AuthApiKey(api_key=os.environ["WEAVIATE_API_KEY"]),
|
13 |
+
additional_headers={
|
14 |
+
"X-OpenAI-Api-Key": os.environ["OPENAI_API_KEY"]
|
15 |
+
}
|
16 |
+
)
|
17 |
+
|
18 |
+
return (
|
19 |
+
client.query
|
20 |
+
.get(class_name=collection_name, properties=["text"])
|
21 |
+
.with_near_text({"concepts": input_text})
|
22 |
+
.with_limit(1)
|
23 |
+
.with_generate(single_prompt="{text}")
|
24 |
+
.do()
|
25 |
+
)
|
26 |
+
|
27 |
+
iface = gr.Interface(
|
28 |
+
fn=predict, # the function to wrap
|
29 |
+
inputs="text", # the input type
|
30 |
+
outputs="text", # the output type
|
31 |
+
)
|
32 |
+
|
33 |
+
if __name__ == "__main__":
|
34 |
+
iface.launch()
|
poetry.lock
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
pyproject.toml
CHANGED
@@ -12,6 +12,7 @@ llama-index = "^0.8.29.post1"
|
|
12 |
weaviate-client = "^3.24.1"
|
13 |
pypdf = "^3.16.1"
|
14 |
goldenverba = "^0.2.3"
|
|
|
15 |
|
16 |
|
17 |
[build-system]
|
|
|
12 |
weaviate-client = "^3.24.1"
|
13 |
pypdf = "^3.16.1"
|
14 |
goldenverba = "^0.2.3"
|
15 |
+
gradio = "^3.44.4"
|
16 |
|
17 |
|
18 |
[build-system]
|