Zaman
commited on
Commit
•
f3b5192
1
Parent(s):
3bb282f
first commit
Browse files- .gitattributes +1 -0
- Dockerfile +20 -0
- apple_amazon_intel_db/chroma-collections.parquet +3 -0
- apple_amazon_intel_db/chroma-embeddings.parquet +3 -0
- apple_amazon_intel_db/index/id_to_uuid_8f095a90-6d97-4fdf-9d51-9b5f73967d45.pkl +3 -0
- apple_amazon_intel_db/index/index_8f095a90-6d97-4fdf-9d51-9b5f73967d45.bin +3 -0
- apple_amazon_intel_db/index/index_metadata_8f095a90-6d97-4fdf-9d51-9b5f73967d45.pkl +3 -0
- apple_amazon_intel_db/index/uuid_to_id_8f095a90-6d97-4fdf-9d51-9b5f73967d45.pkl +3 -0
- bot.py +73 -0
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
apple_amazon_intel_db/* filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
|
5 |
+
COPY ./requirements.txt /code/requirements.txt
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
+
|
9 |
+
RUN useradd -m -u 1000 user
|
10 |
+
|
11 |
+
USER user
|
12 |
+
|
13 |
+
ENV HOME=/home/user \
|
14 |
+
PATH=/home/user/.local/bin:$PATH
|
15 |
+
|
16 |
+
WORKDIR $HOME/app
|
17 |
+
|
18 |
+
COPY --chown=user . $HOME/app
|
19 |
+
|
20 |
+
CMD ["python", "bot.py"]
|
apple_amazon_intel_db/chroma-collections.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:871da07e6cb6d8c1a616b7d95befddf94a3b931384b7e015586d1f29588e62d9
|
3 |
+
size 557
|
apple_amazon_intel_db/chroma-embeddings.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1eaecc1ed1ed43b90c98d42c0a00c16766d6e74d3bf13059913ffd085b295bbb
|
3 |
+
size 4161157
|
apple_amazon_intel_db/index/id_to_uuid_8f095a90-6d97-4fdf-9d51-9b5f73967d45.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e4a5418bc95f6a0a161d3ea6d34ca9ff5ec434898a7a3aba191c052dd31698e9
|
3 |
+
size 9886
|
apple_amazon_intel_db/index/index_8f095a90-6d97-4fdf-9d51-9b5f73967d45.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a35749f0fb151b9e1bacda8e3efb11ff0947d69eb2e5858f3256119429644db8
|
3 |
+
size 1956956
|
apple_amazon_intel_db/index/index_metadata_8f095a90-6d97-4fdf-9d51-9b5f73967d45.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bfb70802984f23bfcb81fb3e446fdf3aa5fb2ea9750c861ef5229a3427080615
|
3 |
+
size 74
|
apple_amazon_intel_db/index/uuid_to_id_8f095a90-6d97-4fdf-9d51-9b5f73967d45.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:de693f7d2c056c4b7620f2bf84d591f8de64193f1dae6cfe3308c9af0933fc12
|
3 |
+
size 11579
|
bot.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
import time
|
4 |
+
from langchain.embeddings.openai import OpenAIEmbeddings
|
5 |
+
from langchain.vectorstores import FAISS, Chroma
|
6 |
+
from langchain.chat_models.openai import ChatOpenAI
|
7 |
+
from langchain.chains import ConversationalRetrievalChain
|
8 |
+
from langchain.memory import ConversationBufferWindowMemory
|
9 |
+
|
10 |
+
# RetrievalQAWithSourcesChain.from_llm()
|
11 |
+
# ConversationalRetrievalChain()
|
12 |
+
|
13 |
+
|
14 |
+
# os.environ["OPENAI_API_KEY"] = "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"
|
15 |
+
print(os.environ.get("OPENAI_API_KEY"))
|
16 |
+
persist_direcory = "apple_amazon_intel_db"
|
17 |
+
# persist_directory = "db"
|
18 |
+
|
19 |
+
embeddings = OpenAIEmbeddings()
|
20 |
+
# db = FAISS.load_local(persist_directory, embeddings)
|
21 |
+
chroma = Chroma(embedding_function=embeddings, persist_directory=persist_direcory)
|
22 |
+
retriever = chroma.as_retriever(search_type="mmr", search_kwargs={"k": 10})
|
23 |
+
|
24 |
+
memory = ConversationBufferWindowMemory(
|
25 |
+
memory_key="chat_history", return_messages=False
|
26 |
+
)
|
27 |
+
|
28 |
+
qa = ConversationalRetrievalChain.from_llm(
|
29 |
+
llm=ChatOpenAI(model_name="gpt-4", temperature=0, streaming=True),
|
30 |
+
chain_type="stuff",
|
31 |
+
retriever=retriever,
|
32 |
+
memory=memory,
|
33 |
+
get_chat_history=lambda h: h,
|
34 |
+
verbose=True,
|
35 |
+
# return_source_documents=True,
|
36 |
+
)
|
37 |
+
|
38 |
+
# res = qa({"question": "what is AD790?", "chat_history": []})
|
39 |
+
# print(res["answer"])
|
40 |
+
|
41 |
+
with gr.Blocks() as demo:
|
42 |
+
chatbot = gr.Chatbot()
|
43 |
+
msg = gr.Textbox()
|
44 |
+
clear = gr.Button("clear")
|
45 |
+
|
46 |
+
def user(user_message, history):
|
47 |
+
return "", history + [[user_message, None]]
|
48 |
+
|
49 |
+
def bot(history):
|
50 |
+
bot_message = qa.run({"question": history[-1][0], "chat_history": history[:-1]})
|
51 |
+
history[-1][1] = ""
|
52 |
+
for character in bot_message:
|
53 |
+
history[-1][1] += character
|
54 |
+
time.sleep(0.05)
|
55 |
+
yield history
|
56 |
+
|
57 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
58 |
+
bot, chatbot, chatbot
|
59 |
+
)
|
60 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
61 |
+
|
62 |
+
demo.queue()
|
63 |
+
demo.launch(share=False, server_name="0.0.0.0")
|
64 |
+
"""
|
65 |
+
Total net revenues of approximately $14.6 billion was up 6.1% on an
|
66 |
+
operational basis
|
67 |
+
|
68 |
+
what was the net revenue during the quarter?
|
69 |
+
The net revenue during the quarter was $14.6 billion.
|
70 |
+
how much did it increase percentage on opeational basis?
|
71 |
+
The percentage increase in net revenue on an operational basis during the quarter was 6.1%.
|
72 |
+
what was the 2022 adjusted earnings per share guidance ?
|
73 |
+
"""
|