Spaces:
Runtime error
Runtime error
Zwea Htet
commited on
Commit
β’
93b834c
1
Parent(s):
90653e1
refactor imports
Browse files- app.py +1 -29
- data.py β data/regItems.py +0 -0
- model/model.py +0 -25
- model.py β models/bloom.py +2 -4
- {model β models}/customLLM.py +0 -0
app.py
CHANGED
@@ -1,41 +1,13 @@
|
|
1 |
-
# import os
|
2 |
-
# from datetime import datetime
|
3 |
-
|
4 |
-
# from flask import Flask, redirect, render_template, request, url_for
|
5 |
-
# from model import initialize_index
|
6 |
-
|
7 |
-
# app = Flask(__name__)
|
8 |
-
# index = None
|
9 |
-
|
10 |
-
# @app.route("/")
|
11 |
-
# def home():
|
12 |
-
# return render_template('chat.html')
|
13 |
-
|
14 |
-
# @app.route("/get")
|
15 |
-
# def get_bot_response():
|
16 |
-
# query_text = request.args.get("msg", None)
|
17 |
-
# if query_text is None:
|
18 |
-
# return "Invalid input"
|
19 |
-
# response = index.query(query_text)
|
20 |
-
# return str(response), 200
|
21 |
-
|
22 |
-
# if __name__ == "__main__":
|
23 |
-
# index = initialize_index("index.json")
|
24 |
-
# app.run(debug=True)
|
25 |
import os
|
26 |
from datetime import datetime
|
27 |
|
28 |
import openai
|
29 |
from flask import Flask, redirect, render_template, request, session, url_for
|
30 |
-
from
|
31 |
|
32 |
app = Flask(__name__)
|
33 |
-
app.secret_key = os.environ.get('SECRET_KEY', 'my-secret-key')
|
34 |
index = None
|
35 |
|
36 |
-
# Set up OpenAI authentication
|
37 |
-
# openai.api_key = os.environ.get('OPENAI_API_KEY')
|
38 |
-
|
39 |
@app.route("/")
|
40 |
def home():
|
41 |
if 'access_token' not in session:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
from datetime import datetime
|
3 |
|
4 |
import openai
|
5 |
from flask import Flask, redirect, render_template, request, session, url_for
|
6 |
+
from models.bloom import initialize_index
|
7 |
|
8 |
app = Flask(__name__)
|
|
|
9 |
index = None
|
10 |
|
|
|
|
|
|
|
11 |
@app.route("/")
|
12 |
def home():
|
13 |
if 'access_token' not in session:
|
data.py β data/regItems.py
RENAMED
File without changes
|
model/model.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
-
import openai
|
4 |
-
from customLLM import CustomLLM, prompt_helper
|
5 |
-
from data import data
|
6 |
-
from dotenv import load_dotenv
|
7 |
-
from llama_index import (Document, GPTSimpleVectorIndex, LLMPredictor,
|
8 |
-
ServiceContext)
|
9 |
-
|
10 |
-
load_dotenv()
|
11 |
-
|
12 |
-
# openai.api_key = os.getenv("OPENAI_API_KEY")
|
13 |
-
|
14 |
-
#define our llm
|
15 |
-
llm_predictor = LLMPredictor(llm=CustomLLM())
|
16 |
-
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, prompt_helper=prompt_helper)
|
17 |
-
|
18 |
-
def initialize_index(index_name):
|
19 |
-
if os.path.exists(index_name):
|
20 |
-
return GPTSimpleVectorIndex.load_from_disk(index_name)
|
21 |
-
else:
|
22 |
-
documents = [Document(d) for d in data]
|
23 |
-
index = GPTSimpleVectorIndex.from_documents(documents, service_context=service_context)
|
24 |
-
index.save_to_disk(index_name)
|
25 |
-
return index
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.py β models/bloom.py
RENAMED
@@ -1,15 +1,13 @@
|
|
1 |
import os
|
2 |
|
3 |
-
import openai
|
4 |
from customLLM import CustomLLM, prompt_helper
|
5 |
-
from data import data
|
6 |
from dotenv import load_dotenv
|
7 |
from llama_index import (Document, GPTSimpleVectorIndex, LLMPredictor,
|
8 |
ServiceContext)
|
9 |
|
10 |
-
|
11 |
|
12 |
-
|
13 |
|
14 |
#define our llm
|
15 |
llm_predictor = LLMPredictor(llm=CustomLLM())
|
|
|
1 |
import os
|
2 |
|
|
|
3 |
from customLLM import CustomLLM, prompt_helper
|
|
|
4 |
from dotenv import load_dotenv
|
5 |
from llama_index import (Document, GPTSimpleVectorIndex, LLMPredictor,
|
6 |
ServiceContext)
|
7 |
|
8 |
+
from data.regItems import data
|
9 |
|
10 |
+
load_dotenv()
|
11 |
|
12 |
#define our llm
|
13 |
llm_predictor = LLMPredictor(llm=CustomLLM())
|
{model β models}/customLLM.py
RENAMED
File without changes
|