Spaces:
Runtime error
Runtime error
File size: 790 Bytes
611aebd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import os
import gradio as gr
import weaviate
collection_name = "Chunk"
def predict(input_text):
client = weaviate.Client(
url=os.environ["WEAVIATE_URL"],
auth_client_secret=weaviate.AuthApiKey(api_key=os.environ["WEAVIATE_API_KEY"]),
additional_headers={
"X-OpenAI-Api-Key": os.environ["OPENAI_API_KEY"]
}
)
return (
client.query
.get(class_name=collection_name, properties=["text"])
.with_near_text({"concepts": input_text})
.with_limit(1)
.with_generate(single_prompt="{text}")
.do()
)
iface = gr.Interface(
fn=predict, # the function to wrap
inputs="text", # the input type
outputs="text", # the output type
)
if __name__ == "__main__":
iface.launch()
|