Spaces:
Sleeping
Sleeping
Update app.py to drop preamble
Browse files
app.py
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
|
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
os.environ["OPENAI_API_KEY"]
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
VectorStoreIndex,
|
| 6 |
-
SummaryIndex,
|
| 7 |
-
SimpleKeywordTableIndex,
|
| 8 |
-
SimpleDirectoryReader,
|
| 9 |
-
ServiceContext,
|
| 10 |
-
StorageContext,
|
| 11 |
-
load_index_from_storage
|
| 12 |
-
)
|
| 13 |
-
from llama_index.schema import IndexNode
|
| 14 |
-
from llama_index.tools import QueryEngineTool, ToolMetadata
|
| 15 |
-
from llama_index.llms import OpenAI
|
| 16 |
|
| 17 |
-
|
| 18 |
-
service_context = ServiceContext.from_defaults(llm=llm)
|
| 19 |
|
| 20 |
PERSIST_DIR = "arv_metadata"
|
| 21 |
storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR)
|
|
@@ -57,7 +51,7 @@ def nishauri(question: str, conversation_history: list[str]):
|
|
| 57 |
|
| 58 |
|
| 59 |
context = " ".join([item["user"] + " " + item["chatbot"] for item in conversation_history])
|
| 60 |
-
response = query_engine.query(preamble +
|
| 61 |
"the user previously asked and received the following: " +
|
| 62 |
context +
|
| 63 |
prompt_intro +
|
|
|
|
| 1 |
+
from llama_index.llms.openai import OpenAI
|
| 2 |
+
from llama_index.core.schema import MetadataMode
|
| 3 |
import os
|
| 4 |
+
import openai
|
| 5 |
os.environ["OPENAI_API_KEY"]
|
| 6 |
+
import logging
|
| 7 |
+
import sys
|
| 8 |
+
llm = OpenAI(temperature=0.0, model="gpt-3.5-turbo", max_tokens=512)
|
| 9 |
|
| 10 |
+
import nest_asyncio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
nest_asyncio.apply()
|
|
|
|
| 13 |
|
| 14 |
PERSIST_DIR = "arv_metadata"
|
| 15 |
storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR)
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
context = " ".join([item["user"] + " " + item["chatbot"] for item in conversation_history])
|
| 54 |
+
response = query_engine.query(#preamble +
|
| 55 |
"the user previously asked and received the following: " +
|
| 56 |
context +
|
| 57 |
prompt_intro +
|