Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,14 @@
|
|
1 |
-
import openai
|
2 |
import gradio
|
|
|
3 |
|
4 |
openai.api_key = "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"
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
messages.append({"role": "user", "content": user_input})
|
10 |
-
response = openai.ChatCompletion.create(
|
11 |
-
model = "gpt-3.5-turbo",
|
12 |
-
messages = messages
|
13 |
-
)
|
14 |
-
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
15 |
-
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
16 |
-
return ChatGPT_reply
|
17 |
-
|
18 |
-
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Real Estate Pro")
|
19 |
|
20 |
demo.launch(inline=False)
|
|
|
|
|
1 |
import gradio
|
2 |
+
from llama_index import SimpleDirectoryReader, GPTListIndex, readers, GPTSimpleVectorIndex, LLMPredictor, PromptHelper, ServiceContext
|
3 |
|
4 |
openai.api_key = "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"
|
5 |
|
6 |
+
def gradio_ask_ai(user_input):
|
7 |
+
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
8 |
+
query = user_input
|
9 |
+
response = index.query(query)
|
10 |
+
return response.response
|
11 |
|
12 |
+
demo = gradio.Interface(fn=gradio_ask_ai, inputs = "text", outputs = "text", title = "Meshwork_bot")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
demo.launch(inline=False)
|